Stream: general

Topic: Error: Compile Large Project using Clang into WebAssembly


view this post on Zulip Dennis Zhang (May 15 2024 at 14:30):

Dear Community,

We are trying to compile GLIBC into WebAssembly using Clang, but we encountered the error "error: clang frontend command failed with exit code 139". We have tried Clang versions 12, 14, 16, and 18, but all of them face the same error. Has anyone experienced similar issues with other large projects? Thanks for any help!

Best regards,
Dennis

view this post on Zulip Chris Fallin (May 15 2024 at 14:43):

Is there any more error output from the build process before that exit?

view this post on Zulip Dennis Zhang (May 15 2024 at 14:47):

Hi Chris, this is the first error we encountered, and after that just exit. Here is the stack trace:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang --target=wasm32-unkown-wasi check_fds.c -c -std=gnu11 -fgnu89-inline -O2 -g -Wall -Wwrite-strings -Wundef -fmerge-all-constants -ftrapping-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -fPIE -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0 -ftls-model=initial-exec -I../include -I/home/dennis/Documents/Just-One-Turtle/glibc/build/csu -I/home/dennis/Documents/Just-One-Turtle/glibc/build -I../sysdeps/lind -I../sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/x86/nptl -I../sysdeps/i386/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/fpu -I../sysdeps/x86/fpu -I../sysdeps/i386 -I../sysdeps/x86/include -I../sysdeps/x86 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/lib/clang/16/include -isystem /usr/i686-linux-gnu/include -D_LIBC_REENTRANT -include /home/dennis/Documents/Just-One-Turtle/glibc/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /home/dennis/Documents/Just-One-Turtle/glibc/build/csu/check_fds.o -MD -MP -MF /home/dennis/Documents/Just-One-Turtle/glibc/build/csu/check_fds.o.dt -MT /home/dennis/Documents/Just-One-Turtle/glibc/build/csu/check_fds.o
1.  <eof> parser at end of file
2.  Code generation
 #0 0x000055fbe342e4f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x30f24f8)
 #1 0x000055fbe342c46e llvm::sys::RunSignalHandlers() (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x30f046e)
 #2 0x000055fbe33b1239 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007deebe442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000055fbe3186ce2 (anonymous namespace)::WasmObjectWriter::writeOneObject(llvm::MCAssembler&, llvm::MCAsmLayout const&, (anonymous namespace)::WasmObjectWriter::DwoMode) WasmObjectWriter.cpp:0:0
 #5 0x000055fbe3182995 (anonymous namespace)::WasmObjectWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) WasmObjectWriter.cpp:0:0
 #6 0x000055fbe312a5e8 llvm::MCAssembler::Finish() (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x2dee5e8)
 #7 0x000055fbe4024583 llvm::AsmPrinter::doFinalization(llvm::Module&) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x3ce8583)
 #8 0x000055fbe2e7d2b1 llvm::FPPassManager::doFinalization(llvm::Module&) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x2b412b1)
 #9 0x000055fbe2e776a2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x2b3b6a2)
#10 0x000055fbe36dc8ad 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/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x33a08ad)
#11 0x000055fbe42ee665 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x3fb2665)
#12 0x000055fbe50fb34d clang::ParseAST(clang::Sema&, bool, bool) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x4dbf34d)
#13 0x000055fbe3d5e7c7 clang::FrontendAction::Execute() (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x3a227c7)
#14 0x000055fbe3cd2664 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x3996664)
#15 0x000055fbe3e13d8f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x3ad7d8f)
#16 0x000055fbe162dc05 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x12f1c05)
#17 0x000055fbe162ac96 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#18 0x000055fbe3b571b2 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#19 0x000055fbe33b101c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x307501c)
#20 0x000055fbe3b56aeb clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x381aaeb)
#21 0x000055fbe3b1c26d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x37e026d)
#22 0x000055fbe3b1c49e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x37e049e)
#23 0x000055fbe3b38b40 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x37fcb40)
#24 0x000055fbe162a10d clang_main(int, char**) (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x12ee10d)
#25 0x00007deebe429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#26 0x00007deebe429e40 call_init ./csu/../csu/libc-start.c:128:20
#27 0x00007deebe429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#28 0x000055fbe1626f55 _start (/home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang+0x12eaf55)
clang-16: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 16.0.4 (https://github.com/llvm/llvm-project ae42196bc493ffe877a7e3dff8be32035dea4d07)
Target: wasm32-unkown-wasi
Thread model: posix
InstalledDir: /home/dennis/Documents/Just-One-Turtle/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin
clang-16: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16: note: diagnostic msg: /tmp/check_fds-73cbed.c
clang-16: note: diagnostic msg: /tmp/check_fds-73cbed.sh
clang-16: note: diagnostic msg:

view this post on Zulip Chris Fallin (May 15 2024 at 14:49):

OK, that's actually a clang crash; you'll need to report the bug to upstream clang, with the files that the message notes ("please attach ...")


Last updated: Nov 22 2024 at 16:03 UTC