From fad6779cdcf109c3facb5581970c1a38d0036225 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Thu, 26 Feb 2026 15:22:01 +0700 Subject: [PATCH] Set llvm in rust for redox dynamically linked --- recipes/archives/zstd/recipe.toml | 3 +++ recipes/dev/llvm21/recipe.toml | 2 +- recipes/dev/rust/config-bootstrap.toml | 1 - recipes/dev/rust/config.toml | 1 + recipes/dev/rust/recipe.toml | 2 ++ 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/recipes/archives/zstd/recipe.toml b/recipes/archives/zstd/recipe.toml index 2e723f8c6..10796f853 100644 --- a/recipes/archives/zstd/recipe.toml +++ b/recipes/archives/zstd/recipe.toml @@ -8,6 +8,9 @@ template = "custom" script = """ DYNAMIC_STATIC_INIT rsync -av --delete "${COOKBOOK_SOURCE}/" ./ +# TODO: fPIC is the default on linux but not on redox and +# required by llvm21 as zstd statically linked there +export CPPFLAGS="$CPPFLAGS -fPIC" ${COOKBOOK_MAKE} ${COOKBOOK_MAKE} install DESTDIR="${COOKBOOK_STAGE}" prefix="/usr" """ diff --git a/recipes/dev/llvm21/recipe.toml b/recipes/dev/llvm21/recipe.toml index 041243edc..e5454478e 100644 --- a/recipes/dev/llvm21/recipe.toml +++ b/recipes/dev/llvm21/recipe.toml @@ -40,6 +40,7 @@ COOKBOOK_CMAKE_FLAGS+=( -DLLVM_TOOL_LLVM_PROFDATA_BUILD=On -DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS_TO_BUILD" -DLLVM_ENABLE_ZLIB=Off + -DLLVM_USE_STATIC_ZSTD=On # the rest of options that shared to clang -DCROSS_TOOLCHAIN_FLAGS_NATIVE="-DCMAKE_TOOLCHAIN_FILE=$(realpath "${COOKBOOK_RECIPE}/native.cmake")" @@ -64,7 +65,6 @@ if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then # avoid linking as much as possible during bootstrapping COOKBOOK_CMAKE_FLAGS+=( -DLLVM_ENABLE_LIBXML2=Off - -DLLVM_USE_STATIC_ZSTD=On ) fi diff --git a/recipes/dev/rust/config-bootstrap.toml b/recipes/dev/rust/config-bootstrap.toml index b3fc3b828..c467336fa 100644 --- a/recipes/dev/rust/config-bootstrap.toml +++ b/recipes/dev/rust/config-bootstrap.toml @@ -1,7 +1,6 @@ [llvm] download-ci-llvm = false static-libstdcpp = false -# shared with lld link-shared = true [build] diff --git a/recipes/dev/rust/config.toml b/recipes/dev/rust/config.toml index 29dc44760..4d2cace38 100644 --- a/recipes/dev/rust/config.toml +++ b/recipes/dev/rust/config.toml @@ -3,6 +3,7 @@ download-ci-llvm = false static-libstdcpp = false targets = "X86" experimental-targets = "" +link-shared = true [build] host = ["x86_64-unknown-redox"] diff --git a/recipes/dev/rust/recipe.toml b/recipes/dev/rust/recipe.toml index 84f0a9713..b42238e88 100644 --- a/recipes/dev/rust/recipe.toml +++ b/recipes/dev/rust/recipe.toml @@ -35,6 +35,8 @@ export CARGO_TARGET_X86_64_UNKNOWN_REDOX_RUSTFLAGS="\ -Clink-args=-lz -Clink-args=-lzstd" # Hack for Rust errorneusly running `llvm-config --version` on cross compiled llvm-config cat "${COOKBOOK_ROOT}/bin/x86_64-unknown-redox-llvm-config" > "${COOKBOOK_SYSROOT}/bin/llvm-config" +# Hack for Rust stage1 being dynamically linked with LLVM in prefix toolchain +export LD_LIBRARY_PATH="${COOKBOOK_HOST_SYSROOT}/lib:${LD_LIBRARY_PATH}" # Linker flags for stage1 compiler (host -> host) export RUSTFLAGS_BOOTSTRAP="\ -Clink-args=-L${COOKBOOK_HOST_SYSROOT}/lib \