mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-11-05 04:06:38 +08:00
Merge branch 'fix-nix-native-prefix' into 'master'
nix: Fix make prefix in native devShell See merge request redox-os/redox!2287
This commit is contained in:
commit
dc666e0c73
@ -101,7 +101,7 @@
|
||||
};
|
||||
|
||||
#TODO: This isn't tested yet, use at your own risk
|
||||
native = pkgs.mkShell rec {
|
||||
native = (pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }) rec {
|
||||
nativeBuildInputs =
|
||||
let
|
||||
autoreconf269 = pkgs.writeShellScriptBin "autoreconf2.69" "${pkgs.autoconf269}/bin/autoreconf";
|
||||
@ -154,6 +154,9 @@
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
(pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
||||
gmp # relibc
|
||||
mpfr # relibc
|
||||
libmpc # relibc
|
||||
fuse # fuser
|
||||
libpng # netsurf
|
||||
fontconfig # orbutils
|
||||
@ -162,6 +165,8 @@
|
||||
xtrans # libX11
|
||||
];
|
||||
|
||||
hardeningDisable = [ "format" ];
|
||||
|
||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||
PERL_PATH = "${pkgs.perl}/bin/perl";
|
||||
SKIP_CHECK_TOOLS = "1";
|
||||
|
||||
@ -249,6 +249,7 @@ else
|
||||
mkdir -p "$@.partial" $(PREFIX)/relibc-freestanding-install/$(GNU_TARGET)/include
|
||||
export $(PREFIX_CONFIG) PATH="$(ROOT)/$(PREFIX)/libtool-install/bin:$(ROOT)/$(PREFIX)/binutils-install/bin:$$PATH" \
|
||||
COOKBOOK_LIBTOOL_DIR=$(ROOT)/$(PREFIX)/libtool-install COOKBOOK_CROSS_TARGET=$(TARGET) COOKBOOK_CROSS_GNU_TARGET=$(GNU_TARGET) \
|
||||
ACLOCAL_PATH=$(ROOT)/$(PREFIX)/libtool-install/share/aclocal:$$ACLOCAL_PATH \
|
||||
COOKBOOK_HOST_SYSROOT=/usr COOKBOOK_CROSS_SYSROOT=$(ROOT)/$(PREFIX)/relibc-freestanding-install/$(GNU_TARGET) && \
|
||||
$(REPO_BIN) cook host:gcc13
|
||||
cp -r "$(GCC_TARGET)/stage/usr/". "$@.partial"
|
||||
@ -304,7 +305,8 @@ else
|
||||
rm -f "$@.partial"/$(GNU_TARGET)/lib/libstdc++.la
|
||||
rm -f "$@.partial"/$(GNU_TARGET)/lib/libsupc++.la
|
||||
# hosted libstdcxx
|
||||
export PATH="$(ROOT)/$@.partial/bin:$$PATH" && \
|
||||
export PATH="$(ROOT)/$@.partial/bin:$$PATH" \
|
||||
ACLOCAL_PATH="$(ROOT)/$(PREFIX)/libtool-install/share/aclocal:$$ACLOCAL_PATH" && \
|
||||
export $(PREFIX_CONFIG) "COOKBOOK_HOST_SYSROOT=$(ROOT)/$@.partial" COOKBOOK_CROSS_TARGET=$(HOST_TARGET) && \
|
||||
rm -rf "$(LIBSTDCXX_TARGET)/stage" && $(REPO_BIN) cook libstdcxx-v3
|
||||
cp -r "$(LIBSTDCXX_TARGET)/stage/usr/". "$@.partial/$(GNU_TARGET)"
|
||||
|
||||
@ -7,6 +7,7 @@ DYNAMIC_INIT
|
||||
COOKBOOK_AUTORECONF=autoreconf2.69 autotools_recursive_regenerate -I"$(realpath ./config)"
|
||||
LIBTOOL_BUILD_AUX="${COOKBOOK_LIBTOOL_DIR:-$COOKBOOK_HOST_SYSROOT}"/share/libtool/build-aux
|
||||
cp -fpv "$LIBTOOL_BUILD_AUX"/{config.sub,config.guess,install-sh} libiberty/
|
||||
cp -fpv "$LIBTOOL_BUILD_AUX"/{config.sub,config.guess,install-sh} zlib/contrib/minizip/
|
||||
"""
|
||||
|
||||
[build]
|
||||
|
||||
@ -1,82 +1,83 @@
|
||||
[source]
|
||||
git = "https://gitlab.redox-os.org/redox-os/rust.git"
|
||||
branch = "redox-2026-05-24"
|
||||
shallow_clone = true
|
||||
|
||||
[build]
|
||||
template = "custom"
|
||||
dependencies = [
|
||||
"llvm21",
|
||||
"zlib",
|
||||
"curl",
|
||||
"openssl3",
|
||||
]
|
||||
dev-dependencies = [
|
||||
"llvm21.dev",
|
||||
"llvm21.runtime",
|
||||
"lld21",
|
||||
]
|
||||
|
||||
script = """
|
||||
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then
|
||||
|
||||
cat ${COOKBOOK_RECIPE}/config-cross.toml > config.toml
|
||||
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_TOOLCHAIN}|g" config.toml
|
||||
sed -i "s|COOKBOOK_TARGET|${COOKBOOK_CROSS_TARGET}|g" config.toml
|
||||
sed -i "s|COOKBOOK_GNU_TARGET|${COOKBOOK_CROSS_GNU_TARGET}|g" config.toml
|
||||
sed -i "s|TARGET|${TARGET}|g" config.toml
|
||||
|
||||
else
|
||||
|
||||
DYNAMIC_INIT
|
||||
# Linker flags for stage2 compiler (host -> target)
|
||||
ARCH="${TARGET%%-*}"
|
||||
export CARGO_TARGET_${ARCH^^}_UNKNOWN_REDOX_RUSTFLAGS="${RUSTFLAGS}" # Rust
|
||||
# Hack for Rust errorneusly running `llvm-config --version` on cross compiled llvm-config
|
||||
cat "${COOKBOOK_ROOT}/bin/${TARGET}-llvm-config" > "${COOKBOOK_SYSROOT}/bin/llvm-config"
|
||||
# Hack for Rust stage1 being dynamically linked with LLVM in prefix toolchain
|
||||
export LD_LIBRARY_PATH="${COOKBOOK_HOST_SYSROOT}/lib:${LD_LIBRARY_PATH}"
|
||||
# Linker flags for stage1 compiler (host -> host)
|
||||
export RUSTFLAGS_BOOTSTRAP="\
|
||||
-Clink-args=-L${COOKBOOK_HOST_SYSROOT}/lib \
|
||||
-Clink-args=-Wl,-rpath-link,${COOKBOOK_HOST_SYSROOT}/lib"
|
||||
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
|
||||
|
||||
cat ${COOKBOOK_RECIPE}/config.toml > config.toml
|
||||
sed -i "s|COOKBOOK_SYSROOT|${COOKBOOK_SYSROOT}|g" config.toml
|
||||
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_HOST_SYSROOT}|g" config.toml
|
||||
sed -i "s|COOKBOOK_TARGET|${TARGET}|g" config.toml
|
||||
sed -i "s|COOKBOOK_GNU_TARGET|${GNU_TARGET}|g" config.toml
|
||||
|
||||
fi
|
||||
|
||||
# Don't poison the stage1 compiler (host -> host)
|
||||
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS CARGO_ENCODED_RUSTFLAGS STRIP
|
||||
|
||||
python3 "${COOKBOOK_SOURCE}/x.py" install \
|
||||
--config config.toml \
|
||||
--jobs ${COOKBOOK_MAKE_JOBS}
|
||||
|
||||
mkdir -p "${COOKBOOK_STAGE}"/usr
|
||||
rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/
|
||||
rm -rf "${COOKBOOK_STAGE}"/usr/lib/rustlib/*.log
|
||||
|
||||
# workaround for rust.lld, needed by e.g. compiling bootloader
|
||||
# https://github.com/rust-lang/rust/issues/143076#issuecomment-3011710678
|
||||
LLD_DIR="${COOKBOOK_STAGE}/usr/lib/rustlib/$TARGET/bin"
|
||||
mkdir -p $LLD_DIR/gcc-ld
|
||||
cp ${COOKBOOK_SYSROOT}/usr/bin/lld $LLD_DIR/rust-lld
|
||||
ln -s rust-lld $LLD_DIR/wasm-component-ld
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld.lld
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld64.lld
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/lld-link
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/wasm-ld
|
||||
ln -s ../../../libLLVM.so.21.1 $LLD_DIR/../lib/libLLVM.so.21.1
|
||||
"""
|
||||
|
||||
[[optional-packages]]
|
||||
name = "doc"
|
||||
files = [
|
||||
"usr/share/doc/**",
|
||||
]
|
||||
[source]
|
||||
git = "https://gitlab.redox-os.org/redox-os/rust.git"
|
||||
branch = "redox-2026-05-24"
|
||||
shallow_clone = true
|
||||
|
||||
[build]
|
||||
template = "custom"
|
||||
dependencies = [
|
||||
"llvm21",
|
||||
"zlib",
|
||||
"curl",
|
||||
"openssl3",
|
||||
]
|
||||
dev-dependencies = [
|
||||
"llvm21.dev",
|
||||
"llvm21.runtime",
|
||||
"lld21",
|
||||
]
|
||||
|
||||
script = """
|
||||
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then
|
||||
|
||||
cat ${COOKBOOK_RECIPE}/config-cross.toml > config.toml
|
||||
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_TOOLCHAIN}|g" config.toml
|
||||
sed -i "s|COOKBOOK_TARGET|${COOKBOOK_CROSS_TARGET}|g" config.toml
|
||||
sed -i "s|COOKBOOK_GNU_TARGET|${COOKBOOK_CROSS_GNU_TARGET}|g" config.toml
|
||||
sed -i "s|TARGET|${TARGET}|g" config.toml
|
||||
|
||||
else
|
||||
|
||||
DYNAMIC_INIT
|
||||
# Linker flags for stage2 compiler (host -> target)
|
||||
ARCH="${TARGET%%-*}"
|
||||
export CARGO_TARGET_${ARCH^^}_UNKNOWN_REDOX_RUSTFLAGS="${RUSTFLAGS}" # Rust
|
||||
# Hack for Rust errorneusly running `llvm-config --version` on cross compiled llvm-config
|
||||
cat "${COOKBOOK_ROOT}/bin/${TARGET}-llvm-config" > "${COOKBOOK_SYSROOT}/bin/llvm-config"
|
||||
# Hack for Rust stage1 being dynamically linked with LLVM in prefix toolchain
|
||||
export LD_LIBRARY_PATH="${COOKBOOK_HOST_SYSROOT}/lib:${LD_LIBRARY_PATH}"
|
||||
# Linker flags for stage1 compiler (host -> host)
|
||||
export RUSTFLAGS_BOOTSTRAP="\
|
||||
-Clink-args=-L${COOKBOOK_HOST_SYSROOT}/lib \
|
||||
-Clink-args=-Wl,-rpath-link,${COOKBOOK_HOST_SYSROOT}/lib"
|
||||
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
|
||||
|
||||
cat ${COOKBOOK_RECIPE}/config.toml > config.toml
|
||||
sed -i "s|COOKBOOK_SYSROOT|${COOKBOOK_SYSROOT}|g" config.toml
|
||||
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_HOST_SYSROOT}|g" config.toml
|
||||
sed -i "s|COOKBOOK_TARGET|${TARGET}|g" config.toml
|
||||
sed -i "s|COOKBOOK_GNU_TARGET|${GNU_TARGET}|g" config.toml
|
||||
|
||||
fi
|
||||
|
||||
# Don't poison the stage1 compiler (host -> host)
|
||||
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS CARGO_ENCODED_RUSTFLAGS STRIP
|
||||
|
||||
SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt" \
|
||||
python3 "${COOKBOOK_SOURCE}/x.py" install \
|
||||
--config config.toml \
|
||||
--jobs ${COOKBOOK_MAKE_JOBS}
|
||||
|
||||
mkdir -p "${COOKBOOK_STAGE}"/usr
|
||||
rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/
|
||||
rm -rf "${COOKBOOK_STAGE}"/usr/lib/rustlib/*.log
|
||||
|
||||
# workaround for rust.lld, needed by e.g. compiling bootloader
|
||||
# https://github.com/rust-lang/rust/issues/143076#issuecomment-3011710678
|
||||
LLD_DIR="${COOKBOOK_STAGE}/usr/lib/rustlib/$TARGET/bin"
|
||||
mkdir -p $LLD_DIR/gcc-ld
|
||||
cp ${COOKBOOK_SYSROOT}/usr/bin/lld $LLD_DIR/rust-lld
|
||||
ln -s rust-lld $LLD_DIR/wasm-component-ld
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld.lld
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld64.lld
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/lld-link
|
||||
ln -s ../rust-lld $LLD_DIR/gcc-ld/wasm-ld
|
||||
ln -s ../../../libLLVM.so.21.1 $LLD_DIR/../lib/libLLVM.so.21.1
|
||||
"""
|
||||
|
||||
[[optional-packages]]
|
||||
name = "doc"
|
||||
files = [
|
||||
"usr/share/doc/**",
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user