mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
minimal-bootstrap: trim static outputs (#522894)
This commit is contained in:
commit
e3b810434b
16 changed files with 145 additions and 45 deletions
|
|
@ -63,6 +63,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--host=${hostPlatform.config} \
|
||||
--without-bash-malloc \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
--enable-static-link \
|
||||
CC=musl-gcc
|
||||
|
||||
|
|
@ -72,5 +73,6 @@ bash.runCommand "${pname}-${version}"
|
|||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm $out/bin/bashbug
|
||||
rm -rf $out/share
|
||||
ln -s $out/bin/bash $out/bin/sh
|
||||
''
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ let
|
|||
"--enable-deterministic-archives"
|
||||
# depends on bison
|
||||
"--disable-gprofng"
|
||||
# unused downstream
|
||||
"--disable-gprof"
|
||||
|
||||
# Turn on --enable-new-dtags by default to make the linker set
|
||||
# RUNPATH instead of RPATH on binaries. This is important because
|
||||
|
|
@ -57,6 +59,8 @@ let
|
|||
# path to force users to declare their use of these libraries.
|
||||
"--with-lib-path=:"
|
||||
"--disable-gold"
|
||||
# unused in the bootstrap path and removed from the output
|
||||
"--disable-libctf"
|
||||
"--disable-plugins"
|
||||
];
|
||||
in
|
||||
|
|
@ -83,6 +87,7 @@ bash.runCommand "${pname}-${version}"
|
|||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
${result}/bin/ld --version
|
||||
${result}/${hostPlatform.config}/bin/ld --version
|
||||
mkdir $out
|
||||
'';
|
||||
}
|
||||
|
|
@ -106,5 +111,17 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# gprof/addr2line/elfedit + man pages are unused downstream.
|
||||
rm -f $out/bin/gprof $out/bin/addr2line $out/bin/elfedit
|
||||
rm -rf $out/share/info $out/share/man
|
||||
rm -rf $out/include $out/lib $out/share
|
||||
|
||||
# The target-prefixed tools duplicate the unprefixed tools byte-for-byte.
|
||||
# Keep the conventional target-prefixed paths, but make them symlinks.
|
||||
targetBin=$out/${hostPlatform.config}/bin
|
||||
if [ -d "$targetBin" ]; then
|
||||
for tool in ar as ld ld.bfd nm objcopy objdump ranlib readelf strip; do
|
||||
if [ -e "$targetBin/$tool" ] && cmp -s "$out/bin/$tool" "$targetBin/$tool"; then
|
||||
rm "$targetBin/$tool"
|
||||
ln -s ../../bin/$tool "$targetBin/$tool"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
''
|
||||
|
|
|
|||
|
|
@ -33,12 +33,28 @@ bash.runCommand "${pname}-${version}"
|
|||
gzip
|
||||
];
|
||||
|
||||
passthru.tests.get-version =
|
||||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
${result}/bin/bzip2 --help
|
||||
mkdir $out
|
||||
'';
|
||||
passthru.tests = {
|
||||
get-version =
|
||||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
${result}/bin/bzip2 --help
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
compress =
|
||||
result:
|
||||
bash.runCommand "${pname}-compress-${version}" { } ''
|
||||
printf 'bootstrap\n' > input
|
||||
${result}/bin/bzip2 -k input
|
||||
${result}/bin/bunzip2 -c input.bz2 > bunzip2-output
|
||||
read -r bunzip2Output < bunzip2-output
|
||||
test "$bunzip2Output" = bootstrap
|
||||
${result}/bin/bzcat input.bz2 > bzcat-output
|
||||
read -r bzcatOutput < bzcat-output
|
||||
test "$bzcatOutput" = bootstrap
|
||||
mkdir $out
|
||||
'';
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "High-quality data compression program";
|
||||
|
|
@ -58,12 +74,15 @@ bash.runCommand "${pname}-${version}"
|
|||
-j $NIX_BUILD_CORES \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static \
|
||||
bzip2 bzip2recover
|
||||
bzip2
|
||||
|
||||
# Install
|
||||
make install -j $NIX_BUILD_CORES PREFIX=$out
|
||||
mkdir -p $out/bin
|
||||
cp bzip2 $out/bin/bzip2
|
||||
ln -s bzip2 $out/bin/bunzip2
|
||||
ln -s bzip2 $out/bin/bzcat
|
||||
|
||||
# Strip
|
||||
# Ignore failures, because strip may fail on non-elf files.
|
||||
find $out/{bin,lib} -type f -exec strip --strip-debug {} + || true
|
||||
strip --strip-debug $out/bin/bzip2 || true
|
||||
''
|
||||
|
|
|
|||
|
|
@ -80,5 +80,5 @@ bash.runCommand "${pname}-${version}"
|
|||
make -j $NIX_BUILD_CORES install-strip
|
||||
|
||||
# Remove documentation not needed in the bootstrap chain.
|
||||
rm -rf $out/share/info $out/share/man
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -369,61 +369,83 @@ lib.makeScope
|
|||
writeTextFile
|
||||
writeText
|
||||
;
|
||||
test = kaem.runCommand "minimal-bootstrap-test" { } (
|
||||
''
|
||||
|
||||
tests = {
|
||||
bootstrap-chain = kaem.runCommand "minimal-bootstrap-bootstrap-chain-test" { } ''
|
||||
echo ${bash.tests.get-version}
|
||||
echo ${bash-static.tests.get-version}
|
||||
echo ${bash_2_05.tests.get-version}
|
||||
echo ${binutils.tests.get-version}
|
||||
echo ${binutils-static.tests.get-version}
|
||||
echo ${bison.tests.get-version}
|
||||
echo ${bzip2.tests.get-version}
|
||||
echo ${bzip2-static.tests.get-version}
|
||||
echo ${coreutils-musl.tests.get-version}
|
||||
echo ${coreutils-static.tests.get-version}
|
||||
echo ${diffutils.tests.get-version}
|
||||
echo ${diffutils-static.tests.get-version}
|
||||
echo ${findutils.tests.get-version}
|
||||
echo ${findutils-static.tests.get-version}
|
||||
echo ${gawk.tests.get-version}
|
||||
echo ${gawk-mes.tests.get-version}
|
||||
echo ${gawk-static.tests.get-version}
|
||||
echo ${gcc46.tests.get-version}
|
||||
echo ${gcc46-cxx.tests.hello-world}
|
||||
echo ${gcc10.tests.hello-world}
|
||||
echo ${gcc-latest.tests.hello-world}
|
||||
echo ${gnugrep.tests.get-version}
|
||||
echo ${gnugrep-static.tests.get-version}
|
||||
echo ${gnum4.tests.get-version}
|
||||
echo ${gnumake-musl.tests.get-version}
|
||||
echo ${gnumake-static.tests.get-version}
|
||||
echo ${gnupatch-static.tests.get-version}
|
||||
echo ${gnused.tests.get-version}
|
||||
echo ${gnused-mes.tests.get-version}
|
||||
echo ${gnused-static.tests.get-version}
|
||||
echo ${gnutar.tests.get-version}
|
||||
echo ${gnutar-latest.tests.get-version}
|
||||
echo ${gnutar-musl.tests.get-version}
|
||||
echo ${gnutar-static.tests.get-version}
|
||||
echo ${gzip.tests.get-version}
|
||||
echo ${gzip-static.tests.get-version}
|
||||
echo ${heirloom.tests.get-version}
|
||||
echo ${mes.compiler.tests.get-version}
|
||||
echo ${musl.tests.hello-world}
|
||||
echo ${patchelf-static.tests.get-version}
|
||||
echo ${python.tests.get-version}
|
||||
echo ${tinycc-mes.compiler.tests.chain}
|
||||
echo ${tinycc-musl.compiler.tests.hello-world}
|
||||
echo ${xz.tests.get-version}
|
||||
''
|
||||
+ (lib.strings.optionalString (hostPlatform.libc == "glibc") ''
|
||||
echo ${gcc-glibc.tests.hello-world}
|
||||
echo ${glibc.tests.hello-world}
|
||||
'')
|
||||
+ ''
|
||||
mkdir ''${out}
|
||||
''
|
||||
);
|
||||
'';
|
||||
|
||||
static-tools = kaem.runCommand "minimal-bootstrap-static-tools-test" { } ''
|
||||
echo ${bash-static.tests.get-version}
|
||||
echo ${binutils-static.tests.get-version}
|
||||
echo ${bzip2-static.tests.get-version}
|
||||
echo ${bzip2-static.tests.compress}
|
||||
echo ${coreutils-static.tests.get-version}
|
||||
echo ${diffutils-static.tests.get-version}
|
||||
echo ${findutils-static.tests.get-version}
|
||||
echo ${gawk-static.tests.get-version}
|
||||
echo ${gnugrep-static.tests.get-version}
|
||||
echo ${gnumake-static.tests.get-version}
|
||||
echo ${gnupatch-static.tests.get-version}
|
||||
echo ${gnused-static.tests.get-version}
|
||||
echo ${gnutar-static.tests.get-version}
|
||||
echo ${gzip-static.tests.get-version}
|
||||
echo ${patchelf-static.tests.get-version}
|
||||
echo ${xz-static.tests.get-version}
|
||||
mkdir ''${out}
|
||||
'';
|
||||
|
||||
compiler = kaem.runCommand "minimal-bootstrap-compiler-test" { } (
|
||||
''
|
||||
echo ${gcc46.tests.get-version}
|
||||
echo ${gcc46-cxx.tests.hello-world}
|
||||
echo ${gcc10.tests.hello-world}
|
||||
echo ${gcc-latest.tests.hello-world}
|
||||
''
|
||||
+ (lib.strings.optionalString (hostPlatform.libc == "glibc") ''
|
||||
echo ${gcc-glibc.tests.hello-world}
|
||||
echo ${glibc.tests.hello-world}
|
||||
'')
|
||||
+ ''
|
||||
mkdir ''${out}
|
||||
''
|
||||
);
|
||||
|
||||
full = kaem.runCommand "minimal-bootstrap-test" { } ''
|
||||
echo ${tests.bootstrap-chain}
|
||||
echo ${tests.static-tools}
|
||||
echo ${tests.compiler}
|
||||
mkdir ''${out}
|
||||
'';
|
||||
};
|
||||
|
||||
test = tests.full;
|
||||
}
|
||||
// (lib.optionalAttrs (hostPlatform.libc == "glibc")) {
|
||||
gcc-glibc = callPackage ./gcc/glibc.nix {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static \
|
||||
ac_cv_path_PR_PROGRAM=pr
|
||||
|
|
@ -78,4 +79,7 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
|
||||
# Remove documentation not needed in the bootstrap chain.
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ bash.runCommand "${pname}-${version}"
|
|||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
${result}/bin/find --version
|
||||
${result}/bin/xargs --version
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
|
|
@ -69,6 +70,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static
|
||||
|
||||
|
|
@ -77,5 +79,8 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm $out/bin/updatedb
|
||||
|
||||
# Keep only the bootstrap-relevant find/xargs tools.
|
||||
rm -f $out/bin/locate $out/bin/updatedb
|
||||
rm -rf $out/libexec $out/share $out/var
|
||||
''
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ bash.runCommand "${pname}-${version}"
|
|||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
${result}/bin/awk --version
|
||||
${result}/bin/awk 'BEGIN { if (2 + 2 != 4) exit 1 }'
|
||||
mkdir $out
|
||||
'';
|
||||
}
|
||||
|
|
@ -62,6 +63,10 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-extensions \
|
||||
--disable-mpfr \
|
||||
--disable-nls \
|
||||
--disable-pma \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static
|
||||
|
||||
|
|
@ -71,4 +76,6 @@ bash.runCommand "${pname}-${version}"
|
|||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm $out/bin/gawkbug
|
||||
rm -rf $out/etc $out/include $out/lib $out/libexec
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static
|
||||
|
||||
|
|
@ -79,4 +80,7 @@ bash.runCommand "${pname}-${version}"
|
|||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm $out/bin/{egrep,fgrep}
|
||||
|
||||
# Remove documentation not needed in the bootstrap chain.
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
CC=musl-gcc \
|
||||
CFLAGS="-static -std=gnu17"
|
||||
|
||||
|
|
@ -87,4 +88,7 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
|
||||
# Remove files not needed to execute make in the bootstrap chain.
|
||||
rm -rf $out/include $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -78,4 +78,5 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static
|
||||
|
||||
|
|
@ -70,4 +71,5 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ bash.runCommand "${pname}-${version}"
|
|||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-nls \
|
||||
CC=musl-gcc \
|
||||
CFLAGS=-static
|
||||
|
||||
|
|
@ -70,4 +71,5 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm -rf $out/libexec $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -77,4 +77,5 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES bin_SCRIPTS= install-strip
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ bash.runCommand "${pname}-${version}"
|
|||
gzip
|
||||
];
|
||||
|
||||
disallowedReferences = [ gcc ];
|
||||
|
||||
passthru.tests.get-version =
|
||||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
|
|
@ -70,11 +72,12 @@ bash.runCommand "${pname}-${version}"
|
|||
--host=${hostPlatform.config} \
|
||||
--disable-dependency-tracking \
|
||||
CC=musl-gcc \
|
||||
CXXFLAGS=-static
|
||||
CXXFLAGS="-static -g0 -O2 -DNDEBUG -ffile-prefix-map=${gcc}=. -fmacro-prefix-map=${gcc}=."
|
||||
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm -rf $out/share
|
||||
''
|
||||
|
|
|
|||
|
|
@ -39,10 +39,12 @@ bash.runCommand "${pname}-${version}"
|
|||
gzip
|
||||
];
|
||||
|
||||
disallowedReferences = [ musl ];
|
||||
|
||||
passthru.tests.get-version =
|
||||
result:
|
||||
bash.runCommand "${pname}-get-version-${version}" { } ''
|
||||
${lib.getExe result} --version
|
||||
${result}/bin/xz --version
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
|
|
@ -65,8 +67,8 @@ bash.runCommand "${pname}-${version}"
|
|||
|
||||
# Configure
|
||||
export CC=musl-gcc
|
||||
export CFLAGS=-static
|
||||
export CXXFLAGS=-static
|
||||
export CFLAGS="-g0 -O2 -DNDEBUG"
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
export LDFLAGS=-static
|
||||
bash ./configure \
|
||||
--prefix=$out \
|
||||
|
|
@ -78,11 +80,16 @@ bash.runCommand "${pname}-${version}"
|
|||
--disable-nls \
|
||||
--disable-shared \
|
||||
--disable-scripts \
|
||||
--disable-doc \
|
||||
--disable-xzdec \
|
||||
--disable-lzmadec \
|
||||
--disable-lzmainfo \
|
||||
--disable-assembler
|
||||
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
make -j $NIX_BUILD_CORES LDFLAGS=-all-static
|
||||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
rm -rf $out/include $out/lib $out/share
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue