Issue |
151128
|
Summary |
Incorrect compiler flags are passed to GCC when cross compiling BOLT from x86_64 to aarch64
|
Labels |
BOLT
|
Assignees |
|
Reporter |
hmih
|
I am using nix to setup a development shell to cross compile BOLT from my host (x86_64) to aarch64. Here's the script, it should be fully reproducible:
```nix
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/7344a3b78128f7b1765dba89060b015fb75431a7.tar.gz";
pkgs = import nixpkgs {
crossSystem = {
config = "aarch64-unknown-linux-musl";
};
};
in
pkgs.pkgsStatic.callPackage (
{
mkShellNoCC,
bolt_20,
llvm_18,
clang_20,
cmake,
ninja,
gcc,
python3,
}:
mkShellNoCC {
nativeBuildInputs = [
llvm_18
clang_20
cmake
ninja
gcc
python3
];
buildInputs = [ bolt_20 ];
}
) { }
````
I followed the BOLT instructions here: https://github.com/llvm/llvm-project/blob/main/bolt/README.md#manual-build and set up the directory structure in the same way.
Using the downloaded clang cross compiler I got the following error:
```
[nix-shell:~/archive/llvm/build]$ cmake -G Ninja ../llvm-project/llvm -DLLVM_TARGETS_TO_BUILD="AArch64" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="bolt"
-- The C compiler identification is Clang 20.1.0
-- The CXX compiler identification is Clang 20.1.0
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang
-- Check for working C compiler: /nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang - broken
CMake Error at /nix/store/j3f4j0i2h5d7h3sbfnlgva8nk0cydvwq-cmake-3.31.5/share/cmake-3.31/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"/nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/home/hmihaylov/archive/llvm/build/CMakeFiles/CMakeScratch/TryCompile-nYvCXy'
Run Build Command(s): /nix/store/b8hida4z1qy9aw1fy3vdr251rzf125i0-ninja-1.12.1/bin/ninja -v cmTC_7a38b
[1/2] /nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang -MD -MT CMakeFiles/cmTC_7a38b.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_7a38b.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_7a38b.dir/testCCompiler.c.o -c /home/hmihaylov/archive/llvm/build/CMakeFiles/CMakeScratch/TryCompile-nYvCXy/testCCompiler.c
[2/2] : && /nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang CMakeFiles/cmTC_7a38b.dir/testCCompiler.c.o -o cmTC_7a38b && :
FAILED: cmTC_7a38b
: && /nix/store/w23f223jida54jb0rzlrkp4fxxdlqy44-aarch64-unknown-linux-musl-clang-wrapper-20.1.0-rc3/bin/aarch64-unknown-linux-musl-clang CMakeFiles/cmTC_7a38b.dir/testCCompiler.c.o -o cmTC_7a38b && :
/nix/store/4j95r1yl58phbadm5gpqczkw4bnv81rz-aarch64-unknown-linux-musl-binutils-2.43.1/bin/aarch64-unknown-linux-musl-ld: cannot find -lgcc_eh: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
```
So I added the `gcc` compiler to my nix shell and tried again. Configuration worked but during compilation `cmake --build .` I got:
```
[nix-shell:~/archive/llvm/build]$ cmake --build .
[5/2466] Performing build step for 'bolt_rt'
FAILED: tools/bolt/bolt_rt-stamps/bolt_rt-build /home/hmihaylov/archive/llvm/build/tools/bolt/bolt_rt-stamps/bolt_rt-build
cd /home/hmihaylov/archive/llvm/build/tools/bolt/bolt_rt-bins && /nix/store/j3f4j0i2h5d7h3sbfnlgva8nk0cydvwq-cmake-3.31.5/bin/cmake --build .
[1/4] Building CXX object CMakeFiles/bolt_rt_instr.dir/instr.cpp.o
FAILED: CMakeFiles/bolt_rt_instr.dir/instr.cpp.o
/nix/store/scz9j42f861bf0yvqp9isg95g9ig3s0l-aarch64-unknown-linux-musl-gcc-wrapper-14-20241116/bin/aarch64-unknown-linux-musl-g++ -I/home/hmihaylov/archive/llvm/build/tools/bolt/bolt_rt-bins -O3 -DNDEBUG -std=c++17 -ffreestanding -fno-exceptions -fno-rtti -fno-stack-protector -fPIC -fomit-frame-pointer -mno-sse -mgeneral-regs-only -MD -MT CMakeFiles/bolt_rt_instr.dir/instr.cpp.o -MF CMakeFiles/bolt_rt_instr.dir/instr.cpp.o.d -o CMakeFiles/bolt_rt_instr.dir/instr.cpp.o -c /home/hmihaylov/archive/llvm/llvm-project/bolt/runtime/instr.cpp
aarch64-unknown-linux-musl-g++: error: unrecognized command-line option '-mno-sse'; did you mean '-fno-dse'?
[2/4] Building CXX object CMakeFiles/bolt_rt_hugify.dir/hugify.cpp.o
FAILED: CMakeFiles/bolt_rt_hugify.dir/hugify.cpp.o
/nix/store/scz9j42f861bf0yvqp9isg95g9ig3s0l-aarch64-unknown-linux-musl-gcc-wrapper-14-20241116/bin/aarch64-unknown-linux-musl-g++ -I/home/hmihaylov/archive/llvm/build/tools/bolt/bolt_rt-bins -O3 -DNDEBUG -std=c++17 -ffreestanding -fno-exceptions -fno-rtti -fno-stack-protector -fPIC -fomit-frame-pointer -mno-sse -mgeneral-regs-only -MD -MT CMakeFiles/bolt_rt_hugify.dir/hugify.cpp.o -MF CMakeFiles/bolt_rt_hugify.dir/hugify.cpp.o.d -o CMakeFiles/bolt_rt_hugify.dir/hugify.cpp.o -c /home/hmihaylov/archive/llvm/llvm-project/bolt/runtime/hugify.cpp
aarch64-unknown-linux-musl-g++: error: unrecognized command-line option '-mno-sse'; did you mean '-fno-dse'?
ninja: build stopped: subcommand failed.
[26/2466] Building CXX object utils/FileCheck/CMakeFiles/FileCheck.dir/FileCheck.cpp.o
ninja: build stopped: subcommand failed.
```
I can edit the `build.ninja` to remove those flags from the compiler command line, but they shouldn't be there in the first place.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs