Skip to content

Commit 552c386

Browse files
authored
GNUmakefile: Add a value for cross-build (#9015)
* Fix cross-build * Add min test for cross build * Fix CICD.yml * Add config for cross build * Add cross-gcc * CICD.yml: chekc that we don't cross-build uudoc * Revert some () to {} * Revert $(PROFILE_CMD) * CICD.yml: PREFIX at cross-build
1 parent f7e639f commit 552c386

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
[target.x86_64-unknown-redox]
66
linker = "x86_64-unknown-redox-gcc"
7+
[target.aarch64-unknown-linux-gnu]
8+
linker = "aarch64-linux-gnu-gcc"
79

810
[env]
911
# See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml

.github/workflows/CICD.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
- name: Install/setup prerequisites
123123
shell: bash
124124
run: |
125-
sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
125+
sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu libselinux1-dev
126126
- name: Initialize workflow variables
127127
id: vars
128128
shell: bash
@@ -269,6 +269,8 @@ jobs:
269269
with:
270270
persist-credentials: false
271271
- uses: dtolnay/rust-toolchain@stable
272+
with:
273+
target: aarch64-unknown-linux-gnu
272274
- uses: taiki-e/install-action@nextest
273275
- uses: Swatinem/rust-cache@v2
274276
- name: Install/setup prerequisites
@@ -287,7 +289,9 @@ jobs:
287289
if [[ -d target ]]; then
288290
mv -T target target.cache
289291
fi
290-
# Actually do the build
292+
# Check that we don't cross-build uudoc
293+
make install-manpages PREFIX=/tmp/usr UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu"
294+
# build (host)
291295
make build
292296
echo "Check that target directory will be ignored by backup tools"
293297
test -f target/CACHEDIR.TAG

GNUmakefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RM := rm -rf
2727
# Binaries
2828
CARGO ?= cargo
2929
CARGOFLAGS ?=
30+
RUSTC_ARCH ?= # should be empty except for cross-build, not --target $(shell rustc -vV | sed -n 's/host: //p')
3031

3132
# Install directories
3233
PREFIX ?= /usr/local
@@ -342,14 +343,14 @@ use_default := 1
342343
build-pkgs:
343344
ifneq (${MULTICALL}, y)
344345
ifdef BUILD_SPEC_FEATURE
345-
${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg))
346+
${CARGO} build ${CARGOFLAGS} --features "$(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH)
346347
else
347-
${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg))
348+
${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} $(foreach pkg,$(EXES),-p uu_$(pkg)) $(RUSTC_ARCH)
348349
endif
349350
endif
350351

351352
build-coreutils:
352-
${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features
353+
${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features $(RUSTC_ARCH)
353354

354355
build: build-coreutils build-pkgs locales
355356

@@ -400,14 +401,15 @@ busytest: $(BUILDDIR)/busybox $(addprefix test_busybox_,$(filter-out $(SKIP_UTIL
400401
endif
401402

402403
clean:
403-
cargo clean
404-
cd $(DOCSDIR) && $(MAKE) clean
404+
cargo clean $(RUSTC_ARCH)
405+
cd $(DOCSDIR) && $(MAKE) clean $(RUSTC_ARCH)
405406

406407
distclean: clean
407-
$(CARGO) clean $(CARGOFLAGS) && $(CARGO) update $(CARGOFLAGS)
408+
$(CARGO) clean $(CARGOFLAGS) $(RUSTC_ARCH) && $(CARGO) update $(CARGOFLAGS) $(RUSTC_ARCH)
408409

409410
ifeq ($(MANPAGES),y)
410411
build-uudoc:
412+
# Use same PROFILE with coreutils to share crates (if not cross-build)
411413
${CARGO} build ${CARGOFLAGS} --bin uudoc --features "uudoc ${EXES}" ${PROFILE_CMD} --no-default-features
412414

413415
install-manpages: build-uudoc

0 commit comments

Comments
 (0)