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

bootstrapping: Segmentation fault in clang while bootstrapping LLVM 18 #91899

Open
Mishura4 opened this issue May 12, 2024 · 3 comments
Open
Labels
clang Clang issues not falling into any other category crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@Mishura4
Copy link

Mishura4 commented May 12, 2024

Commit: 617a15a (grafted, HEAD, tag: llvmorg-18.1.5)
OS: Ubuntu 24.04

Error:

[ 56%] Building LLVM bitcode Workshare.cpp-sm_90.bc
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/miuna/dev/llvmorg-18.1.5/build/bin/clang-18 -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Workshare.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/miuna/dev/llvmorg-18.1.5/build/projects/openmp/libomptarget/DeviceRTL -fcoverage-compilation-dir=/home/miuna/dev/llvmorg-18.1.5/build/projects/openmp/libomptarget/DeviceRTL -nostdsysteminc -nobuiltininc -resource-dir /home/miuna/dev/llvmorg-18.1.5/build/lib/clang/18 -dependency-file Workshare.cpp-sm_90.bc.d -MT Workshare.cpp-sm_90.bc -sys-header-deps -D SHARED_SCRATCHPAD_SIZE=512 -D OMPTARGET_DEVICE_RUNTIME -I /home/miuna/dev/llvmorg-18.1.5/openmp/libomptarget/DeviceRTL/include -I /home/miuna/dev/llvmorg-18.1.5/openmp/libomptarget/DeviceRTL/../include -I /home/miuna/dev/llvmorg-18.1.5/llvm/include -I /home/miuna/dev/llvmorg-18.1.5/build/include -O3 -Wno-unknown-cuda-version -std=c++17 -fdeprecated-macro -ferror-limit 19 -fvisibility=hidden -fopenmp -fopenmp-cuda-mode -nogpulib -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -openmp-opt-disable -mllvm -vectorize-slp=false -disable-llvm-passes -fopenmp-targets=nvptx64-nvidia-cuda -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/Workshare-sm_90-4bb41b.bc -x c++ /home/miuna/dev/llvmorg-18.1.5/openmp/libomptarget/DeviceRTL/src/Workshare.cpp
 #0 0x00005a60cc4210f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x2f3f0f8)
 #1 0x00005a60cc41e74e llvm::sys::RunSignalHandlers() (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x2f3c74e)
 #2 0x00005a60cc421bd8 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f9579a45320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
 #4 0x00005a60cd10b6ae ParseTargetArgs(clang::TargetOptions&, llvm::opt::ArgList&, clang::DiagnosticsEngine&) CompilerInvocation.cpp:0:0
 #5 0x00005a60cd0f5403 clang::CompilerInvocation::CreateFromArgsImpl(clang::CompilerInvocation&, llvm::ArrayRef<char const*>, clang::DiagnosticsEngine&, char const*) (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x3c13403)
 #6 0x00005a60cb20feb1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x1d2deb1)
 #7 0x00005a60cb20de2c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
 #8 0x00005a60cb20c624 clang_main(int, char**, llvm::ToolContext const&) (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x1d2a624)
 #9 0x00005a60cb21f18a main (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x1d3d18a)
