[llvm-bugs] [Bug 35934] New: Clang Modules Broken on Mac OS Trunk (and has been for some time?)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 12 11:28:52 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=35934

            Bug ID: 35934
           Summary: Clang Modules Broken on Mac OS Trunk (and has been for
                    some time?)
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: asher at strong.ai
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

I’ve been working in C++ using clang modules (not TS modules) for a bit, now,
using a toolchain built from 5.0.0. 

I haven’t been particularly diligent about keeping my toolchain up to date;
when I fresh installed my OS a month or two ago, I proceeded to do a fresh
compilation from trunk (6.0.0). I’ve now attempted again with 7.0.0 and am
having similar results. 

Pre-requisite Configuration:

* Since this bug still has not been fixed
https://bugs.llvm.org/show_bug.cgi?id=33801, any include/mach/host_priv.h that
is included has to have “module” members renamed to something else. That
requires rebooting into rescue mode, csrutil disable, reboot, change, reboot,
csrutil enable, reboot. 

LLVM / clang configuration:

* set up llvm build config with cmake -G Ninja -DLLVM_CREATE_XCODE_TOOLCHAIN=On
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} $LLVMROOT
* built and installed to /usr/local/Toolchains
* test vs a .cc file that includes only “import std” or “#include <string>” (or
any other stdlib) while -fmodules -fcxx-modules -fmodules-ts, for ex ./clang -x
c++ -fmodules -fcxx-modules -o ~/test ~/test.cc

My understanding is that -fmodules-ts is required in order to have “import”
syntax available for C++. if I leave -fmodules-ts out and use #include <…>
instead of import, clang simply prints out -v info and then hangs indefinitely.
Including or leaving out -fcxx-modules does not seem to make any difference. 

Output when compiling import std:

clang version 7.0.0 (trunk 322158)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin/.
 "/usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin/clang-7.0" -cc1
-triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-main-file-name test.cc -mrelocation-model pic -pic-level 2 -mthread-model
posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn
-dwarf-column-info -debugger-tuning=lldb -target-linker-version 302.3.1 -v
-coverage-notes-file /Users/asher/test.gcno -resource-dir
/usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/lib/clang/7.0.0
-stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir
/usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin -ferror-limit 19
-fmessage-length 146 -stack-protector 1 -fblocks
-fencode-extended-block-signature -fmodules -fmodules-ts -fimplicit-module-maps
-fmodules-cache-path=/var/folders/jt/vwmmgt5x4lv1h220h2l86f900000gn/C/org.llvm.clang.asher/ModuleCache
-fobjc-runtime=macosx-10.13.0 -fcxx-exceptions -fexceptions -fmax-type-align=16
-fdiagnostics-show-option -fcolor-diagnostics -o /Users/asher/test -x c++
/Users/asher/test.cc
clang -cc1 version 7.0.0 based upon LLVM 7.0.0svn default target
x86_64-apple-darwin17.3.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/include/c++/v1
 /usr/include/c++/v1
 /usr/local/include
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/lib/clang/7.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
clang -cc1 version 7.0.0 based upon LLVM 7.0.0svn default target
x86_64-apple-darwin17.3.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/include/c++/v1
 /usr/include/c++/v1
 /usr/local/include
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/lib/clang/7.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
clang -cc1 version 7.0.0 based upon LLVM 7.0.0svn default target
x86_64-apple-darwin17.3.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/include/c++/v1
 /usr/include/c++/v1
 /usr/local/include
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/lib/clang/7.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
Assertion failed: ((ID || !Mod) && "asked for module ID for non-local,
non-imported module"), function getSubmoduleID, file
/Users/asher/Projects/Source/llvm/tools/clang/lib/Serialization/ASTWriter.cpp,
line 2754.
0  clang-7.0                0x00000001038c8cdc
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  clang-7.0                0x00000001038c92d9
PrintStackTraceSignalHandler(void*) + 25
2  clang-7.0                0x00000001038c4b99 llvm::sys::RunSignalHandlers() +
425
3  clang-7.0                0x00000001038c9692 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fff6ba58f5a _sigtramp + 26
5  libsystem_platform.dylib 0x000000011422c488 _sigtramp + 2826777928
6  libsystem_c.dylib        0x00007fff6b883312 abort + 127
7  libsystem_c.dylib        0x00007fff6b84b368 basename_r + 0
8  clang-7.0                0x0000000106079887
clang::ASTWriter::getSubmoduleID(clang::Module*) + 119
9  clang-7.0                0x00000001060e4f81
clang::ASTDeclWriter::VisitDecl(clang::Decl*) + 625
10 clang-7.0                0x00000001060ebcef
clang::ASTDeclWriter::VisitLinkageSpecDecl(clang::LinkageSpecDecl*) + 47
11 clang-7.0                0x00000001060e42e4
clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::ASTDeclWriter,
void>::Visit(clang::Decl*) + 356
12 clang-7.0                0x00000001060e40a7
clang::ASTDeclWriter::Visit(clang::Decl*) + 39
13 clang-7.0                0x00000001060f837f
clang::ASTWriter::WriteDecl(clang::ASTContext&, clang::Decl*) + 447
14 clang-7.0                0x000000010609dab0
clang::ASTWriter::WriteASTCore(clang::Sema&, llvm::StringRef,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > const&, clang::Module*) + 12064
15 clang-7.0                0x000000010609a549
clang::ASTWriter::WriteAST(clang::Sema&, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
clang::Module*, llvm::StringRef, bool) + 377
16 clang-7.0                0x0000000106116157
clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&) + 1799
17 clang-7.0                0x00000001048b97e7
clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 455
18 clang-7.0                0x0000000105db0516 clang::ParseAST(clang::Sema&,
bool, bool) + 1238
19 clang-7.0                0x0000000104865255
clang::ASTFrontendAction::ExecuteAction() + 485
20 clang-7.0                0x00000001048641b0 clang::FrontendAction::Execute()
+ 112
21 clang-7.0                0x000000010477516d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 2285
22 clang-7.0                0x00000001047a6753
compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation,
llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef,
llvm::function_ref<void (clang::CompilerInstance&)>, llvm::function_ref<void
(clang::CompilerInstance&)>)::$_3::operator()() const + 51
23 clang-7.0                0x00000001047a6715 void llvm::function_ref<void
()>::callback_fn<compileModuleImpl(clang::CompilerInstance&,
clang::SourceLocation, llvm::StringRef, clang::FrontendInputFile,
llvm::StringRef, llvm::StringRef, llvm::function_ref<void
(clang::CompilerInstance&)>, llvm::function_ref<void
(clang::CompilerInstance&)>)::$_3>(long) + 21
24 clang-7.0                0x00000001037849e9 llvm::function_ref<void
()>::operator()() const + 25
25 clang-7.0                0x000000010378498d
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 221
26 clang-7.0                0x0000000103784c3f
RunSafelyOnThread_Dispatch(void*) + 79
27 clang-7.0                0x00000001038d0640 ExecuteOnThread_Dispatch(void*)
+ 48
28 libsystem_pthread.dylib  0x00007fff6ba626c1 _pthread_body + 340
29 libsystem_pthread.dylib  0x00007fff6ba6256d _pthread_body + 0
30 libsystem_pthread.dylib  0x00007fff6ba61c5d thread_start + 13
Stack dump:
0.      <eof> parser at end of file
clang-7.0: error: unable to execute command: Abort trap: 6
clang-7.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 322158)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin/.
clang-7.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-7.0: error: unable to execute command: Abort trap: 6
clang-7.0: note: diagnostic msg: Error generating preprocessed source(s).

Using #include <string>:

clang version 7.0.0 (trunk 322158)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin/.
 "/usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin/clang-7.0" -cc1
-triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-main-file-name test.cc -mrelocation-model pic -pic-level 2 -mthread-model
posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn
-dwarf-column-info -debugger-tuning=lldb -target-linker-version 302.3.1 -v
-coverage-notes-file /Users/asher/test.gcno -resource-dir
/usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/lib/clang/7.0.0
-stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir
/usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/bin -ferror-limit 19
-fmessage-length 146 -stack-protector 1 -fblocks
-fencode-extended-block-signature -fmodules -fmodules-ts -fimplicit-module-maps
-fmodules-cache-path=/var/folders/jt/vwmmgt5x4lv1h220h2l86f900000gn/C/org.llvm.clang.asher/ModuleCache
-fobjc-runtime=macosx-10.13.0 -fcxx-exceptions -fexceptions -fmax-type-align=16
-fdiagnostics-show-option -fcolor-diagnostics -o /Users/asher/test -x c++
/Users/asher/test.cc
clang -cc1 version 7.0.0 based upon LLVM 7.0.0svn default target
x86_64-apple-darwin17.3.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/include/c++/v1
 /usr/include/c++/v1
 /usr/local/include
 /usr/local/Toolchains/LLVM7.0.0svn.xctoolchain/usr/lib/clang/7.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
/Users/asher/test.cc:1:10: fatal error: module 'std.string' not found
#include <string>
 ~~~~~~~~^
1 error generated.

No difference results when explicitly specifying either -fbuiltin-module-map or
-fmodule-map-file=[file with std].

Could anyone provide insight?

Thanks!
Asher

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180112/b8df11e4/attachment.html>


More information about the llvm-bugs mailing list