[libcxx-commits] [libcxx] [libcxx] Fix libcxx config to be non-textual. (PR #130723)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 10 23:05:35 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Matt (matts1)

<details>
<summary>Changes</summary>

When building libcxx as a module, it fails to build because it's missing various definitions.

Consider the following code for module A:
```
#include <module B that includes __config_site>
#include <__config>
#include <module C that includes __config>
```

With the module map file:
```
module std {
   module A { header "a.h" }
   module B { header "b.h" }
   module C { header "c.h" }
}
```

Macro visibility rules state that "[macros] are visible if they are from the current submodule or translation unit, or if they were exported from a submodule that has been imported."
* Module A has visibility of all macros exported by modules B and C (because they were exported from an imported submodule)
* Module B and C have visibility over all macros exported by module A (because they are from the current submodule)

1) When we #include the first line, module B successfully includes __config_site.

Module B exports: __config_site contents, __config_site header guard

2) Module A now includes <__config> directly

Because it can see module B's exports, it stops at the header guard for __config_site and does not include __config_site. This is not an issue, however, because it has visibility onto everything exported from __config_site thanks to module B.

Module A exports: __config  contents, __config header guard, __config's includes' content and header guard (*except __config_site*)

3) Module C now includes __config. Based on the above visibility rules, it can see everything exported from module A.

Because of that, we see the header guard for __config and do not import it at all. This is mostly OK, as we can see the __config that module A exported. However, if we ever try and access __config_site, it will fail, as A did not export __config_site.

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


1 Files Affected:

- (modified) libcxx/include/module.modulemap (+8-7) 


``````````diff
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index b9964dac84acd..b719f6d69273d 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1,13 +1,14 @@
 // This module contains headers related to the configuration of the library. These headers
 // are free of any dependency on the rest of libc++.
 module std_config [system] {
-  textual header "__config"
-  textual header "__configuration/abi.h"
-  textual header "__configuration/availability.h"
-  textual header "__configuration/compiler.h"
-  textual header "__configuration/language.h"
-  textual header "__configuration/platform.h"
-  textual header "version"
+  header "__config"
+  header "__configuration/abi.h"
+  header "__configuration/availability.h"
+  header "__configuration/compiler.h"
+  header "__configuration/language.h"
+  header "__configuration/platform.h"
+  header "version"
+  export *
 }
 
 module std_core [system] {

``````````

</details>


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


More information about the libcxx-commits mailing list