[clang] [clang][driver] Improve Clang-CL support for C++20 standard modules (PR #98761)
Sharadh Rajaraman via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 13 11:36:58 PDT 2024
https://github.com/sharadhr created https://github.com/llvm/llvm-project/pull/98761
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!
>From 1fed92a00f0d732a2575861c2bf6a6d053407255 Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman <r.sharadh at outlook.sg>
Date: Sat, 13 Jul 2024 19:25:47 +0100
Subject: [PATCH] Allow `--precompile` and `-fprebuilt-module-path` to be
passed directly into CL driver without `/clang:` prefix
---
clang/include/clang/Driver/Options.td | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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>;
More information about the cfe-commits
mailing list