The -fsystem-module flag is used when explicitly building a module. It
forces the module to be treated as a system module. This is used when
converting an implicit build to an explicit build to match the
systemness the implicit build would have had for a given module.
Details
- Reviewers
rsmith bruno - Commits
- rG27a3ecee4558: [clang][Modules] Add -fsystem-module flag
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hi Michael, thanks for improving this.
clang/include/clang/Driver/Options.td | ||
---|---|---|
1448 | I wonder if -isystem-module wouldn't be better since it's kinda similar with -isystem for headers, but for modules. | |
clang/lib/Frontend/CompilerInvocation.cpp | ||
1912 | What happens when we use this with implicit modules? It will just be ignored? If so, users might think that using -fsystem-module might help them get rid of some warnings/errors, when in fact it won't. | |
clang/test/Modules/fsystem-module.m | ||
2 | Is this really needed given you are only using %t-saved below? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
1448 | FWIW, I prefer -fsystem-module. I would expect -i* to be modifying search paths, and this option does not do that. |
This is used when
converting an implicit build to an explicit build to match the
systemness the implicit build would have had for a given module.
I had another thought. What if for the explicitly built "system" modules:
- If -Wsystem-headers is on, leave them as user modules in the explicit build.
- If -Wsystem-headers is off, turn off all diagnostics in the explicit build.
Does that give the right semantics, or is there something subtly different?
clang/lib/Frontend/CompilerInvocation.cpp | ||
---|---|---|
1912 | It's an error unless you also pass -emit-module. If you also have implicit modules enabled while explicitly building a module then those modules will be treated as normal, but I don't think there's a huge cause for confusion there. The only way to use it is when explicitly building a module, so it's clear which module it applies to. | |
clang/test/Modules/fsystem-module.m | ||
2 | It's not, that's a leftover from the test I based this one on. I'll clean it up. |
I considered this, but decided against it because I wanted the implicit and explicit builds to be as similar as possible, and reduce the amount of changes made to the original command line. There's a lot of code in Clang dealing with system files, and I'm not 100% sure that -Wno-everything would be equivalent.
I wonder if -isystem-module wouldn't be better since it's kinda similar with -isystem for headers, but for modules.