2021-04-19 18:44:10 +00:00
|
|
|
{ pkgspath ? ../../.., test-pkgspath ? pkgspath
|
stdenvBootstrapTools: inherit {cross,local}System
It's expected that attributes in the top-level package set will all use
that package set, but this wasn't the case for the bootstrap tools.
This led some very confusing behaviour:
- pkgsMusl.stdenvBootstrapTools would build glibc bootstrap tools
- stdenvBootstrapTools was _always_ cross compiled, even if
Nixpkgs wasn't, because it always set crossSystem. This also didn't
match the behaviour of using make-bootstrap-tools.nix as an
entrypoint, where crossSystem would default to null.
For the Linux stdenv, I've made the ideal fix, which is to make pkgs an
argument rather than taking the arguments for pkgs, and then
re-importing it. This means it'll always use exactly the same package
set that's calling it, and should also mean faster eval due to not
importing Nixpkgs twice.
The Darwin stdenv is more complicated, and I'm not able to easily test
it, so I wasn't confident in making the same fix there. Instead, I've
just made sure crossSystem and localSystem are set to the correct values
so they're not always cross compiled and match the parent package set's.
It would still be preferable if somebody could make Darwin's
make-bootstrap-tools.nix take pkgs as an argument, rather than all the
arguments for pkgs.
2022-05-30 14:16:22 +00:00
|
|
|
, localSystem ? { system = builtins.currentSystem; }
|
|
|
|
, crossSystem ? null
|
|
|
|
, bootstrapFiles ? null
|
2021-04-19 18:44:10 +00:00
|
|
|
}:
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2021-04-19 18:44:10 +00:00
|
|
|
let cross = if crossSystem != null
|
|
|
|
then { inherit crossSystem; }
|
|
|
|
else {};
|
|
|
|
custom-bootstrap = if bootstrapFiles != null
|
|
|
|
then { stdenvStages = args:
|
|
|
|
let args' = args // { bootstrapFiles = bootstrapFiles; };
|
2023-07-15 11:24:51 +00:00
|
|
|
in (import "${pkgspath}/pkgs/stdenv/darwin" args');
|
2021-04-19 18:44:10 +00:00
|
|
|
}
|
|
|
|
else {};
|
2024-03-19 14:45:11 +00:00
|
|
|
in with import pkgspath ({ inherit localSystem; } // cross // custom-bootstrap);
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2023-11-12 13:52:30 +00:00
|
|
|
rec {
|
2015-02-18 05:24:16 +00:00
|
|
|
build = stdenv.mkDerivation {
|
2015-10-23 11:04:10 +00:00
|
|
|
name = "stdenv-bootstrap-tools";
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
nativeBuildInputs = [ dumpnar nukeReferences ];
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
buildCommand = let
|
|
|
|
inherit (lib)
|
|
|
|
getBin
|
|
|
|
getDev
|
|
|
|
getLib
|
|
|
|
;
|
2024-03-11 23:02:27 +00:00
|
|
|
|
|
|
|
coreutils_ = (coreutils.override (args: {
|
|
|
|
# We want coreutils without ACL support.
|
|
|
|
aclSupport = false;
|
|
|
|
# Cannot use a single binary build, or it gets dynamically linked against gmp.
|
|
|
|
singleBinary = false;
|
|
|
|
})).overrideAttrs (oa: {
|
|
|
|
# Increase header size to be able to inject extra RPATHs. Otherwise
|
|
|
|
# x86_64-darwin build fails as:
|
|
|
|
# https://cache.nixos.org/log/g5wyq9xqshan6m3kl21bjn1z88hx48rh-stdenv-bootstrap-tools.drv
|
|
|
|
NIX_LDFLAGS = (oa.NIX_LDFLAGS or "") + " -headerpad_max_install_names";
|
|
|
|
});
|
|
|
|
|
|
|
|
cctools_ = darwin.cctools;
|
|
|
|
|
|
|
|
# Avoid messing with libkrb5 and libnghttp2.
|
|
|
|
curl_ = curlMinimal.override (args: {
|
|
|
|
gssSupport = false;
|
|
|
|
http2Support = false;
|
|
|
|
scpSupport = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
gnutar_ = (gnutar.override { libintl = null; }).overrideAttrs (old: {
|
|
|
|
configureFlags = [
|
|
|
|
"--disable-nls"
|
|
|
|
] ++ old.configureFlags or [];
|
|
|
|
});
|
|
|
|
|
|
|
|
xz_ = xz.override { enableStatic = true; };
|
2024-03-18 12:56:20 +00:00
|
|
|
|
|
|
|
unpackScript = writeText "bootstrap-tools-unpack.sh" ''
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
echo Unpacking the bootstrap tools... >&2
|
|
|
|
mkdir $out
|
|
|
|
tar xf "$1" -C $out
|
|
|
|
|
|
|
|
updateInstallName() {
|
|
|
|
local path="$1"
|
|
|
|
|
|
|
|
cp "$path" "$path.new"
|
|
|
|
install_name_tool -id "$path" "$path.new"
|
|
|
|
codesign -f -i "$(basename "$path")" -s - "$path.new"
|
|
|
|
mv -f "$path.new" "$path"
|
|
|
|
}
|
|
|
|
|
|
|
|
find $out/lib -type f -name '*.dylib' -print0 | while IFS= read -r -d $'\0' lib; do
|
|
|
|
updateInstallName "$lib"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Provide a gunzip script.
|
|
|
|
cat > $out/bin/gunzip <<EOF
|
|
|
|
#!$out/bin/sh
|
|
|
|
exec $out/bin/gzip -d "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/gunzip
|
|
|
|
|
|
|
|
# Provide fgrep/egrep.
|
|
|
|
echo "#! $out/bin/sh" > $out/bin/egrep
|
|
|
|
echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
|
|
|
|
echo "#! $out/bin/sh" > $out/bin/fgrep
|
|
|
|
echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
|
|
|
|
|
|
|
|
cat >$out/bin/dsymutil << EOF
|
|
|
|
#!$out/bin/sh
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil
|
|
|
|
'';
|
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
in
|
|
|
|
''
|
2020-11-19 08:28:00 +00:00
|
|
|
mkdir -p $out/bin $out/lib $out/lib/system $out/lib/darwin
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2020-11-19 08:28:00 +00:00
|
|
|
${lib.optionalString stdenv.targetPlatform.isx86_64 ''
|
|
|
|
# Copy libSystem's .o files for various low-level boot stuff.
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getLib darwin.Libsystem}/lib/*.o $out/lib
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2020-11-19 08:28:00 +00:00
|
|
|
# Resolv is actually a link to another package, so let's copy it properly
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -L ${getLib darwin.Libsystem}/lib/libresolv.9.dylib $out/lib
|
2020-11-19 08:28:00 +00:00
|
|
|
''}
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -rL ${getDev darwin.Libsystem}/include $out
|
2023-01-01 19:24:02 +00:00
|
|
|
chmod -R u+w $out/include
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -rL ${getDev libiconv}/include/* $out/include
|
|
|
|
cp -rL ${getDev gnugrep.pcre2}/include/* $out/include
|
2023-01-01 19:24:02 +00:00
|
|
|
mv $out/include $out/include-Libsystem
|
|
|
|
|
2015-02-18 05:24:16 +00:00
|
|
|
# Copy coreutils, bash, etc.
|
2024-03-11 14:21:34 +00:00
|
|
|
cp ${getBin coreutils_}/bin/* $out/bin
|
2015-02-18 05:24:16 +00:00
|
|
|
(cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
|
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
cp ${getBin bash}/bin/bash $out/bin
|
2023-01-01 19:24:02 +00:00
|
|
|
ln -s bash $out/bin/sh
|
2024-03-11 14:21:34 +00:00
|
|
|
cp ${getBin findutils}/bin/find $out/bin
|
|
|
|
cp ${getBin findutils}/bin/xargs $out/bin
|
|
|
|
cp -d ${getBin diffutils}/bin/* $out/bin
|
|
|
|
cp -d ${getBin gnused}/bin/* $out/bin
|
|
|
|
cp -d ${getBin gnugrep}/bin/grep $out/bin
|
|
|
|
cp ${getBin gawk}/bin/gawk $out/bin
|
|
|
|
cp -d ${getBin gawk}/bin/awk $out/bin
|
|
|
|
cp ${getBin gnutar}/bin/tar $out/bin
|
|
|
|
cp ${getBin gzip}/bin/.gzip-wrapped $out/bin/gzip
|
2024-03-11 23:02:27 +00:00
|
|
|
cp ${getBin bzip2}/bin/bzip2 $out/bin
|
2023-01-01 19:24:02 +00:00
|
|
|
ln -s bzip2 $out/bin/bunzip2
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getBin gnumake}/bin/* $out/bin
|
|
|
|
cp -d ${getBin patch}/bin/* $out/bin
|
|
|
|
cp -d ${getBin xz}/bin/xz $out/bin
|
|
|
|
cp ${getBin cpio}/bin/cpio $out/bin
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
# This used to be in-nixpkgs, but now is in the bundle
|
|
|
|
# because I can't be bothered to make it partially static
|
2024-03-11 14:21:34 +00:00
|
|
|
cp ${getBin curl_}/bin/curl $out/bin
|
|
|
|
cp -d ${getLib curl_}/lib/libcurl*.dylib $out/lib
|
|
|
|
cp -d ${getLib openssl}/lib/*.dylib $out/lib
|
|
|
|
|
|
|
|
cp -d ${getLib gnugrep.pcre2}/lib/libpcre2*.dylib $out/lib
|
|
|
|
cp -d ${getLib libiconv}/lib/lib*.dylib $out/lib
|
|
|
|
cp -d ${getLib gettext}/lib/libintl*.dylib $out/lib
|
2015-06-18 17:03:32 +00:00
|
|
|
chmod +x $out/lib/libintl*.dylib
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getLib ncurses}/lib/libncurses*.dylib $out/lib
|
|
|
|
cp -d ${getLib libxml2}/lib/libxml2*.dylib $out/lib
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
# Copy what we need of clang
|
2024-03-11 23:02:27 +00:00
|
|
|
cp -d ${getBin llvmPackages.clang-unwrapped}/bin/clang{,++,-cl,-cpp,-[0-9]*} $out/bin
|
|
|
|
cp -d ${getLib llvmPackages.clang-unwrapped}/lib/libclang-cpp*.dylib $out/lib
|
|
|
|
cp -rd ${getLib llvmPackages.clang-unwrapped}/lib/clang $out/lib
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getLib llvmPackages.libcxx}/lib/libc++*.dylib $out/lib
|
2024-03-11 23:02:27 +00:00
|
|
|
mkdir -p $out/lib/darwin
|
|
|
|
cp -d ${getLib llvmPackages.compiler-rt}/lib/darwin/libclang_rt.{,profile_}osx.a $out/lib/darwin
|
|
|
|
cp -d ${getLib llvmPackages.compiler-rt}/lib/libclang_rt.{,profile_}osx.a $out/lib
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getLib llvmPackages.llvm}/lib/libLLVM.dylib $out/lib
|
|
|
|
cp -d ${getLib libffi}/lib/libffi*.dylib $out/lib
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
mkdir $out/include
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -rd ${getDev llvmPackages.libcxx}/include/c++ $out/include
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2022-07-15 01:07:28 +00:00
|
|
|
# copy .tbd assembly utils
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getBin pkgs.darwin.rewrite-tbd}/bin/rewrite-tbd $out/bin
|
|
|
|
cp -d ${getLib pkgs.libyaml}/lib/libyaml*.dylib $out/lib
|
2020-11-19 08:28:00 +00:00
|
|
|
|
2022-07-15 01:07:28 +00:00
|
|
|
# copy package extraction tools
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getBin pkgs.pbzx}/bin/pbzx $out/bin
|
|
|
|
cp -d ${getLib pkgs.xar}/lib/libxar*.dylib $out/lib
|
|
|
|
cp -d ${getLib pkgs.bzip2}/lib/libbz2*.dylib $out/lib
|
2020-11-19 08:28:00 +00:00
|
|
|
|
2023-01-01 19:24:02 +00:00
|
|
|
# copy sigtool
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getBin pkgs.darwin.sigtool}/bin/sigtool $out/bin
|
|
|
|
cp -d ${getBin pkgs.darwin.sigtool}/bin/codesign $out/bin
|
2020-11-19 08:28:00 +00:00
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getLib zlib}/lib/libz.* $out/lib
|
|
|
|
cp -d ${getLib gmpxx}/lib/libgmp*.* $out/lib
|
|
|
|
cp -d ${getLib xz}/lib/liblzma*.* $out/lib
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
# Copy binutils.
|
2020-11-19 08:28:00 +00:00
|
|
|
for i in as ld ar ranlib nm strip otool install_name_tool lipo codesign_allocate; do
|
2024-03-11 14:21:34 +00:00
|
|
|
cp ${getBin cctools_}/bin/$i $out/bin
|
2015-02-18 05:24:16 +00:00
|
|
|
done
|
|
|
|
|
2024-03-11 14:21:34 +00:00
|
|
|
cp -d ${getLib darwin.libtapi}/lib/libtapi* $out/lib
|
2020-07-25 06:26:54 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
# tools needed to unpack bootstrap archive. they should not contain any
|
|
|
|
# external references. we will process them like the other tools but
|
|
|
|
# perform some additional checks and will not pack them into the archive.
|
|
|
|
mkdir -p unpack/bin
|
|
|
|
cp ${getBin bash}/bin/bash unpack/bin
|
|
|
|
ln -s bash unpack/bin/sh
|
|
|
|
cp ${getBin coreutils_}/bin/mkdir unpack/bin
|
|
|
|
cp ${getBin gnutar_}/bin/tar unpack/bin
|
|
|
|
cp ${getBin xz_}/bin/xz unpack/bin
|
2024-03-18 12:56:20 +00:00
|
|
|
cp ${unpackScript} unpack/bootstrap-tools-unpack.sh
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
#
|
|
|
|
# All files copied. Perform processing to update references to point into
|
|
|
|
# the archive
|
|
|
|
#
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
chmod -R u+w $out unpack
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
# - change nix store library paths to use @rpath/library
|
|
|
|
# - if needed add an rpath containing lib/
|
|
|
|
# - strip executable
|
2015-02-18 05:24:16 +00:00
|
|
|
rpathify() {
|
2024-03-11 23:02:27 +00:00
|
|
|
local libs=$(${stdenv.cc.targetPrefix}otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*" || true)
|
|
|
|
local lib rpath
|
2015-02-18 05:24:16 +00:00
|
|
|
for lib in $libs; do
|
2021-05-24 05:15:09 +00:00
|
|
|
${stdenv.cc.targetPrefix}install_name_tool -change $lib "@rpath/$(basename "$lib")" "$1"
|
2015-02-18 05:24:16 +00:00
|
|
|
done
|
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
case "$(dirname "$1")" in
|
|
|
|
*/bin)
|
|
|
|
# Strip executables even further
|
|
|
|
${stdenv.cc.targetPrefix}strip "$i"
|
|
|
|
rpath='@executable_path/../lib'
|
|
|
|
;;
|
|
|
|
*/lib)
|
|
|
|
# the '/.' suffix is required
|
|
|
|
rpath='@loader_path/.'
|
|
|
|
;;
|
|
|
|
*/lib/darwin)
|
|
|
|
rpath='@loader_path/..'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo unkown executable $1 >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# if shared object contains references add an rpath to lib/
|
|
|
|
if ${stdenv.cc.targetPrefix}otool -l "$1"| grep -q '@rpath/'; then
|
|
|
|
${stdenv.cc.targetPrefix}install_name_tool -add_rpath "$rpath" "$1"
|
2015-02-18 05:24:16 +00:00
|
|
|
fi
|
2024-03-11 23:02:27 +00:00
|
|
|
}
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
# check that linked library paths exist in $out/lib
|
|
|
|
# must be run after rpathify is performed
|
|
|
|
checkDeps() {
|
|
|
|
local deps=$(${stdenv.cc.targetPrefix}otool -l "$1"| grep -o '@rpath/[^ ]*' || true)
|
|
|
|
local lib
|
|
|
|
for lib in $deps; do
|
|
|
|
if [[ ! -e $out/''${lib/@rpath/lib} ]]; then
|
|
|
|
echo "error: $1 missing lib for $lib" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
for i in $out/bin/* unpack/bin/* $out/lib{,/darwin}/*.dylib; do
|
|
|
|
if [[ ! -L $i ]] && isMachO "$i"; then
|
|
|
|
rpathify "$i"
|
|
|
|
checkDeps "$i"
|
2020-11-19 08:28:00 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
nuke-refs $out/bin/*
|
2015-02-18 05:24:16 +00:00
|
|
|
nuke-refs $out/lib/*
|
2020-11-19 08:28:00 +00:00
|
|
|
nuke-refs $out/lib/darwin/*
|
2024-03-11 23:02:27 +00:00
|
|
|
nuke-refs $out/lib/system/*
|
|
|
|
nuke-refs unpack/bin/*
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
mkdir $out/.pack
|
|
|
|
mv $out/* $out/.pack
|
|
|
|
mv $out/.pack $out/pack
|
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
# validate that tools contain no references into the archive
|
|
|
|
for tool in unpack/bin/*; do
|
|
|
|
deps=$(${stdenv.cc.targetPrefix}otool -l "$tool"| grep '@rpath/' || true)
|
|
|
|
if [[ -n "$deps" ]]; then
|
|
|
|
printf "error: $tool is not self contained\n$deps\n" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-02-18 05:24:16 +00:00
|
|
|
mkdir $out/on-server
|
2024-03-11 23:02:27 +00:00
|
|
|
cp -r unpack $out
|
|
|
|
|
|
|
|
XZ_OPT="-9 -T $NIX_BUILD_CORES" tar cvJf $out/on-server/bootstrap-tools.tar.xz \
|
|
|
|
--hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 -C $out/pack .
|
|
|
|
dumpnar $out/unpack | xz -9 -T $NIX_BUILD_CORES > $out/on-server/unpack.nar.xz
|
2015-02-18 05:24:16 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
allowedReferences = [];
|
2015-12-28 21:59:24 +00:00
|
|
|
|
|
|
|
meta = {
|
2021-01-15 07:11:03 +00:00
|
|
|
maintainers = [ lib.maintainers.copumpkin ];
|
2015-12-28 21:59:24 +00:00
|
|
|
};
|
2015-02-18 05:24:16 +00:00
|
|
|
};
|
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
dist = runCommand "stdenv-bootstrap-tools" {} ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "file tarball ${build}/on-server/*.tar.xz" >> $out/nix-support/hydra-build-products
|
|
|
|
echo "file unpack ${build}/on-server/unpack.* " >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2016-01-04 02:47:09 +00:00
|
|
|
bootstrapFiles = {
|
2024-03-11 23:02:27 +00:00
|
|
|
bootstrapTools = "${build}/on-server/bootstrap-tools.tar.xz";
|
|
|
|
unpack = runCommand "unpack" { allowedReferences = []; } ''
|
|
|
|
cp -r ${build}/unpack $out
|
|
|
|
'';
|
2015-02-18 05:24:16 +00:00
|
|
|
};
|
|
|
|
|
2023-01-01 19:24:02 +00:00
|
|
|
bootstrapTools = derivation {
|
release.nix: namespace bootstrap tools with triples
This will allow buliding bootstrap tools for platforms with
non-default libcs, like *-unknown-linux-musl.
This gets rid of limitedSupportSystems/systemsWithAnySupport. There
was no need to use systemsWithAnySupport for supportDarwin, because it
was always equivalent to supportedSystems for that purpose, and the
only other way it was used was for determining which platforms to
build the bootstrap tools for, so we might as well use a more explicit
parameter for that, and then we can change how it works without
affecting the rest of the Hydra jobs.
Not affecting the rest of the Hydra jobs is important, because if we
changed all jobs to use config triples, we'd end up renaming every
Hydra job. That might still be worth thinking about at some point,
but it's unnecessary at this point (and would be a lot of work).
I've checked by running
nix-eval-jobs --force-recurse pkgs/top-level/release.nix
that the actual bootstrap tools derivations are unaffected by this
change, and that the only other jobs that change are ones that depend
on the hash of all of Nixpkgs. Of the other jobset entrypoints that
end up importing pkgs/top-level/release.nix, none used the
limitedSupportedSystems parameter, so they should all be unaffected as
well.
2023-10-07 15:48:15 +00:00
|
|
|
inherit (stdenv.hostPlatform) system;
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2023-01-01 19:24:02 +00:00
|
|
|
name = "bootstrap-tools";
|
2024-03-11 23:02:27 +00:00
|
|
|
builder = "${bootstrapFiles.unpack}/bin/bash";
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-18 12:56:20 +00:00
|
|
|
args = [
|
|
|
|
"${bootstrapFiles.unpack}/bootstrap-tools-unpack.sh"
|
|
|
|
bootstrapFiles.bootstrapTools
|
|
|
|
];
|
|
|
|
|
|
|
|
PATH = lib.makeBinPath [
|
|
|
|
(placeholder "out")
|
|
|
|
bootstrapFiles.unpack
|
|
|
|
];
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
allowedReferences = [ "out" ];
|
2023-01-01 19:24:02 +00:00
|
|
|
};
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
test = derivation {
|
|
|
|
name = "test-bootstrap-tools";
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
builder = "${bootstrapTools}/bin/bash";
|
|
|
|
args = [ "-euo" "pipefail" "-c" "eval \"$buildCommand\"" ];
|
|
|
|
PATH = lib.makeBinPath [ bootstrapTools ];
|
2023-01-01 19:24:02 +00:00
|
|
|
tools = bootstrapTools;
|
2024-03-11 23:02:27 +00:00
|
|
|
"${stdenv.cc.darwinMinVersionVariable}" = stdenv.cc.darwinMinVersion;
|
|
|
|
|
|
|
|
# Create a pure environment where we use just what's in the bootstrap tools.
|
2015-02-18 05:24:16 +00:00
|
|
|
buildCommand = ''
|
2023-01-01 19:24:02 +00:00
|
|
|
|
2015-02-18 05:24:16 +00:00
|
|
|
ls -l
|
|
|
|
mkdir $out
|
|
|
|
mkdir $out/bin
|
|
|
|
sed --version
|
|
|
|
find --version
|
|
|
|
diff --version
|
|
|
|
patch --version
|
|
|
|
make --version
|
|
|
|
awk --version
|
|
|
|
grep --version
|
|
|
|
clang --version
|
|
|
|
xz --version
|
|
|
|
|
|
|
|
# The grep will return a nonzero exit code if there is no match, and we want to assert that we have
|
|
|
|
# an SSL-capable curl
|
|
|
|
curl --version | grep SSL
|
|
|
|
|
2020-09-09 00:50:35 +00:00
|
|
|
# This approximates a bootstrap version of libSystem can that be
|
|
|
|
# assembled via fetchurl. Adapted from main libSystem expression.
|
|
|
|
mkdir libSystem-boot
|
|
|
|
cp -vr \
|
2023-01-01 19:24:02 +00:00
|
|
|
${stdenv.cc.libc_dev}/lib/libSystem.B.tbd \
|
|
|
|
${stdenv.cc.libc_dev}/lib/system \
|
2020-09-09 00:50:35 +00:00
|
|
|
libSystem-boot
|
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
sed -i "s|/usr/lib/system/|$PWD/libSystem-boot/system/|g" libSystem-boot/libSystem.B.tbd
|
2020-09-09 00:50:35 +00:00
|
|
|
ln -s libSystem.B.tbd libSystem-boot/libSystem.tbd
|
|
|
|
# End of bootstrap libSystem
|
|
|
|
|
2023-01-01 19:24:02 +00:00
|
|
|
export flags="-idirafter $tools/include-Libsystem --sysroot=$tools -L$tools/lib -L$PWD/libSystem-boot"
|
2015-02-18 05:24:16 +00:00
|
|
|
|
|
|
|
export CPP="clang -E $flags"
|
2024-03-11 23:02:27 +00:00
|
|
|
export CC="clang $flags"
|
|
|
|
export CXX="clang++ $flags --stdlib=libc++ -isystem$tools/include/c++/v1"
|
2023-01-01 19:24:02 +00:00
|
|
|
|
|
|
|
# NOTE: These tests do a separate 'install' step (using cp), because
|
|
|
|
# having clang write directly to the final location apparently will make
|
|
|
|
# running the executable fail signature verification. (SIGKILL'd)
|
|
|
|
#
|
|
|
|
# Suspect this is creating a corrupt entry in the kernel cache, but it is
|
|
|
|
# unique to cctools ld. (The problem goes away with `-fuse-ld=lld`.)
|
|
|
|
|
|
|
|
echo '#include <stdio.h>' >> hello1.c
|
|
|
|
echo '#include <float.h>' >> hello1.c
|
|
|
|
echo '#include <limits.h>' >> hello1.c
|
|
|
|
echo 'int main() { printf("Hello World\n"); return 0; }' >> hello1.c
|
|
|
|
$CC -o hello1 hello1.c
|
|
|
|
cp hello1 $out/bin/
|
|
|
|
$out/bin/hello1
|
|
|
|
|
|
|
|
echo '#include <iostream>' >> hello3.cc
|
|
|
|
echo 'int main() { std::cout << "Hello World\n"; }' >> hello3.cc
|
|
|
|
$CXX -v -o hello3 hello3.cc
|
|
|
|
cp hello3 $out/bin/
|
|
|
|
$out/bin/hello3
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-03-11 23:02:27 +00:00
|
|
|
# test that libc++.dylib rpaths are correct so it can reference libc++abi.dylib when linked.
|
|
|
|
# using -Wl,-flat_namespace is required to generate an error
|
|
|
|
mkdir libtest/
|
|
|
|
ln -s $tools/lib/libc++.dylib libtest/
|
|
|
|
clang++ -Wl,-flat_namespace -idirafter $tools/include-Libsystem -isystem$tools/include/c++/v1 \
|
|
|
|
--sysroot=$tools -L./libtest -L$PWD/libSystem-boot hello3.cc
|
|
|
|
|
2015-02-18 05:24:16 +00:00
|
|
|
tar xvf ${hello.src}
|
|
|
|
cd hello-*
|
2024-03-11 23:02:27 +00:00
|
|
|
# hello configure detects -liconv is needed but doesn't add to the link step
|
|
|
|
LDFLAGS=-liconv ./configure --prefix=$out
|
2015-02-18 05:24:16 +00:00
|
|
|
make
|
|
|
|
make install
|
|
|
|
$out/bin/hello
|
|
|
|
'';
|
|
|
|
};
|
2016-01-04 02:47:09 +00:00
|
|
|
|
|
|
|
# The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
|
2024-03-20 16:28:21 +00:00
|
|
|
# eg: nix-build -A freshBootstrapTools.test-pkgs.stdenv
|
2016-12-04 01:21:07 +00:00
|
|
|
test-pkgs = import test-pkgspath {
|
2020-11-19 08:28:00 +00:00
|
|
|
# if the bootstrap tools are for another platform, we should be testing
|
|
|
|
# that platform.
|
stdenvBootstrapTools: inherit {cross,local}System
It's expected that attributes in the top-level package set will all use
that package set, but this wasn't the case for the bootstrap tools.
This led some very confusing behaviour:
- pkgsMusl.stdenvBootstrapTools would build glibc bootstrap tools
- stdenvBootstrapTools was _always_ cross compiled, even if
Nixpkgs wasn't, because it always set crossSystem. This also didn't
match the behaviour of using make-bootstrap-tools.nix as an
entrypoint, where crossSystem would default to null.
For the Linux stdenv, I've made the ideal fix, which is to make pkgs an
argument rather than taking the arguments for pkgs, and then
re-importing it. This means it'll always use exactly the same package
set that's calling it, and should also mean faster eval due to not
importing Nixpkgs twice.
The Darwin stdenv is more complicated, and I'm not able to easily test
it, so I wasn't confident in making the same fix there. Instead, I've
just made sure crossSystem and localSystem are set to the correct values
so they're not always cross compiled and match the parent package set's.
It would still be preferable if somebody could make Darwin's
make-bootstrap-tools.nix take pkgs as an argument, rather than all the
arguments for pkgs.
2022-05-30 14:16:22 +00:00
|
|
|
localSystem = if crossSystem != null then crossSystem else localSystem;
|
2020-11-19 08:28:00 +00:00
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
stdenvStages = args: let
|
2023-07-15 11:24:51 +00:00
|
|
|
args' = args // { inherit bootstrapFiles; };
|
|
|
|
in (import (test-pkgspath + "/pkgs/stdenv/darwin") args');
|
2016-01-04 02:47:09 +00:00
|
|
|
};
|
2015-02-18 05:24:16 +00:00
|
|
|
}
|