Repository navigation
Description
Problem
When cross-compiling a release, tools/package_release.sh passes the Cargo target linker assignment to env using an unquoted expansion. If HYB_CC is a linker path with spaces, env treats part of the path as the command name and exits 127 before either build completes.
Reproduction and verification
On base 5071ce8, an offline test sets HYB_RUST_TARGET=aarch64-unknown-linux-gnu and HYB_CC to a path ending in tool chain/target gcc. The unmodified script exits 127 with env: chain/target: No such file or directory. After quoting the assignment, the fixture records the full, unmodified linker path in both Cargo invocations. All seven packaging and version tests pass, as do sh -n and git apply --check. This uses a Cargo fixture and does not exercise a native cross compiler or the separate Go/QEMU smoke path.
Patch
In both cross-build branches (the hyrt library and hyb), change env CARGO_BUILD_JOBS=2 $CROSS_ENV cargo build … to env CARGO_BUILD_JOBS=2 "$CROSS_ENV" cargo build ….
The regression extends PackageReleaseIsolationTests: the fake Cargo records CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER on each invocation, then the test checks that both recorded values equal the original path with spaces. The full patch follows below.
Please consider this tooling fix under the useful-improvements track in BOUNTY.md.
Full patch against 5071ce8
--- a/tools/package_release.sh
+++ b/tools/package_release.sh
@@ -84,7 +84,7 @@
echo "==> building hyrt staticlib (crate-local)"
( cd "$REPO_ROOT/runtime/rust/hyrt" && \
if [ -n "$RUST_TARGET" ]; then \
- env CARGO_BUILD_JOBS=2 $CROSS_ENV cargo build --release --target "$RUST_TARGET" --quiet; \
+ env CARGO_BUILD_JOBS=2 "$CROSS_ENV" cargo build --release --target "$RUST_TARGET" --quiet; \
else \
CARGO_BUILD_JOBS=2 cargo build --release --quiet; fi )
@@ -93,7 +93,7 @@
echo "==> building hyb (release)"
( cd "$REPO_ROOT/compiler" && \
if [ -n "$RUST_TARGET" ]; then \
- env CARGO_BUILD_JOBS=2 $CROSS_ENV cargo build --release -p hyb --target "$RUST_TARGET" --quiet; \
+ env CARGO_BUILD_JOBS=2 "$CROSS_ENV" cargo build --release -p hyb --target "$RUST_TARGET" --quiet; \
else \
cargo build --release -p hyb --quiet; fi )
HYB_BIN="$REPO_ROOT/compiler/target/release/hyb"
--- a/tools/test_package_release.py
+++ b/tools/test_package_release.py
@@ -218,6 +218,20 @@
(self.repo / "runtime" / "rust" / "hyrt" / "target" / "release" / "libhyrt.a").read_text(),
"FRESH-LIB\n",
)
+
+ def test_cross_linker_path_with_spaces_reaches_both_cargo_builds(self):
+ triple = "aarch64-unknown-linux-gnu"
+ linker = str(self.root / "tool chain" / "target gcc")
+ cargo = self.cargo_bin / "cargo"
+ source = cargo.read_text()
+ cargo.write_text(source.replace(
+ "#!/bin/sh\n",
+ '#!/bin/sh\nprintf "%s\\n" "$CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER" >> "$LINKER_LOG"\n',
+ 1,
+ ))
+ log = self.root / "linker.log"
+ self.package(HYB_RUST_TARGET=triple, HYB_CC=linker, LINKER_LOG=str(log))
+ self.assertEqual(log.read_text().splitlines(), [linker, linker])
def test_cross_target_ships_triple_artifacts_not_the_native_tree(self):
triple = "aarch64-unknown-linux-gnu"
Activity