From 7b9f586c37938cc8191179e42b848e978a9ab87b Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 25 Jul 2025 03:50:05 +0000 Subject: [PATCH 1/5] Update and Fix rust linking --- recipes/dev/rust/config.toml | 6 +++++- recipes/dev/rust/recipe.toml | 9 ++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/recipes/dev/rust/config.toml b/recipes/dev/rust/config.toml index d2760f2e7..b53de2d71 100644 --- a/recipes/dev/rust/config.toml +++ b/recipes/dev/rust/config.toml @@ -1,6 +1,10 @@ [llvm] +# TODO: LLVM is only compiled for stage1, +# it should be possible to enable this download-ci-llvm = false static-libstdcpp = false +targets = "X86" +experimental-targets = "" # TODO: This currently must need to be set manually. # If you like to build llvm with sccache, uncomment: # ccache = "sccache" @@ -19,7 +23,6 @@ sysconfdir = "etc" [rust] backtrace = false -rpath = false codegen-tests = false [target.x86_64-unknown-redox] @@ -29,4 +32,5 @@ ar = "x86_64-unknown-redox-ar" linker = "x86_64-unknown-redox-gcc" # Nasty path, please fix llvm-config = "../../../../bin/x86_64-unknown-redox-llvm-config" +rpath = false crt-static = false diff --git a/recipes/dev/rust/recipe.toml b/recipes/dev/rust/recipe.toml index e71a4c6e6..3bdc930fd 100644 --- a/recipes/dev/rust/recipe.toml +++ b/recipes/dev/rust/recipe.toml @@ -1,8 +1,8 @@ [source] git = "https://gitlab.redox-os.org/redox-os/rust.git" -branch = "redox-2024-05-11" +branch = "redox-2025-01-12" # due to heavy git operation, this will only clone once and will not refetch -# if you want to refetch or changing the branch, please do ucr.rust +# if you want to refetch or changing the branch, please run `make ucr.rust` shallow_clone = true [build] @@ -15,9 +15,9 @@ script = """ DYNAMIC_INIT HOST_STRIP=$STRIP # Linker flags for stage2 compiler (host -> target) -export MAGIC_EXTRA_RUSTFLAGS="${LDFLAGS} -C link-args=-lz" +export LDFLAGS_x86_64_unknown_redox="${LDFLAGS}" # Don't poison the stage1 compiler (host -> host) -unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF STRIP +unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS STRIP python3 "${COOKBOOK_SOURCE}/x.py" install \ --config "${COOKBOOK_RECIPE}/config.toml" \ --jobs $(nproc) @@ -29,7 +29,6 @@ rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}/" [package] dependencies = [ - "gcc13", "cargo" ] # TODO: Not implemented From fe314d7b6af699159c3467dbb6e15b2538553bc2 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 25 Jul 2025 05:00:21 +0000 Subject: [PATCH 2/5] Add RUSTFLAGS again --- recipes/dev/rust/recipe.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/dev/rust/recipe.toml b/recipes/dev/rust/recipe.toml index 3bdc930fd..1197c373b 100644 --- a/recipes/dev/rust/recipe.toml +++ b/recipes/dev/rust/recipe.toml @@ -15,7 +15,10 @@ script = """ DYNAMIC_INIT HOST_STRIP=$STRIP # Linker flags for stage2 compiler (host -> target) -export LDFLAGS_x86_64_unknown_redox="${LDFLAGS}" +export LDFLAGS_x86_64_unknown_redox="${LDFLAGS}" # LLVM +export CARGO_TARGET_X86_64_UNKNOWN_REDOX_RUSTFLAGS="\ +-C link-arg=-L${COOKBOOK_SYSROOT}/lib \ +-C link-arg=-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib" # Don't poison the stage1 compiler (host -> host) unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS STRIP python3 "${COOKBOOK_SOURCE}/x.py" install \ From 2b0c27c02e0a9aff5bfd420b0803de252019ab1e Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 25 Jul 2025 05:02:57 +0000 Subject: [PATCH 3/5] Revert comments --- recipes/dev/rust/config.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/dev/rust/config.toml b/recipes/dev/rust/config.toml index b53de2d71..89604cb72 100644 --- a/recipes/dev/rust/config.toml +++ b/recipes/dev/rust/config.toml @@ -1,6 +1,4 @@ [llvm] -# TODO: LLVM is only compiled for stage1, -# it should be possible to enable this download-ci-llvm = false static-libstdcpp = false targets = "X86" From 6098ef179a14e60e22f9c43d789fe3677b035349 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 25 Jul 2025 07:07:31 +0000 Subject: [PATCH 4/5] Update args and fix rust auto deps --- recipes/dev/rust/recipe.toml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/dev/rust/recipe.toml b/recipes/dev/rust/recipe.toml index 1197c373b..50f563666 100644 --- a/recipes/dev/rust/recipe.toml +++ b/recipes/dev/rust/recipe.toml @@ -17,16 +17,18 @@ HOST_STRIP=$STRIP # Linker flags for stage2 compiler (host -> target) export LDFLAGS_x86_64_unknown_redox="${LDFLAGS}" # LLVM export CARGO_TARGET_X86_64_UNKNOWN_REDOX_RUSTFLAGS="\ --C link-arg=-L${COOKBOOK_SYSROOT}/lib \ --C link-arg=-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib" +-Clink-args=-L${COOKBOOK_SYSROOT}/lib \ +-Clink-args=-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib \ +-Clink-args=-lz" # Don't poison the stage1 compiler (host -> host) unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS STRIP python3 "${COOKBOOK_SOURCE}/x.py" install \ --config "${COOKBOOK_RECIPE}/config.toml" \ --jobs $(nproc) -rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}/" -"${HOST_STRIP}" -v "${COOKBOOK_STAGE}/bin/rustc" +mkdir -p "${COOKBOOK_STAGE}"/usr +rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/ +"${HOST_STRIP}" -v "${COOKBOOK_STAGE}/usr/bin/rustc" # TODO: rustdoc """ From b1a40a2b572400e89010674693e80142cb1fdd7b Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 25 Jul 2025 08:50:43 +0000 Subject: [PATCH 5/5] Strip is handled automatically --- recipes/dev/rust/recipe.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/dev/rust/recipe.toml b/recipes/dev/rust/recipe.toml index 50f563666..58b4658a2 100644 --- a/recipes/dev/rust/recipe.toml +++ b/recipes/dev/rust/recipe.toml @@ -13,7 +13,6 @@ dependencies = [ ] script = """ DYNAMIC_INIT -HOST_STRIP=$STRIP # Linker flags for stage2 compiler (host -> target) export LDFLAGS_x86_64_unknown_redox="${LDFLAGS}" # LLVM export CARGO_TARGET_X86_64_UNKNOWN_REDOX_RUSTFLAGS="\ @@ -28,7 +27,6 @@ python3 "${COOKBOOK_SOURCE}/x.py" install \ mkdir -p "${COOKBOOK_STAGE}"/usr rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/ -"${HOST_STRIP}" -v "${COOKBOOK_STAGE}/usr/bin/rustc" # TODO: rustdoc """