[BOLT][AArch64] `UNREACHABLE executed at llvm/include/llvm/Support/Error.h:810` when running `llvm-bolt`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
I needed to bolt clang with the assertions enabled. I've modified the `clang/cmake/caches/BOLT.cmake` file (included by `clang/cmake/caches/BOLT-PGO.cmake` which I used for the CMake step) by adding the following line:
```
set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
```
Unfortunately, as the `ninja stage2-clang-bolt` progressed, at some point it failed as such:
```
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: aarch64
BOLT-INFO: BOLT version:
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x7a00000, offset 0x7a00000
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
Failure value returned from cantFail wrapped call
can't read an entry at 0xa2edf0: it goes past the end of the section (0xa2edf0)
UNREACHABLE executed at atfl/llvm/include/llvm/Support/Error.h:810!
#0 0x0000aaaacb15850c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1e1850c)
#1 0x0000aaaacb158e5c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x0000ffffbdd537dc (linux-vdso.so.1+0x7dc)
#3 0x0000ffffbd972008 __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x0000ffffbd92a83c gsignal ./signal/../sysdeps/posix/raise.c:27:6
#5 0x0000ffffbd917134 abort ./stdlib/abort.c:81:7
#6 0x0000aaaaca3d7cec llvm::ConstantRange::ConstantRange(unsigned int, bool) (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1097cec)
#7 0x0000aaaacafd2724 llvm::Expected::operator*() AArch64AsmBackend.cpp:0:0
#8 0x0000aaaacb1eb738 llvm::bolt::RewriteInstance::handleRelocation(llvm::object::SectionRef const&, llvm::object::RelocationRef const&) (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1eab738)
#9 0x0000aaaacb1e92d4 llvm::bolt::RewriteInstance::readRelocations(llvm::object::SectionRef const&) (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1ea92d4)
#10 0x0000aaaacb1e3aac llvm::bolt::RewriteInstance::processRelocations() (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1ea3aac)
#11 0x0000aaaacb1dc41c llvm::bolt::RewriteInstance::discoverFileObjects() (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1e9c41c)
#12 0x0000aaaacb1d5f40 llvm::bolt::RewriteInstance::run() (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1e95f40)
#13 0x0000aaaacae5f284 main (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1b1f284)
#14 0x0000ffffbd917400 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#15 0x0000ffffbd9174d8 call_init ./csu/../csu/libc-start.c:128:20
#16 0x0000ffffbd9174d8 __libc_start_main ./csu/../csu/libc-start.c:379:5
#17 0x0000aaaacae5d630 _start (atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt+0x1b1d630)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/clang-23 -o atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/./bin/clang-bolt.inst -instrument --instrumentation-file-append-pid --instrumentation-file=atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/tools/clang/tools/driver/../../utils/perf-training/prof.fdata
Traceback (most recent call last):
File "atfl/clang/tools/driver/../../utils/perf-training/perf-helper.py", line 763, in
main()
File "atfl/clang/tools/driver/../../utils/perf-training/perf-helper.py", line 759, in main
sys.exit(f(sys.argv[2:]))
File "atfl/clang/tools/driver/../../utils/perf-training/perf-helper.py", line 671, in bolt_optimize
process.check_returncode()
File "/usr/lib/python3.10/subprocess.py", line 457, in check_returncode
raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/llvm-bolt', 'atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/bin/clang-23', '-o', 'atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/./bin/clang-bolt.inst', '-instrument', '--instrumentation-file-append-pid', '--instrumentation-file=atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/tools/clang/tools/driver/../../utils/perf-training/prof.fdata']' died with .
ninja: build stopped: subcommand failed.
FAILED: tools/clang/stage2-stamps/stage2-clang-bolt atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-stamps/stage2-clang-bolt
cd atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang && /usr/bin/cmake --build atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/tools/clang/stage2-bins/ --target clang-bolt
ninja: build stopped: subcommand failed.
FAILED: tools/clang/stage2-instrumented-stamps/stage2-instrumented-stage2-clang-bolt atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-stamps/stage2-instrumented-stage2-clang-bolt
cd atfl/arm-software/linux/build/stage/product_bolted/tools/clang && /usr/bin/cmake --build atfl/arm-software/linux/build/stage/product_bolted/tools/clang/stage2-instrumented-bins/ --target stage2-clang-bolt
ninja: build stopped: subcommand failed.
```
Is there any rationale for not bolting clang with assertions enabled?
Contributor guide
Research direction
Reproduce the failure with clang/cmake/caches/BOLT.cmake and the ninja stage2-clang-bolt target. Start at llvm/include/llvm/Support/Error.h:810 and follow RewriteInstance::processRelocations, readRelocations, and handleRelocation from the stack trace. Done means identifying why relocation reading passes the section end for assertions-enabled clang and establishing the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100