-
Notifications
You must be signed in to change notification settings - Fork 10
Support compiling C++ modules with Clang >= 16 #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support compiling C++ modules with Clang >= 16 #60
Conversation
|
Of course Apple Clang has to behave differently to mainline Clang in this specific instance... |
peterebden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Was ages ago that I looked at the module stuff though; I'm not surprised it doesn't match up any more, but I also hear they've been tricky to support in general - I don't know to what degree we have something that works in the real world any more. (Although it is noted as experimental in the comment at least!)
Indeed: C++ modules are a mess. I'd like to keep whatever level of support we currently have, but it's pretty hard to figure out exactly what's broken across the various compiler versions - #61 should simplify that quite a bit... |
00eff8b to
2be2a57
Compare
|
Force-pushing to rebase on master so we get the benefit of the new CI tests on this PR. |
The flags necessary for Clang to compile C++ modules changed between Clang 15 and 17: * Clang >= 16 just require C++20 features to be enabled (`-std=c++20`) in order to enable modules, while older versions of Clang explicitly require modules to be enabled via the `-fmodules-ts` option. Choose the appropriate flag based on the detected Clang version. * Clang >= 17 require a dependent module's name to be specified along with its path with `-fmodule-file`, otherwise a warning (`-Weager-load-cxx-named-modules`) is outputted, but specifying the module's name at all is a syntax error with Clang < 16. When using Clang >= 16, specify the basename of the module file as the module name; nothing in the C++ specification says that a single module has to be declared in a file of the same name, but it'll be the case most of the time (and will fail loudly in the other cases). Fixes please-build#27.
2be2a57 to
4b33bd1
Compare
|
I've given up trying to figure out whether Apple Clang supports C++ modules - the compiler's error messages say yes, but only with I'm going to disable these tests by default unless they're re-enabled with a feature flag, and set that feature flag for the |
The flags necessary for Clang to compile C++ modules changed between Clang 15 and 17:
-std=c++20) in order to enable modules, while older versions of Clang explicitly require modules to be enabled via the-fmodules-tsoption. Choose the appropriate flag based on the detected Clang version.-fmodule-file, otherwise a warning (-Weager-load-cxx-named-modules) is outputted, but specifying the module's name at all is a syntax error with Clang < 16 (and Apple Clang < 15). When using Clang >= 16, specify the basename of the module file as the module name; nothing in the C++ specification says that a single module has to be declared in a file of the same name, but it'll be the case most of the time (and will fail loudly in the other cases).Fixes #27.