From 7a863fd96934db9c7faeb19a972166d1f7344716 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 10 Mar 2026 03:26:18 +0900 Subject: [PATCH 1/2] GNUmakefile: Swap uname -s with rustc --print host-tuple for cross-build and MSYS --- .github/workflows/make.yml | 34 ++++++++++++++++++++++++++++++++++ GNUmakefile | 19 ++++++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 917ee713826..8a8aca21036 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -266,6 +266,40 @@ jobs: # 2. the makefile doesn't try to install libstdbuf even though stdbuf is skipped DESTDIR=/tmp/ make SKIP_UTILS="stdbuf" install + # keep this job minimal to avoid have many duplicated build with CICD + build_makefile-other: + name: Build/Makefile + runs-on: ${{ matrix.job.os }} + env: + CARGO_INCREMENTAL: 0 + strategy: + fail-fast: false + matrix: + job: + - { os: windows-latest , features: feat_os_windows } + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - uses: Swatinem/rust-cache@v2 + - name: Run sccache-cache + id: sccache-setup + uses: mozilla-actions/sccache-action@v0.0.9 + continue-on-error: true + - name: Export sccache + if: steps.sccache-setup.outcome == 'success' + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - name: "`make build`" + shell: bash + run: | + set -x + # Check that we exclude unix programs to avoid build failure + make PREFIX=/tmp/usr MULTICALL=y COMPLETIONS=n MANPAGES=n LOCALES=n \ + SKIP_UTILS="arch b2sum base32 base64 basename basenc cat cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold head hostname join link ln ls md5sum mkdir mktemp more mv nl nproc numfmt od paste pr printenv printf ptx pwd readlink realpath rm rmdir seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split sum sync tac tail tee test touch tr truncate tsort uname unexpand uniq unlink vdir wc whoami yes" + target/debug/coreutils.exe true + test_busybox: name: Tests/BusyBox test suite runs-on: ${{ matrix.job.os }} diff --git a/GNUmakefile b/GNUmakefile index ae266b6c277..d3cfa2f6464 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,17 +62,14 @@ TOYBOX_ROOT := $(BASEDIR)/tmp TOYBOX_VER := 0.8.12 TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER) -#------------------------------------------------------------------------ -# Detect the host system. -# On Windows uname -s might return MINGW_NT-* or CYGWIN_NT-*. -# Otherwise let it default to the kernel name returned by uname -s -# (Linux, Darwin, FreeBSD, …). -#------------------------------------------------------------------------ -OS ?= $(shell uname -s) +# Detect the target system +# See https://doc.rust-lang.org/beta/rustc/platform-support.html +# todo: support building wasm +OS := $(or $(CARGO_BUILD_TARGET),$(shell rustc --print host-tuple)) # Windows does not allow symlink by default. # Allow to override LN for AppArmor. -ifneq (,$(findstring _NT,$(OS))) +ifneq (,$(findstring windows,$(OS))) LN ?= ln -f endif LN ?= ln -sf @@ -97,7 +94,7 @@ SELINUX_PROGS := \ $(info Detected OS = $(OS)) -ifeq (,$(findstring MINGW,$(OS))) +ifeq (,$(findstring windows,$(OS))) PROGS += $(UNIX_PROGS) endif ifeq ($(SELINUX_ENABLED),1) @@ -288,7 +285,7 @@ install: build install-manpages install-completions install-locales mkdir -p $(INSTALLDIR_BIN) ifneq (,$(and $(findstring stdbuf,$(UTILS)),$(findstring feat_external_libstdbuf,$(CARGOFLAGS)))) mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR) -ifneq (,$(findstring CYGWIN,$(OS))) +ifneq (,$(findstring cygwin,$(OS))) $(INSTALL) -m 755 $(BUILDDIR)/deps/stdbuf.dll $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.dll else $(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf.* $(DESTDIR)$(LIBSTDBUF_DIR)/ @@ -308,7 +305,7 @@ else endif uninstall: -ifeq (,$(findstring MINGW,$(OS))) +ifeq (,$(findstring windows,$(OS))) rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.* -rm -d $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true endif From c2b79ad450551c3c00352bc521575804f5eda119 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Mon, 16 Mar 2026 19:52:19 +0900 Subject: [PATCH 2/2] GNUmakefile: Do not depend on system tr for Gentoo --- GNUmakefile | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index d3cfa2f6464..a99fefa46ec 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -74,20 +74,6 @@ ifneq (,$(findstring windows,$(OS))) endif LN ?= ln -sf -# Possible programs -PROGS := \ - $(shell sed -n '/feat_Tier1 = \[/,/\]/p' Cargo.toml | sed '1d;2d' |tr -d '],"\n')\ - $(shell sed -n '/feat_common_core = \[/,/\]/p' Cargo.toml | sed '1d' |tr -d '],"\n') - -UNIX_PROGS := \ - $(shell sed -n '/feat_require_unix_core = \[/,/\]/p' Cargo.toml | sed '1d' |tr -d '],"\n') \ - hostid \ - pinky \ - stdbuf \ - uptime \ - users \ - who - SELINUX_PROGS := \ chcon \ runcon @@ -95,8 +81,12 @@ SELINUX_PROGS := \ $(info Detected OS = $(OS)) ifeq (,$(findstring windows,$(OS))) - PROGS += $(UNIX_PROGS) + FEATURE_EXTRACT_UTILS := feat_os_unix +else + FEATURE_EXTRACT_UTILS := feat_Tier1 endif +PROGS := $(shell cargo tree --depth 1 --features $(FEATURE_EXTRACT_UTILS) --format "{p}" --prefix none | sed -E -n 's/^uu_([^ ]+).*/\1/p') + ifeq ($(SELINUX_ENABLED),1) PROGS += $(SELINUX_PROGS) endif @@ -111,7 +101,7 @@ endif # Programs with usable tests TESTS := \ - $(sort $(filter $(UTILS),$(PROGS) $(UNIX_PROGS) $(SELINUX_PROGS))) + $(sort $(filter $(UTILS),$(PROGS) $(SELINUX_PROGS))) TEST_NO_FAIL_FAST := TEST_SPEC_FEATURE :=