From 4ac4593192fda74ba065d5421ae3551b811c9973 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Thu, 3 Jul 2025 13:21:08 +0000 Subject: [PATCH 1/7] Support build with sccache in podman --- mk/config.mk | 19 ++++++++++++++++++- podman/rustinstall.sh | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mk/config.mk b/mk/config.mk index 1dc21d9b5..c1b43a7a7 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -31,6 +31,8 @@ HOST_CARGO=env -u RUSTUP_TOOLCHAIN -u CC -u TARGET cargo REDOXFS_MKFS_FLAGS?= ## Set to 1 to enable Podman build, any other value will disable it PODMAN_BUILD?=1 +## Enable sccache to speed up cargo builds +SSCACHE_BUILD?=1 ## The containerfile to use for the Podman base image CONTAINERFILE?=podman/redox-base-containerfile @@ -41,9 +43,17 @@ export REDOX_MAKE=make ifneq ($(PODMAN_BUILD),1) HOST_TARGET := $(shell env -u RUSTUP_TOOLCHAIN rustc -vV | grep host | cut -d: -f2 | tr -d " ") ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu) - # The binary prefix is only built for x86_64 Linux hosts + $(info The binary prefix is only built for x86_64 Linux hosts) PREFIX_BINARY=0 endif + +ifeq ($(SSCACHE_BUILD),1) +ifeq (,$(shell command -v sccache)) + $(info sccache not found in PATH) + SSCACHE_BUILD=0 +endif +endif + endif UNAME := $(shell uname) @@ -112,6 +122,13 @@ RANLIB=$(GNU_TARGET)-gcc-ranlib READELF=$(GNU_TARGET)-readelf STRIP=$(GNU_TARGET)-strip +ifeq ($(SSCACHE_BUILD),1) + CC_WRAPPER:=sccache + CC=$(CC_WRAPPER) $(GNU_TARGET)-gcc + CXX=$(CC_WRAPPER) $(GNU_TARGET)-g++ + export RUSTC_WRAPPER:=$(CC_WRAPPER) +endif + ## Rust cross compile variables export AR_$(subst -,_,$(TARGET)):=$(AR) export CC_$(subst -,_,$(TARGET)):=$(CC) diff --git a/podman/rustinstall.sh b/podman/rustinstall.sh index 2fce22bdb..def5c2b53 100755 --- a/podman/rustinstall.sh +++ b/podman/rustinstall.sh @@ -7,3 +7,6 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable cargo +stable install --force --version 0.1.1 cargo-config cargo +stable install --force --version 1.16.0 just cargo +stable install --force --version 0.27.0 cbindgen + +SCCACHE_PATH=https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(uname -m)-unknown-linux-musl.tar.gz +curl -sSL $(SCCACHE_PATH) | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' From a9e311c0126be7a2ae077fc26c7d64efefb965da Mon Sep 17 00:00:00 2001 From: Wildan M Date: Thu, 3 Jul 2025 20:54:16 +0700 Subject: [PATCH 2/7] Fix config --- mk/config.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mk/config.mk b/mk/config.mk index c1b43a7a7..60d9cf567 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -32,7 +32,8 @@ REDOXFS_MKFS_FLAGS?= ## Set to 1 to enable Podman build, any other value will disable it PODMAN_BUILD?=1 ## Enable sccache to speed up cargo builds -SSCACHE_BUILD?=1 +## only do this by default if this is inside podman +SSCACHE_BUILD?=$(PODMAN_BUILD) ## The containerfile to use for the Podman base image CONTAINERFILE?=podman/redox-base-containerfile @@ -43,19 +44,18 @@ export REDOX_MAKE=make ifneq ($(PODMAN_BUILD),1) HOST_TARGET := $(shell env -u RUSTUP_TOOLCHAIN rustc -vV | grep host | cut -d: -f2 | tr -d " ") ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu) - $(info The binary prefix is only built for x86_64 Linux hosts) + $(info The binary prefix is only built for x86_64 Linux hosts) PREFIX_BINARY=0 endif +endif ifeq ($(SSCACHE_BUILD),1) ifeq (,$(shell command -v sccache)) - $(info sccache not found in PATH) + $(info sccache not found in PATH) SSCACHE_BUILD=0 endif endif -endif - UNAME := $(shell uname) ifeq ($(UNAME),Darwin) FUMOUNT=umount From 0701d81b4107ad61c3417acc15035fa0229dadcb Mon Sep 17 00:00:00 2001 From: Wildan M Date: Thu, 3 Jul 2025 21:03:32 +0700 Subject: [PATCH 3/7] FIx env --- podman/rustinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/podman/rustinstall.sh b/podman/rustinstall.sh index def5c2b53..f72851d95 100755 --- a/podman/rustinstall.sh +++ b/podman/rustinstall.sh @@ -9,4 +9,4 @@ cargo +stable install --force --version 1.16.0 just cargo +stable install --force --version 0.27.0 cbindgen SCCACHE_PATH=https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(uname -m)-unknown-linux-musl.tar.gz -curl -sSL $(SCCACHE_PATH) | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' +curl -sSL $SCCACHE_PATH | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' From 949f56d78214d9e052b43a4e2d22c343a2fe707d Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 4 Jul 2025 08:23:09 +0700 Subject: [PATCH 4/7] Fix podman detection --- mk/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/config.mk b/mk/config.mk index 60d9cf567..b0994bb3f 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -33,7 +33,7 @@ REDOXFS_MKFS_FLAGS?= PODMAN_BUILD?=1 ## Enable sccache to speed up cargo builds ## only do this by default if this is inside podman -SSCACHE_BUILD?=$(PODMAN_BUILD) +SSCACHE_BUILD?=$(shell [ -f /run/.containerenv ] && echo 1 || echo 0) ## The containerfile to use for the Podman base image CONTAINERFILE?=podman/redox-base-containerfile From 424f51e9e297d958b2be701eccacee076b1fbcd5 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 4 Jul 2025 06:20:37 +0000 Subject: [PATCH 5/7] Typo --- mk/config.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mk/config.mk b/mk/config.mk index b0994bb3f..4e03907b9 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -33,7 +33,7 @@ REDOXFS_MKFS_FLAGS?= PODMAN_BUILD?=1 ## Enable sccache to speed up cargo builds ## only do this by default if this is inside podman -SSCACHE_BUILD?=$(shell [ -f /run/.containerenv ] && echo 1 || echo 0) +SCCACHE_BUILD?=$(shell [ -f /run/.containerenv ] && echo 1 || echo 0) ## The containerfile to use for the Podman base image CONTAINERFILE?=podman/redox-base-containerfile @@ -49,10 +49,10 @@ ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu) endif endif -ifeq ($(SSCACHE_BUILD),1) +ifeq ($(SCCACHE_BUILD),1) ifeq (,$(shell command -v sccache)) $(info sccache not found in PATH) - SSCACHE_BUILD=0 + SCCACHE_BUILD=0 endif endif @@ -122,7 +122,7 @@ RANLIB=$(GNU_TARGET)-gcc-ranlib READELF=$(GNU_TARGET)-readelf STRIP=$(GNU_TARGET)-strip -ifeq ($(SSCACHE_BUILD),1) +ifeq ($(SCCACHE_BUILD),1) CC_WRAPPER:=sccache CC=$(CC_WRAPPER) $(GNU_TARGET)-gcc CXX=$(CC_WRAPPER) $(GNU_TARGET)-g++ From eb2d1db239ce3408c94be225bb7dfc2331fd0794 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 4 Jul 2025 18:27:08 +0700 Subject: [PATCH 6/7] Install with sccache to speed it up --- podman/rustinstall.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/podman/rustinstall.sh b/podman/rustinstall.sh index f72851d95..2210dcc20 100755 --- a/podman/rustinstall.sh +++ b/podman/rustinstall.sh @@ -4,9 +4,11 @@ # in Podman after the image has been built curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable -cargo +stable install --force --version 0.1.1 cargo-config -cargo +stable install --force --version 1.16.0 just -cargo +stable install --force --version 0.27.0 cbindgen SCCACHE_PATH=https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(uname -m)-unknown-linux-musl.tar.gz curl -sSL $SCCACHE_PATH | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' +export RUSTC_WRAPPER=sccache + +cargo +stable install --force --version 0.1.1 cargo-config +cargo +stable install --force --version 1.16.0 just +cargo +stable install --force --version 0.27.0 cbindgen From ef910b7307683134db4c59d55d45710f74240221 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Sat, 5 Jul 2025 08:59:50 +0700 Subject: [PATCH 7/7] Apply submodules --- cookbook | 2 +- mk/config.mk | 4 ++-- relibc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook b/cookbook index 1f238c0f9..f7f69579e 160000 --- a/cookbook +++ b/cookbook @@ -1 +1 @@ -Subproject commit 1f238c0f912cab65079fc2681cb94fde90b27790 +Subproject commit f7f69579e55e7c967e8205c2cb248fc9ef5310bf diff --git a/mk/config.mk b/mk/config.mk index 4e03907b9..ceb2df0ad 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -123,10 +123,10 @@ READELF=$(GNU_TARGET)-readelf STRIP=$(GNU_TARGET)-strip ifeq ($(SCCACHE_BUILD),1) - CC_WRAPPER:=sccache + export CC_WRAPPER:=sccache + export RUSTC_WRAPPER:=$(CC_WRAPPER) CC=$(CC_WRAPPER) $(GNU_TARGET)-gcc CXX=$(CC_WRAPPER) $(GNU_TARGET)-g++ - export RUSTC_WRAPPER:=$(CC_WRAPPER) endif ## Rust cross compile variables diff --git a/relibc b/relibc index 1550bb54b..84d410084 160000 --- a/relibc +++ b/relibc @@ -1 +1 @@ -Subproject commit 1550bb54b5eb5e13e31c311ae8c116e6b009831b +Subproject commit 84d410084571e456031f48650b75b1b2f628550d