Skip to content

Commit 6adc5b2

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b2de37237c9a' from llvm.org/release/19.x into stable/20240723
2 parents 27c858c + b2de372 commit 6adc5b2

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ BMIs cannot be shipped in an archive to create a module library. Instead, the
398398
BMIs(``*.pcm``) are compiled into object files(``*.o``) and those object files
399399
are added to the archive instead.
400400

401+
clang-cl
402+
~~~~~~~~
403+
404+
``clang-cl`` supports the same options as ``clang++`` for modules as detailed above;
405+
there is no need to prefix these options with ``/clang:``. Note that ``cl.exe``
406+
`options to emit/consume IFC files <https://devblogs.microsoft.com/cppblog/using-cpp-modules-in-msvc-from-the-command-line-part-1/>` are *not* supported.
407+
The resultant precompiled modules are also not compatible for use with ``cl.exe``.
408+
409+
We recommend that build system authors use the above-mentioned ``clang++`` options with ``clang-cl`` to build modules.
410+
401411
Consistency Requirements
402412
~~~~~~~~~~~~~~~~~~~~~~~~
403413

@@ -1387,13 +1397,6 @@ have ``.cppm`` (or ``.ccm``, ``.cxxm``, ``.c++m``) as the file extension.
13871397
However, the behavior is inconsistent with other compilers. This is tracked by
13881398
`#57416 <https://github.com/llvm/llvm-project/issues/57416>`_.
13891399

1390-
clang-cl is not compatible with standard C++ modules
1391-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1392-
1393-
``/clang:-fmodule-file`` and ``/clang:-fprebuilt-module-path`` cannot be used
1394-
to specify the BMI with ``clang-cl.exe``. This is tracked by
1395-
`#64118 <https://github.com/llvm/llvm-project/issues/64118>`_.
1396-
13971400
Incorrect ODR violation diagnostics
13981401
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13991402

clang/docs/UsersManual.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4745,6 +4745,12 @@ Execute ``clang-cl /?`` to see a list of supported options:
47454745
-flto=<value> Set LTO mode to either 'full' or 'thin'
47464746
-flto Enable LTO in 'full' mode
47474747
-fmerge-all-constants Allow merging of constants
4748+
-fmodule-file=<module_name>=<module-file>
4749+
Use the specified module file that provides the module <module_name>
4750+
-fmodule-header=<header>
4751+
Build <header> as a C++20 header unit
4752+
-fmodule-output=<path>
4753+
Save intermediate module file results when compiling a standard C++ module unit.
47484754
-fms-compatibility-version=<value>
47494755
Dot-separated value representing the Microsoft compiler version
47504756
number to report in _MSC_VER (0 = don't define it; default is same value as installed cl.exe, or 1933)

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@ def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Grou
31383138
HelpText<"Specify the module user build path">,
31393139
MarshallingInfoString<HeaderSearchOpts<"ModuleUserBuildPath">>;
31403140
def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group<i_Group>,
3141-
Flags<[]>, Visibility<[ClangOption, CC1Option]>,
3141+
Flags<[]>, Visibility<[ClangOption, CLOption, CC1Option]>,
31423142
MetaVarName<"<directory>">,
31433143
HelpText<"Specify the prebuilt module path">;
31443144
defm prebuilt_implicit_modules : BoolFOption<"prebuilt-implicit-modules",
@@ -3150,11 +3150,11 @@ def fmodule_related_to_pch : Flag<["-"], "fmodule-related-to-pch">,
31503150
HelpText<"Mark module as related to a PCH">;
31513151

31523152
def fmodule_output_EQ : Joined<["-"], "fmodule-output=">,
3153-
Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option]>,
3153+
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, CC1Option]>,
31543154
MarshallingInfoString<FrontendOpts<"ModuleOutputPath">>,
31553155
HelpText<"Save intermediate module file results when compiling a standard C++ module unit.">;
31563156
def fmodule_output : Flag<["-"], "fmodule-output">, Flags<[NoXarchOption]>,
3157-
Visibility<[ClangOption, CC1Option]>,
3157+
Visibility<[ClangOption, CLOption, CC1Option]>,
31583158
HelpText<"Save intermediate module file results when compiling a standard C++ module unit.">;
31593159

31603160
defm skip_odr_check_in_gmf : BoolOption<"f", "skip-odr-check-in-gmf",
@@ -3334,8 +3334,10 @@ def fretain_comments_from_system_headers : Flag<["-"], "fretain-comments-from-sy
33343334
Visibility<[ClangOption, CC1Option]>,
33353335
MarshallingInfoFlag<LangOpts<"RetainCommentsFromSystemHeaders">>;
33363336
def fmodule_header : Flag <["-"], "fmodule-header">, Group<f_Group>,
3337+
Visibility<[ClangOption, CLOption]>,
33373338
HelpText<"Build a C++20 Header Unit from a header">;
33383339
def fmodule_header_EQ : Joined<["-"], "fmodule-header=">, Group<f_Group>,
3340+
Visibility<[ClangOption, CLOption]>,
33393341
MetaVarName<"<kind>">,
33403342
HelpText<"Build a C++20 Header Unit from a header that should be found in the user (fmodule-header=user) or system (fmodule-header=system) search path.">;
33413343

@@ -6006,6 +6008,7 @@ def _output : Separate<["--"], "output">, Alias<o>;
60066008
def _param : Separate<["--"], "param">, Group<CompileOnly_Group>;
60076009
def _param_EQ : Joined<["--"], "param=">, Alias<_param>;
60086010
def _precompile : Flag<["--"], "precompile">, Flags<[NoXarchOption]>,
6011+
Visibility<[ClangOption, CLOption]>,
60096012
Group<Action_Group>, HelpText<"Only precompile the input">;
60106013
def _prefix_EQ : Joined<["--"], "prefix=">, Alias<B>;
60116014
def _prefix : Separate<["--"], "prefix">, Alias<B>;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cl /std:c++20 --precompile -### -- %s 2>&1 | FileCheck --check-prefix=PRECOMPILE %s
2+
// PRECOMPILE: -emit-module-interface
3+
4+
// RUN: %clang_cl /std:c++20 --fmodule-file=Foo=Foo.pcm -### -- %s 2>&1 | FileCheck --check-prefix=FMODULEFILE %s
5+
// FMODULEFILE: -fmodule-file=Foo=Foo.pcm
6+
7+
// RUN: %clang_cl /std:c++20 --fprebuilt-module-path=. -### -- %s 2>&1 | FileCheck --check-prefix=FPREBUILT %s
8+
// FPREBUILT: -fprebuilt-module-path=.

0 commit comments

Comments
 (0)