<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Compiler-provided inttypes.h is not recognized as belonging to any module"
href="https://bugs.llvm.org/show_bug.cgi?id=51307">51307</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler-provided inttypes.h is not recognized as belonging to any module
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Modules
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mark+llvm.org@bdash.net.nz
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Attempting to compile a module containing a header that imports `inttypes.h`
with `-fmodules-strict-decluse` enabled results in an error despite providing
Clang with the Darwin module that provides `inttypes.h`:
```
While building module 'test':
In file included from <module-includes>:1:
./test.h:1:10: error: module test does not depend on a module exporting
'inttypes.h'
#include <inttypes.h>
^
1 error generated.
```
Clang finds `inttypes.h` within the compiler-provided headers, but does not
consider the header to be built-in. The header is not present in the module map
alongside the compiler-provided headers so there is no other module to depend
on to access the header when using `-fmodules-strict-decluse`.
Most other compiler-provided headers are present in either the module map[1] or
as built-in headers that are treated as belonging to the module that provides
the header they're wrapping[2]. `inttypes.h` and a few other headers are absent
from both. `inttypes.h` appears like it should be treated as a built-in header.
It's not clear how the other headers should be handled.
Platform-agnostic headers that appear to be missing from both the module map
and built-in header list:
inttypes.h
builtins.h
stdnoreturn.h
varargs.h
vadefs.h
There are a number of platform-specific headers that are also absent from the
module map.
[1]:
<a href="https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/module.modulemap">https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/module.modulemap</a>
[2]:
<a href="https://github.com/llvm/llvm-project/blob/07548b83247e5c266e209ac4cdc2ab7a3231155d/clang/lib/Lex/ModuleMap.cpp#L372-L389">https://github.com/llvm/llvm-project/blob/07548b83247e5c266e209ac4cdc2ab7a3231155d/clang/lib/Lex/ModuleMap.cpp#L372-L389</a>
Steps to reproduce:
Requires macOS with Xcode 12.x installed. Tested with both Clang from Xcode
12.5.1 (Apple clang version 12.0.5 (clang-1205.0.22.11)) and from main
(bdf4c7b738ee3dfbcd468ec347beec58b6e43a5a).
# Precompile _Builtin_stddef_max_align_t
clang -cc1 -fsyntax-only -std=gnu11 \
-resource-dir $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/* \
-isysroot $(xcrun --show-sdk-path) \
-internal-isystem $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/*/include \
-internal-externc-isystem $(xcrun --show-sdk-path)/usr/include \
-fgnuc-version=4.2.1 -fmodules \
-emit-module \
-fmodule-name=_Builtin_stddef_max_align_t \
$(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/*/include/module.modulemap
\
-o _Builtin_stddef_max_align_t.pcm
# Precompile Darwin
clang -cc1 -fsyntax-only -std=gnu11 \
-resource-dir $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/* \
-isysroot $(xcrun --show-sdk-path) \
-internal-isystem $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/*/include \
-internal-externc-isystem $(xcrun --show-sdk-path)/usr/include \
-fgnuc-version=4.2.1 -fmodules \
-emit-module \
-fmodule-map-file=$(echo $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/*/include/module.modulemap)
\
-fmodule-file=_Builtin_stddef_max_align_t=_Builtin_stddef_max_align_t.pcm \
-fmodule-name=Darwin \
$(xcrun --show-sdk-path)/usr/include/module.modulemap \
-o Darwin.pcm
# Attempt to precompile the module whose header imports inttypes.h
echo "#include <inttypes.h>" > test.h
echo -e "module test {\n use Darwin\n header \"test.h\"\n export *\n}" >
test.modulemap
clang -cc1 -fsyntax-only -std=gnu11 \
-resource-dir $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/* \
-isysroot $(xcrun --show-sdk-path) \
-internal-isystem $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/*/include \
-internal-externc-isystem $(xcrun --show-sdk-path)/usr/include \
-fgnuc-version=4.2.1 -fmodules \
-emit-module \
-fmodules-strict-decluse \
-fmodule-map-file=$(echo $(xcode-select
-p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/*/include/module.modulemap)
\
-fmodule-file=_Builtin_stddef_max_align_t=_Builtin_stddef_max_align_t.pcm \
-fmodule-map-file=$(xcrun --show-sdk-path)/usr/include/module.modulemap \
-fmodule-file=Darwin=Darwin.pcm \
-fmodule-name=test \
test.modulemap -o test.pcm</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>