From c0b8ecbe067341e93bf31c259d2d85f80fb628d2 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sat, 25 Oct 2025 21:10:45 +0900 Subject: [PATCH 1/9] Fix cross-build --- GNUmakefile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e4bc5f4355f..3cc614af7e2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -27,6 +27,7 @@ RM := rm -rf # Binaries CARGO ?= cargo CARGOFLAGS ?= +RUSTC_ARCH ?= # should be empty instead of --target $(shell rustc -vV | sed -n 's/host: //p') to share crates ar target dir # Install directories PREFIX ?= /usr/local @@ -342,14 +343,14 @@ use_default := 1 build-pkgs: ifneq (${MULTICALL}, y) ifdef BUILD_SPEC_FEATURE - ${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) + $(CARGO) build $(CARGOFLAGS) --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) else - ${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) + $(CARGO) build $(CARGOFLAGS) $(PROFILE_CMD) $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) endif endif build-coreutils: - ${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features + $(CARGO) build $(CARGOFLAGS) --features "$(EXES) $(BUILD_SPEC_FEATURE)" $(PROFILE_CMD) --no-default-features $(RUSTC_ARCH) build: build-coreutils build-pkgs locales @@ -400,15 +401,16 @@ busytest: $(BUILDDIR)/busybox $(addprefix test_busybox_,$(filter-out $(SKIP_UTIL endif clean: - cargo clean - cd $(DOCSDIR) && $(MAKE) clean + cargo clean $(RUSTC_ARCH) + cd $(DOCSDIR) && $(MAKE) clean $(RUSTC_ARCH) distclean: clean - $(CARGO) clean $(CARGOFLAGS) && $(CARGO) update $(CARGOFLAGS) + $(CARGO) clean $(CARGOFLAGS) $(RUSTC_ARCH) && $(CARGO) update $(CARGOFLAGS) $(RUSTC_ARCH) ifeq ($(MANPAGES),y) build-uudoc: - ${CARGO} build ${CARGOFLAGS} --bin uudoc --features "uudoc ${EXES}" ${PROFILE_CMD} --no-default-features + # Use same PROFILE with coreutils to share crates (if not cross-build) + $(CARGO) build $(CARGOFLAGS) --bin uudoc --features "uudoc $(EXES)" $(PROFILE_CMD) --no-default-features install-manpages: build-uudoc mkdir -p $(DESTDIR)$(DATAROOTDIR)/man/man1 From 40f1de0223956d8d96584c0558fa78e2a87f570c Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 01:21:53 +0900 Subject: [PATCH 2/9] Add min test for cross build --- .github/workflows/CICD.yml | 8 +++++++- GNUmakefile | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 99b7c996be6..cf99f02b56f 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -269,6 +269,9 @@ jobs: with: persist-credentials: false - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@stable + with: + target: aarch64-unknown-linux-gnu - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 - name: Install/setup prerequisites @@ -287,7 +290,10 @@ jobs: if [[ -d target ]]; then mv -T target target.cache fi - # Actually do the build + # Minimal cross-built with native uudoc + make UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu" + ./target/debug/uudoc manpage + # build (host) make build echo "Check that target directory will be ignored by backup tools" test -f target/CACHEDIR.TAG diff --git a/GNUmakefile b/GNUmakefile index 3cc614af7e2..44b2a1a2882 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -27,7 +27,7 @@ RM := rm -rf # Binaries CARGO ?= cargo CARGOFLAGS ?= -RUSTC_ARCH ?= # should be empty instead of --target $(shell rustc -vV | sed -n 's/host: //p') to share crates ar target dir +RUSTC_ARCH ?= # should be empty except for cross-build, not --target $(shell rustc -vV | sed -n 's/host: //p') # Install directories PREFIX ?= /usr/local From 11413574ab41ecd10ba82354126866fbb8a195e4 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 03:39:31 +0900 Subject: [PATCH 3/9] Fix CICD.yml --- .github/workflows/CICD.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index cf99f02b56f..f1d2917a8bc 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -269,9 +269,8 @@ jobs: with: persist-credentials: false - uses: dtolnay/rust-toolchain@stable - - uses: dtolnay/rust-toolchain@stable - with: - target: aarch64-unknown-linux-gnu + with: + target: aarch64-unknown-linux-gnu - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 - name: Install/setup prerequisites @@ -292,7 +291,7 @@ jobs: fi # Minimal cross-built with native uudoc make UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu" - ./target/debug/uudoc manpage + ./target/debug/uudoc manpage true # build (host) make build echo "Check that target directory will be ignored by backup tools" From b6108696b36a389f1ce2439fe7f6a8a2b497ba28 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 03:50:46 +0900 Subject: [PATCH 4/9] Add config for cross build --- .cargo/config.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 45efde1f333..364776950c7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,6 +4,8 @@ [target.x86_64-unknown-redox] linker = "x86_64-unknown-redox-gcc" +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" [env] # See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml From 0e94f10ca4743411542c118eedaac4ed4554f5f8 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 03:59:56 +0900 Subject: [PATCH 5/9] Add cross-gcc --- .github/workflows/CICD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index f1d2917a8bc..523c79cb42d 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -122,7 +122,7 @@ jobs: - name: Install/setup prerequisites shell: bash run: | - sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev + sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu libselinux1-dev - name: Initialize workflow variables id: vars shell: bash From 6591424582f49ac1194ccd26bf3bbfeb2fc1402b Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 14:43:40 +0900 Subject: [PATCH 6/9] CICD.yml: chekc that we don't cross-build uudoc --- .github/workflows/CICD.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 523c79cb42d..a3fb6af5ce1 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -289,9 +289,8 @@ jobs: if [[ -d target ]]; then mv -T target target.cache fi - # Minimal cross-built with native uudoc - make UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu" - ./target/debug/uudoc manpage true + # Check that we don't cross-build uudoc + make install-manpages UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu" # build (host) make build echo "Check that target directory will be ignored by backup tools" From c3f621d0611ac6bfd61064b36fe5d64dcf5c2870 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:30:45 +0900 Subject: [PATCH 7/9] Revert some () to {} --- GNUmakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 44b2a1a2882..e593649485b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -343,14 +343,14 @@ use_default := 1 build-pkgs: ifneq (${MULTICALL}, y) ifdef BUILD_SPEC_FEATURE - $(CARGO) build $(CARGOFLAGS) --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) + ${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" $(PROFILE_CMD) $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) else - $(CARGO) build $(CARGOFLAGS) $(PROFILE_CMD) $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) + ${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) endif endif build-coreutils: - $(CARGO) build $(CARGOFLAGS) --features "$(EXES) $(BUILD_SPEC_FEATURE)" $(PROFILE_CMD) --no-default-features $(RUSTC_ARCH) + ${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features $(RUSTC_ARCH) build: build-coreutils build-pkgs locales @@ -410,7 +410,7 @@ distclean: clean ifeq ($(MANPAGES),y) build-uudoc: # Use same PROFILE with coreutils to share crates (if not cross-build) - $(CARGO) build $(CARGOFLAGS) --bin uudoc --features "uudoc $(EXES)" $(PROFILE_CMD) --no-default-features + ${CARGO} build ${CARGOFLAGS} --bin uudoc --features "uudoc ${EXES}" ${PROFILE_CMD} --no-default-features install-manpages: build-uudoc mkdir -p $(DESTDIR)$(DATAROOTDIR)/man/man1 From 95d964e3be8975d159873a88e5cdbead3a832013 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:32:31 +0900 Subject: [PATCH 8/9] Revert $(PROFILE_CMD) --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index e593649485b..91d9e7385ee 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -343,7 +343,7 @@ use_default := 1 build-pkgs: ifneq (${MULTICALL}, y) ifdef BUILD_SPEC_FEATURE - ${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" $(PROFILE_CMD) $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) + ${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) else ${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH) endif From 3dc541985a5472ad76fe27507f1603edc7d32971 Mon Sep 17 00:00:00 2001 From: E <79379754+oech3@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:44:34 +0900 Subject: [PATCH 9/9] CICD.yml: PREFIX at cross-build --- .github/workflows/CICD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index a3fb6af5ce1..20517fd630d 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -290,7 +290,7 @@ jobs: mv -T target target.cache fi # Check that we don't cross-build uudoc - make install-manpages UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu" + make install-manpages PREFIX=/tmp/usr UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu" # build (host) make build echo "Check that target directory will be ignored by backup tools"