Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error when compiling wasi-libc with -mbulk-memory #52618

Closed
TerrorJack opened this issue Dec 11, 2021 · 5 comments
Closed

Fatal error when compiling wasi-libc with -mbulk-memory #52618

TerrorJack opened this issue Dec 11, 2021 · 5 comments
Assignees

Comments

@TerrorJack
Copy link

Using clang-13 to compile https://github.com/WebAssembly/wasi-libc to wasm32-wasi with -mbulk-memory results in a fatal error. The command line and stack trace is attached below.

fatal error: error in backend: only -ftls-model=local-exec is supported for now on non-Emscripten OSes: variable errno
PLEASE submit a bug report to bugs.llvm.org and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang -mbulk-memory -O2 -DNDEBUG --target=wasm32-wasi -fno-trapping-math -Wall -Wextra -Werror -Wno-null-pointer-arithmetic -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wno-ignored-attributes -Wno-missing-braces -Wno-ignored-pragmas -Wno-unused-but-set-variable -Wno-unknown-warning-option -mthread-model single --sysroot=/home/runner/work/wasi-libc/wasi-libc/sysroot -I/home/runner/work/wasi-libc/wasi-libc/dlmalloc/include -MD -MP -o /home/runner/work/wasi-libc/wasi-libc/build/dlmalloc/src/dlmalloc.o -c /home/runner/work/wasi-libc/wasi-libc/dlmalloc/src/dlmalloc.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/home/runner/work/wasi-libc/wasi-libc/dlmalloc/src/dlmalloc.c'.
4.	Running pass 'WebAssembly Instruction Selection' on function '@dlmalloc'
 #0 0x0000000004a9ea73 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a9ea73)
 #1 0x0000000004a9ca5e llvm::sys::RunSignalHandlers() (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a9ca5e)
 #2 0x0000000004a9df2d llvm::sys::CleanupOnSignal(unsigned long) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a9df2d)
 #3 0x0000000004a1873a (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #4 0x0000000004a186db (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a186db)
 #5 0x0000000004a99107 llvm::sys::Process::Exit(int, bool) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a99107)
 #6 0x0000000002ddd8c0 llvm::AliasSetTracker::~AliasSetTracker() cc1_main.cpp:0:0
 #7 0x0000000004a1c522 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a1c522)
 #8 0x00000000039b290e (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x39b290e)
 #9 0x00000000039b218c llvm::WebAssemblyTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const WebAssemblyISelLowering.cpp:0:0
#10 0x0000000005730a0f (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
#11 0x00000000057300e5 llvm::SelectionDAG::Legalize() (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x57300e5)
#12 0x00000000057d9135 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x57d9135)
#13 0x00000000057d850d llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x57d850d)
#14 0x00000000057d6279 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x57d6279)
#15 0x0000000003fb785e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x3fb785e)
#16 0x0000000004372e6d llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4372e6d)
#17 0x0000000004379cc3 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4379cc3)
#18 0x00000000043735b4 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x43735b4)
#19 0x00000000050903f7 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#20 0x000000000508a497 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x508a497)
#21 0x000000000539640e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#22 0x000000000641bd44 clang::ParseAST(clang::Sema&, bool, bool) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x641bd44)
#23 0x00000000052e8479 clang::FrontendAction::Execute() (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x52e8479)
#24 0x000000000525b0b6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x525b0b6)
#25 0x000000000539151c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x539151c)
#26 0x0000000002ddd5bf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x2ddd5bf)
#27 0x0000000002ddb5d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#28 0x0000000005104a62 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1>(long) Job.cpp:0:0
#29 0x0000000004a186bd llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x4a186bd)
#30 0x00000000051045ba clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x51045ba)
#31 0x00000000050d306d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x50d306d)
#32 0x00000000050d32b7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x50d32b7)
#33 0x00000000050e9c61 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x50e9c61)
#34 0x0000000002ddac90 main (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x2ddac90)
#35 0x00007f6069e520b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#36 0x0000000002dd837e _start (/home/runner/work/wasi-libc/wasi-libc/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang+0x2dd837e)
make: *** [Makefile:389: /home/runner/work/wasi-libc/wasi-libc/build/dlmalloc/src/dlmalloc.o] Error 1
@Martin-Vinci
Copy link

Martin-Vinci commented Dec 11, 2021 via email

@sbc100 sbc100 assigned sbc100 and unassigned sbc100 Dec 11, 2021
@TerrorJack
Copy link
Author

Update: I confirm this issue is gone in llvm-15, but still present in llvm-14.

@TerrorJack
Copy link
Author

Minimal repro for llvm-14:

_Thread_local a;
b() { a = 0; }

@sbc100
Copy link
Collaborator

sbc100 commented May 30, 2022

I suggest we mark this a closed then .. unless you think this issue is important enough to warrant a backport? (My feeling is that it probably is not).

@TerrorJack
Copy link
Author

Nope, we can wait for wasi-sdk to bump to llvm-15 when the new major release is out, feel free to close :)

@sbc100 sbc100 closed this as completed May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants