aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/cc/compile-rule.cxx30
-rw-r--r--libbuild2/cxx/init.cxx23
2 files changed, 19 insertions, 34 deletions
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index ee97b39..aefcc30 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -3606,16 +3606,6 @@ namespace build2
// Some compile options (e.g., -std, -m) affect the preprocessor.
//
- // Currently Clang supports importing "header modules" even when in
- // the TS mode. And "header modules" support macros which means
- // imports have to be resolved during preprocessing. Which poses a
- // bit of a chicken and egg problem for us. For now, the workaround
- // is to remove the -fmodules-ts option when preprocessing. Hopefully
- // there will be a "pure modules" mode at some point.
- //
- // @@ MODHDR Clang: should be solved with the dynamic module mapper
- // if/when Clang supports it?
- //
// Don't treat warnings as errors.
//
@@ -3708,8 +3698,7 @@ namespace build2
}
case compiler_class::gcc:
{
- append_options (args, cmode,
- cmode.size () - (modules && clang ? 1 : 0));
+ append_options (args, cmode, cmode.size ());
append_sys_hdr_options (args); // Extra system header dirs (last).
// If not gen, then stderr is discarded.
@@ -6885,11 +6874,7 @@ namespace build2
if (ms.start == 0)
return;
- // Clang embeds module file references so we only need to specify
- // our direct imports.
- //
- // If/when we get the ability to specify the mapping in a file, we
- // will pass the whole list.
+ // If/when we get the ability to specify the mapping in a file.
//
#if 0
// In Clang the module implementation's unit .pcm is special and
@@ -6910,9 +6895,16 @@ namespace build2
s.insert (0, "-fmodule-file-map=@=");
stor.push_back (move (s));
#else
+ // Clang embeds module file references so we only need to specify
+ // our direct imports. @@ TMP: note anymore, clean up.
+ //
auto& pts (t.prerequisite_targets[a]);
for (size_t i (ms.start),
+#if 0
n (ms.copied != 0 ? ms.copied : pts.size ());
+#else
+ n (pts.size ());
+#endif
i != n;
++i)
{
@@ -6942,9 +6934,7 @@ namespace build2
return;
auto& pts (t.prerequisite_targets[a]);
- for (size_t i (ms.start), n (pts.size ());
- i != n;
- ++i)
+ for (size_t i (ms.start), n (pts.size ()); i != n; ++i)
{
const target* pt (pts[i]);
diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx
index 3023ad5..8948e6a 100644
--- a/libbuild2/cxx/init.cxx
+++ b/libbuild2/cxx/init.cxx
@@ -433,20 +433,15 @@ namespace build2
}
case compiler_type::clang:
{
- // @@ TMP: revise
+ // Things (command line options, semantics) changed quite a bit
+ // around Clang 16 so we don't support anything earlier than
+ // that (it's not practically usable anyway).
//
- // At the time of this writing, support for C++20 modules in
- // Clang is incomplete. And starting with Clang 9 (Apple Clang
- // 11.0.3), they are enabled by default in the C++2a mode which
- // breaks the way we set things up for partial preprocessing;
- // see this post for details:
- //
- // http://lists.llvm.org/pipermail/cfe-dev/2019-October/063637.html
- //
- // As a result, for now, we only enable modules if forced with
- // explicit cxx.features.modules=true.
- //
- // Also see Clang modules support hack in cc::compile.
+ // Clang enable modules by default in c++20 or later but they
+ // don't yet (as of Clang 18) define __cpp_modules. When they
+ // do, we can consider enabling modules by default on our side.
+ // For now, we only enable modules if forced with explicit
+ // cxx.features.modules=true.
//
if (modules.value)
{
@@ -459,7 +454,7 @@ namespace build2
// See https://github.com/llvm/llvm-project/issues/71364
//
- prepend ("-D__cpp_modules=201704"); // p0629r0
+ prepend ("-D__cpp_modules=201907L");
modules = true;
}