[clang] [clang][driver] Improve Clang-CL support for C++20 standard modules (PR #98761)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 13 11:37:46 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Sharadh Rajaraman (sharadhr)

<details>
<summary>Changes</summary>

This PR is the first step in improving the situation for `clang-cl` detailed in [this LLVM Discourse thread](https://discourse.llvm.org/t/clang-cl-exe-support-for-c-modules/72257/28). There has been some work done in #<!-- -->89772. I believe this is somewhat orthogonal.

This is a work-in-progress; the functionality has only been tested with the [basic 'Hello World' example](https://clang.llvm.org/docs/StandardCPlusPlusModules.html#quick-start), and proper test cases need to be written. Additionally, the `/std:c++20` command-line argument is considered unused (although it is very much required, and compilation fails without it) with the following warning:

```
clang: warning: argument unused during compilation: '/std:c++20' [-Wunused-command-line-argument]
```

I suspect the issue is somewhere around https://github.com/llvm/llvm-project/blob/8802c9fd73da9451e69e15eed53b396c7d44a866/clang/lib/Driver/ToolChains/Clang.cpp#L6285-L6300

I'd like some thoughts on this, thanks!

---
Full diff: https://github.com/llvm/llvm-project/pull/98761.diff


1 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+2-1) 


``````````diff
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 4ab8638175dd3..ca7cfef8453a0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3085,7 +3085,7 @@ def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Grou
   HelpText<"Specify the module user build path">,
   MarshallingInfoString<HeaderSearchOpts<"ModuleUserBuildPath">>;
 def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group<i_Group>,
-  Flags<[]>, Visibility<[ClangOption, CC1Option]>,
+  Flags<[]>, Visibility<[ClangOption, CLOption, CC1Option]>,
   MetaVarName<"<directory>">,
   HelpText<"Specify the prebuilt module path">;
 defm prebuilt_implicit_modules : BoolFOption<"prebuilt-implicit-modules",
@@ -5874,6 +5874,7 @@ def _output : Separate<["--"], "output">, Alias<o>;
 def _param : Separate<["--"], "param">, Group<CompileOnly_Group>;
 def _param_EQ : Joined<["--"], "param=">, Alias<_param>;
 def _precompile : Flag<["--"], "precompile">, Flags<[NoXarchOption]>,
+  Visibility<[ClangOption, CLOption]>,
   Group<Action_Group>, HelpText<"Only precompile the input">;
 def _prefix_EQ : Joined<["--"], "prefix=">, Alias<B>;
 def _prefix : Separate<["--"], "prefix">, Alias<B>;

``````````

</details>


https://github.com/llvm/llvm-project/pull/98761


More information about the cfe-commits mailing list