musl host support: bootstrap and run on Alpine (x86_64-alpine-linux-musl)
The Linux host code paths were gated on the x86_64_pc_linux_gnu target define alone, and LoadProject hardcoded --target=x86_64-pc-linux-gnu when compiling project.cpp and the module PCMs. Both break on musl hosts: the glibc release launcher cannot run there at all (no glibc loader; gcompat lacks libgcc_s and the __isoc23_* symbols), and a musl-built launcher would still compile project.cpp for the wrong libc. - The host gates test clang's __linux__ instead of one triple's define: they mean "Linux host", whatever the libc (or, later, the CPU). - LoadProject derives the host triple from HostTarget() (clang's -print-target-triple), which is also more correct on glibc distros whose triple isn't x86_64-pc-linux-gnu. - project.cpp / the cmake libc++ flags treat any *-linux-gnu or *-linux-musl target as Linux. - build.sh targets the host toolchain's triple (CRAFTER_BUILD_TARGET overrides) and derives the per-target define from it. On Arch this is byte-for-byte the previous behaviour. - CI: a release-musl job bootstraps on alpine:edge, runs the tests, and attaches crafter-build-linux-x86_64-musl-v2.tar.gz to the rolling latest release (via the API, so the glibc assets survive). Dynamic against musl libc++: the launcher dlopens project.so, so it cannot be fully static. First consumer: imsd's package CI, which cross-compiles for aarch64 from an Alpine container. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
802caac1c2
commit
dc239f4257
7 changed files with 131 additions and 22 deletions
19
build.sh
19
build.sh
|
|
@ -44,10 +44,23 @@ cd ../../
|
|||
|
||||
MARCH="${CRAFTER_BUILD_MARCH:-native}"
|
||||
MTUNE="${CRAFTER_BUILD_MTUNE:-native}"
|
||||
# The bootstrap targets the host toolchain's own triple: x86_64-pc-linux-gnu
|
||||
# on glibc distros, x86_64-alpine-linux-musl on Alpine. Override with
|
||||
# CRAFTER_BUILD_TARGET. The per-target define (triple with '-' -> '_') is the
|
||||
# same one the self-hosted build emits, so the host-gated code paths match.
|
||||
TARGET="${CRAFTER_BUILD_TARGET:-$(clang++ -print-target-triple)}"
|
||||
TARGET_DEFINE="CRAFTER_BUILD_CONFIGURATION_TARGET_$(printf '%s' "$TARGET" | tr - _)"
|
||||
|
||||
common_options="--target=x86_64-pc-linux-gnu -stdlib=libc++ -I./build/glslang -std=c++26 -O3 -march=$MARCH -mtune=$MTUNE -fprebuilt-module-path=./build -D CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu -D CRAFTER_BUILD_CONFIGURATION_TYPE_EXECUTABLE -c"
|
||||
# Crafter.Build-Lint includes libclang's clang-c/Index.h. glibc distros keep
|
||||
# it in /usr/include; Alpine keeps LLVM under /usr/lib/llvmNN, so ask
|
||||
# llvm-config and add the dir when it is not already on the default path
|
||||
# (never add /usr/include itself: that breaks libc++'s #include_next).
|
||||
LLVM_INCDIR="$(llvm-config --includedir 2>/dev/null || true)"
|
||||
case "$LLVM_INCDIR" in ""|/usr/include) LLVM_INCFLAG="" ;; *) LLVM_INCFLAG="-I$LLVM_INCDIR" ;; esac
|
||||
|
||||
clang++ --target=x86_64-pc-linux-gnu -std=c++26 -stdlib=libc++ -O3 -march=$MARCH -mtune=$MTUNE -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile /usr/share/libc++/v1/std.cppm -o ./build/std.pcm
|
||||
common_options="--target=$TARGET -stdlib=libc++ -I./build/glslang $LLVM_INCFLAG -std=c++26 -O3 -march=$MARCH -mtune=$MTUNE -fprebuilt-module-path=./build -D $TARGET_DEFINE -D CRAFTER_BUILD_CONFIGURATION_TYPE_EXECUTABLE -c"
|
||||
|
||||
clang++ --target=$TARGET -std=c++26 -stdlib=libc++ -O3 -march=$MARCH -mtune=$MTUNE -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile /usr/share/libc++/v1/std.cppm -o ./build/std.pcm
|
||||
|
||||
clang++ $common_options -fmodule-output interfaces/Crafter.Build-Shader.cppm -o ./build/Crafter.Build-Shader.o
|
||||
clang++ $common_options -fmodule-output interfaces/Crafter.Build-Platform.cppm -o ./build/Crafter.Build-Platform.o
|
||||
|
|
@ -100,7 +113,7 @@ ar rcs ./lib/libcrafter-build.a \
|
|||
./build/Crafter.Build-Progress_impl.o \
|
||||
./build/Crafter.Build-Asset_impl.o
|
||||
|
||||
clang++ -std=c++26 -stdlib=libc++ -O3 -march=$MARCH -mtune=$MTUNE -fuse-ld=lld \
|
||||
clang++ --target=$TARGET -std=c++26 -stdlib=libc++ -O3 -march=$MARCH -mtune=$MTUNE -fuse-ld=lld \
|
||||
-Wl,--export-dynamic \
|
||||
-L./build \
|
||||
./build/Crafter.Build-Shader.o \
|
||||
|
|
|
|||
Loading…
Reference in a new issue