Open arachsys opened 3 years ago
Following up to this: the problem seems to be that the musl builds are detecting their host triple as x86_64-unknown-linux-gnu instead of x86_64-unknown-linux-musl or x86_64-alpine-linux-musl. (See 'build/bin/clang -dumpmachine'.)
Adding an explicit
-DLLVM_HOST_TRIPLE=x86_64-alpine-linux-musl
is sufficient to get the ENABLE_RUNTIMES version to build.
@arachsys Are you still experiencing this issue on trunk?
Hi, I've just re-checked this. Constructing an up-to-date test build chroot from completely stock Alpine Linux:
https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.3-x86_64.tar.gz
apk add alpine-sdk cmake linux-headers python3
and compiling the HEAD of git main as of now, c336a061, the following recipe still fails:
cmake -W no-dev \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \
-DLLVM_INCLUDE_TESTS=No \
-DLLVM_TARGETS_TO_BUILD="Native" \
-DLIBCXX_HAS_MUSL_LIBC=Yes \
-DCOMPILER_RT_BUILD_LIBFUZZER=No \
-DCOMPILER_RT_BUILD_MEMPROF=No \
-DCOMPILER_RT_BUILD_SANITIZERS=No \
-DCOMPILER_RT_BUILD_XRAY=No \
../llvm && make -j16
whereas adding -DLLVM_HOST_TRIPLE=x86_64-alpine-linux-musl
gets it building fine.
Nowadays the failure is a little more obvious to diagnose, because there's an explicit cmake warning about not knowing the target architecture:
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG - Failed
-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG - Failed
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG - Failed
CMake Warning (dev) at /usr/share/cmake/Modules/GNUInstallDirs.cmake:243 (message):
Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
target architecture is known. Please enable at least one language before
including GNUInstallDirs.
Call Stack (most recent call first):
/llvm/llvm/cmake/modules/AddLLVM.cmake:1 (include)
CMakeLists.txt:155 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Linker detection: GNU ld
-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Failed
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test CXX_SUPPORTS_FPIC - Failed
CMake Warning at /llvm/llvm/cmake/modules/HandleLLVMOptions.cmake:285 (message):
-fPIC is not supported.
Call Stack (most recent call first):
/llvm/llvm/cmake/modules/HandleLLVMOptions.cmake:342 (add_flag_or_print_warning)
CMakeLists.txt:156 (include)
Ultimately it dies because
-- Performing Test CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG - Failed
-- Performing Test CXX_SUPPORTS_FNO_RTTI_FLAG
-- Performing Test CXX_SUPPORTS_FNO_RTTI_FLAG - Failed
CMake Error at /llvm/libunwind/src/CMakeLists.txt:90 (message):
Compiler doesn't support generation of unwind tables if exception support
is disabled. Building libunwind DSO with runtime dependency on C++ ABI
library is not supported.
but this is misleading: every CXX_SUPPORTS_*
compile test has failed due to the unknown architecture.
Exactly as in the original report two-and-a-half years ago,
/llvm/build # bin/clang -dumpmachine
x86_64-unknown-linux-gnu
whereas with explicitly provided -DLLVM_HOST_TRIPLE=x86_64-alpine-linux-musl
,
llvm/build # bin/clang -dumpmachine
x86_64-alpine-linux-musl
Thank you for details!
Yeah, I'm getting this as well when following https://libcxx.llvm.org/BuildingLibcxx.html#bootstrapping-build
But setting LLVM_HOST_TRIPLE
made no difference in the outcome.
EDIT0:
Ah, looking at runtimes/runtimes-<tuple>-bins/CMakeFiles/CMakeConfigureLog.yaml
, I saw one of the tests was looking at /usr/lib/Scrt1.o
, but for the wrong arch.
Currently rebuilding for the build-machine, and I expect it'll be fine.
Then I'll do it for the host-target and point to sysroot as well.
Extended Description
TL;DR: LLVM_ENABLE_RUNTIMES in both release/12.x and main appears to be broken on linux/musl but not on linux/glibc.
I stumbled over this whilst packaging llvm/clang/etc for a weird local linux distribution, but I reproduce and demonstrate below with mainstream Alpine Linux and Debian images.
In a linux/musl image, such as
running
completes successfully, and the resulting compiler and runtimes can be re-used to fully bootstrap. However, the same thing with ENABLE_RUNTIMES:
crashes when the runtimes build tries to configure:
During this configure step, every runtimes-bin test is down as 'Failed', even things like 'C_SUPPORTS_FPIC' or 'Looking for fopen in c'. Looking at runtimes/runtimes-bin/CMakeFiles/CMakeError.log shows link repeatedly failing like this:
This doesn't happen on a linux/glibc image, such as Debian unstable with
where
completes fine, as does a build with the runtimes in LLVM_ENABLE_PROJECTS. (Same cmake command except I've dropped -DLIBCXX_HAS_MUSL_LIBC.)