#10 0x00007f9579a2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#11 0x00007f9579a2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#12 0x00005a60cb1fe4a5 _start (/home/miuna/dev/llvmorg-18.1.5/build/bin/clang-18+0x1d1c4a5)
clang-18: error: unable to execute command: Segmentation fault (core dumped)
clang-18: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 18.1.5 (https://github.com/llvm/llvm-project.git 617a15a9eac96088ae5e9134248d8236e34b91b1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/miuna/dev/llvmorg-18.1.5/build/projects/openmp/libomptarget/DeviceRTL/../../../../bin
clang-18: error: unable to execute command: Segmentation fault (core dumped)
clang-18: note: diagnostic msg: Error generating preprocessed source(s).
gmake[2]: *** [projects/openmp/libomptarget/DeviceRTL/CMakeFiles/omptarget.devicertl.dir/build.make:4585: projects/openmp/libomptarget/DeviceRTL/Workshare.cpp-sm_90.bc] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:118238: projects/openmp/libomptarget/DeviceRTL/CMakeFiles/omptarget.devicertl.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2

No preprocessed sources because clang-18: note: diagnostic msg: Error generating preprocessed source(s).

Build script:

#!/bin/sh

export CXX=clang++-17
export CC=clang-17

cmake llvm/ -B build \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;libc;libclc;lld;lldb;openmp;polly" \
      -DLLVM_ENABLE_RUNTIMES='all' \
      -DLLVM_TARGETS_TO_BUILD=Native \
      -DCLANG_ENABLE_BOOTSTRAP=ON \
      -DLLVM_ENABLE_LTO='Thin' \
      -DLLVM_USE_LINKER='lld' \
      -DCMAKE_BUILD_TYPE=Release \
      -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
      -DCLANG_DEFAULT_RTLIB=compiler-rt \
      -DLIBCXX_USE_COMPILER_RT=YES \
      -DLIBCXXABI_USE_COMPILER_RT=YES \
      -DLIBCXXABI_USE_LLVM_UNWINDER=YES \
      -DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
      -DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ \
      -DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt \
      -DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=YES \
      -DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=YES \
      -DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=YES \
      -DBOOTSTRAP_LLVM_USE_LINKER=lld \
      -DBOOTSTRAP_LLVM_ENABLE_LTO='Thin' \
      -DLIBUNWIND_USE_COMPILER_RT=Yes \
      -DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=Yes

cmake --build build --config Release --parallel 4

(and yes i've tried without --parallel, same issue, though I haven't tried a full rebuild without it)

Bootstrapped with:

$ clang++-17 -v
Ubuntu clang version 17.0.6 (9ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/14
Candidate multilib: .;@m64
Selected multilib: .;@m64

Machine runs Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz with 32Gb RAM. clang-17 was installed using apt-get.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label May 12, 2024
@firewave firewave added the crash Prefer [crash-on-valid] or [crash-on-invalid] label May 12, 2024
@Mishura4
Copy link
Author

Mishura4 commented May 12, 2024

I noticed I was using lld 18 to link clang built with clang17. I'll try again without -DBOOTSTRAP_LLVM_USE_LINKER=lld and -DBOOTSTRAP_LLVM_ENABLE_LTO='Thin', which should use GNU ld 2.42, and update with results

@Mishura4
Copy link
Author

That did not fix it

@Mishura4
Copy link
Author

Mishura4 commented May 13, 2024

Tried this instead:

#!/bin/sh

export CXX=clang++-17
export CC=clang-17

cmake llvm/ -B build \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;polly" \
      -DLLVM_ENABLE_RUNTIMES='compiler-rt;libc;libcxx;libcxxabi;libunwind;openmp' \
      -DLLVM_TARGETS_TO_BUILD=Native \
      -DLLVM_ENABLE_LTO='Thin' \
      -DLLVM_ENABLE_LLD=On \
      -DLLVM_ENABLE_LIBCXX=On \
      -DLLVM_PARALLEL_COMPILE_JOBS=$(nproc) \
      -DLLVM_PARALLEL_LINK_JOBS=4 \
      -DCMAKE_BUILD_TYPE=Release \
      -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
      -DCLANG_DEFAULT_RTLIB=compiler-rt \
      -DCLANG_DEFAULT_LINKER=lld \
      -DLIBCXX_USE_COMPILER_RT=YES \
      -DLIBCXXABI_USE_COMPILER_RT=YES \
      -DLIBCXXABI_USE_LLVM_UNWINDER=YES \
      -DCLANG_ENABLE_BOOTSTRAP=ON \
      -DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
      -DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ \
      -DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt \
      -DBOOTSTRAP_CLANG_DEFAULT_LINKER=lld \
      -DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=YES \
      -DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=YES \
      -DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=YES \
      -DLIBUNWIND_USE_COMPILER_RT=Yes \
      -DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=Yes \
      -G Ninja

ninja -C build stage2

Got another crash also missing preprocessed sources: CMakeError.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

2 participants