Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

lld/mac-linked clang crashes at runtime #51394

Open Quuxplusone opened 2 years ago

Quuxplusone commented 2 years ago
Bugzilla Link PR52427
Status NEW
Importance P enhancement
Reported by Nico Weber (nicolasweber@gmx.de)
Reported on 2021-11-05 15:04:43 -0700
Last modified on 2021-11-05 16:19:48 -0700
Version unspecified
Hardware PC All
CC gkm@fb.com, jezreel@gmail.com, llvm-bugs@lists.llvm.org, smeenai@fb.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

Repro file for linking clang: https://drive.google.com/file/d/1uoZnBDRWrG6HQUsPzXsG5yA6t-I0zAoL/view?usp=sharing

This is a clang that was built with -DLLVM_BUILD_INSTRUMENTED=IR.

Linking clang with the repro file with lld.ld64 and then running bin/clang++ -target x86_64-unknown-unknown -O2 -g -std=c++14 -fno-exceptions -fno-rtti -w -c pgo_training-1.ii pgo_training-1.ii makes clang crash after ~25s.

clang doesn't crash if it's linked with ld64 (it succeeds after ~31s).

You can obtain pgo_training-1.ii by running curl -L -O https://commondatastorage.googleapis.com/chromium-browser-clang/pgo_training-1.ii.

1: Full cmake invocation for producing the .o files:

 Running cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF '-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld;clang-tools-extra;libcxx' '-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Mips;PowerPC;SystemZ;WebAssembly;X86' -DLLVM_ENABLE_PIC=OFF -DLLVM_ENABLE_UNWIND_TABLES=OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF -DCLANG_PLUGIN_SUPPORT=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DCLANG_ENABLE_ARCMT=OFF '-DBUG_REPORT_URL=https://crbug.com and run tools/clang/scripts/process_crashreports.py (only works inside Google) which will upload a report' -DLLVM_INCLUDE_GO_TESTS=OFF -DENABLE_X86_RELAX_RELOCATIONS=NO -DLLVM_ENABLE_DIA_SDK=OFF '-DCOMPILER_RT_SANITIZERS_TO_BUILD=asan;dfsan;msan;hwasan;tsan;cfi' -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF -DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC=OFF -DLIBCXX_INCLUDE_TESTS=OFF -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLLVM_ENABLE_LIBXML2=FORCE_ON -DLLVM_ENABLE_LLD=ON '-DLLVM_ENABLE_PROJECTS=clang;libcxx;compiler-rt' -DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS= -DCMAKE_EXE_LINKER_FLAGS= -DCMAKE_SHARED_LINKER_FLAGS= -DCMAKE_MODULE_LINKER_FLAGS= -DLLVM_BUILD_INSTRUMENTED=IR -DCMAKE_C_COMPILER=/Users/thakis/src/chrome/src/third_party/llvm-bootstrap-install/bin/clang -DCMAKE_CXX_COMPILER=/Users/thakis/src/chrome/src/third_party/llvm-bootstrap-install/bin/clang++ /Users/thakis/src/chrome/src/third_party/llvm/llvm

This is with a "normally" built clang as stage0 compiler, but it might repro when just using system clang as host compiler.

Quuxplusone commented 2 years ago

https://bugs.chromium.org/p/chromium/issues/detail?id=1267227 comment 0 has full stack. (It's pretty long.)

Still happens without -dead_strip.

Quuxplusone commented 2 years ago
Now that I'm actually trying this with the repro file, you need to do the
following to get it to actually repro:

mkdir bin
mv clang-14 bin # Update response.txt to write to here directly
mkdir -p lib/clang/14.0.0
ln -s ~/src/llvm-project/clang/lib/Headers lib/clang/14.0.0/include

And then to get the crash:

bin/clang-14 -target x86_64-unknown-unknown -O2 -g -std=c++14 -fno-exceptions -
fno-rtti -w -c pgo_training-1.ii pgo_training-1.ii

(See comment 0 for where to get the .ii file.)
Quuxplusone commented 2 years ago

https://reviews.llvm.org/rG317e00dc54c74a2e0fd0c62bdc6a6d68b0d2ca7e is somewhat related.