Merge pull request #26881 from obsidiansystems/cross-hashbreak

Make hash-breaking cleanups avoided in #26007

Changed files
+84 -75
pkgs
applications
audio
mpg123
editors
development
compilers
rust
libraries
tools
misc
binutils
gdb
os-specific
darwin
binutils
cctools
linux
busybox
tools
archivers
misc
coreutils
system
ddrescue
text
gnupatch
+2 -2
pkgs/applications/audio/mpg123/default.nix
···
{ stdenv
, fetchurl, alsaLib
-
, buildPlatform, hostPlatform
+
, hostPlatform
}:
stdenv.mkDerivation rec {
···
buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
-
${if buildPlatform != hostPlatform then "configureFlags" else null} =
+
configureFlags =
stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";
meta = {
+7 -1
pkgs/applications/editors/ed/default.nix
···
*/
doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform);
-
configureFlags = if hostPlatform == buildPlatform then null else [
+
# TODO(@Ericson2314): Use placeholder to make this a configure flag once Nix
+
# 1.12 is released.
+
preConfigure = ''
+
export DESTDIR=$out
+
'';
+
+
configureFlags = [
"--exec-prefix=${stdenv.cc.prefix}"
"CC=${stdenv.cc.prefix}cc"
];
+1 -2
pkgs/development/compilers/rust/rustc.nix
···
inherit doCheck;
-
${if buildPlatform == hostPlatform then "dontSetConfigureCross" else null} = true;
-
${if buildPlatform != hostPlatform then "configurePlatforms" else null} = [];
+
configurePlatforms = [];
# https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764
# https://github.com/rust-lang/rust/issues/30181
+2 -2
pkgs/development/libraries/glew/1.10.nix
···
cp -r README.txt LICENSE.txt doc $out/share/doc/glew
'';
-
makeFlags = if hostPlatform == buildPlatform then null else [
-
"SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel}"
+
makeFlags = [
+
"SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
];
meta = with stdenv.lib; {
+2 -2
pkgs/development/libraries/glew/default.nix
···
rm $out/lib/*.a
'';
-
makeFlags = if hostPlatform == buildPlatform then null else [
-
"SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel}"
+
makeFlags = [
+
"SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
];
meta = with stdenv.lib; {
pkgs/development/libraries/libelf/cross-ar.patch pkgs/development/libraries/libelf/dont-hardcode-ar.patch
+2 -3
pkgs/development/libraries/libelf/default.nix
···
sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
};
-
# TODO(@Ericson2314) Make unconditional next hash break
-
patches = if hostPlatform == buildPlatform then null else [
-
./cross-ar.patch
+
patches = [
+
./dont-hardcode-ar.patch
];
doCheck = true;
+27 -31
pkgs/development/libraries/zlib/default.nix
···
, static ? false
}:
-
let version = "1.2.11"; in
-
stdenv.mkDerivation rec {
name = "zlib-${version}";
+
version = "1.2.11";
src = fetchurl {
urls =
···
patches = stdenv.lib.optional hostPlatform.isCygwin ./disable-cygwin-widechar.patch;
-
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+
postPatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
substituteInPlace configure \
--replace '/usr/bin/libtool' 'ar' \
--replace 'AR="libtool"' 'AR="ar"' \
···
setOutputFlags = false;
outputDoc = "dev"; # single tiny man3 page
-
# TODO(@Dridus) CC set by cc-wrapper setup-hook, so just empty out the preConfigure script when cross building, but leave the old incorrect script when not
-
# cross building to avoid hash breakage. Once hash breakage is acceptable, remove preConfigure entirely.
-
preConfigure = stdenv.lib.optionalString (hostPlatform == buildPlatform) ''
-
if test -n "$crossConfig"; then
-
export CC=$crossConfig-gcc
-
fi
-
'';
-
# FIXME needs gcc 4.9 in bootstrap tools
hardeningDisable = [ "stackprotector" ];
···
# jww (2015-01-06): Sometimes this library install as a .so, even on
# Darwin; others time it installs as a .dylib. I haven't yet figured out
# what causes this difference.
-
+ stdenv.lib.optionalString stdenv.isDarwin ''
+
+ stdenv.lib.optionalString hostPlatform.isDarwin ''
for file in $out/lib/*.so* $out/lib/*.dylib* ; do
install_name_tool -id "$file" $file
done
+
''
+
# Non-typical naming confuses libtool which then refuses to use zlib's DLL
+
# in some cases, e.g. when compiling libpng.
+
+ stdenv.lib.optionalString (hostPlatform.libc == "msvcrt") ''
+
ln -s zlib1.dll $out/bin/libz.dll
'';
# As zlib takes part in the stdenv building, we don't want references
# to the bootstrap-tools libgcc (as uses to happen on arm/mips)
-
NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!stdenv.isDarwin) "-static-libgcc";
+
NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!hostPlatform.isDarwin) "-static-libgcc";
-
crossAttrs = {
-
dontStrip = static;
-
configurePlatforms = [];
-
} // stdenv.lib.optionalAttrs (hostPlatform.libc == "msvcrt") {
-
installFlags = [
-
"BINARY_PATH=$(out)/bin"
-
"INCLUDE_PATH=$(dev)/include"
-
"LIBRARY_PATH=$(out)/lib"
-
];
-
makeFlags = [
-
"-f" "win32/Makefile.gcc"
-
"PREFIX=${stdenv.cc.prefix}"
-
] ++ stdenv.lib.optional (!static) "SHARED_MODE=1";
+
dontStrip = hostPlatform != buildPlatform && static;
+
configurePlatforms = [];
+
+
installFlags = stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
+
"BINARY_PATH=$(out)/bin"
+
"INCLUDE_PATH=$(dev)/include"
+
"LIBRARY_PATH=$(out)/lib"
+
];
+
+
makeFlags = [
+
"PREFIX=${stdenv.cc.prefix}"
+
] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
+
"-f" "win32/Makefile.gcc"
+
] ++ stdenv.lib.optionals (!static) [
+
"SHARED_MODE=1"
+
];
-
# Non-typical naming confuses libtool which then refuses to use zlib's DLL
-
# in some cases, e.g. when compiling libpng.
-
postInstall = postInstall + "ln -s zlib1.dll $out/bin/libz.dll";
+
passthru = {
+
inherit version;
};
-
-
passthru.version = version;
meta = with stdenv.lib; {
description = "Lossless data-compression library";
+10 -2
pkgs/development/tools/misc/binutils/default.nix
···
version = "2.28";
basename = "binutils-${version}";
inherit (stdenv.lib) optional optionals optionalString;
+
# The prefix prepended to binary names to allow multiple binuntils on the
+
# PATH to both be usable.
+
prefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
in
stdenv.mkDerivation rec {
-
name = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-" + basename;
+
name = prefix + basename;
src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2";
···
then "-Wno-string-plus-int -Wno-deprecated-declarations"
else "-static-libgcc";
+
# TODO(@Ericson2314): Always pass "--target" and always prefix.
+
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
[ "--enable-shared" "--enable-deterministic-archives" "--disable-werror" ]
++ optional (stdenv.system == "mips64el-linux") "--enable-fix-loongson2f-nop"
-
++ optional (targetPlatform != hostPlatform) "--target=${targetPlatform.config}" # TODO: make this unconditional
++ optionals gold [ "--enable-gold" "--enable-plugins" ]
++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu";
enableParallelBuilding = true;
+
+
passthru = {
+
inherit prefix;
+
};
meta = with stdenv.lib; {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
+3 -2
pkgs/development/tools/misc/gdb/default.nix
···
NIX_CFLAGS_COMPILE = "-Wno-format-nonliteral";
+
# TODO(@Ericson2314): Always pass "--target" and always prefix.
+
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
configureFlags = with stdenv.lib; [
"--with-gmp=${gmp.dev}" "--with-mpfr=${mpfr.dev}" "--with-system-readline"
"--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.dev}"
···
# TODO(@Ericson2314): make this conditional on whether host platform is NixOS
"--with-separate-debug-dir=/run/current-system/sw/lib/debug"
++ stdenv.lib.optional (!pythonSupport) "--without-python"
-
# TODO(@Ericson2314): This should be done in stdenv, not per-package
-
++ stdenv.lib.optional (targetPlatform != hostPlatform) "--target=${targetPlatform.config}"
++ stdenv.lib.optional multitarget "--enable-targets=all";
postInstall =
+9 -4
pkgs/os-specific/darwin/binutils/default.nix
···
, hostPlatform, targetPlatform
}:
+
# Make sure both underlying packages claim to have prepended their binaries
+
# with the same prefix.
+
assert binutils-raw.prefix == cctools.prefix;
+
let
-
prefix = stdenv.lib.optionalString
-
(targetPlatform != hostPlatform)
-
"${targetPlatform.config}-";
-
+
inherit (binutils-raw) prefix;
cmds = [
"ar" "ranlib" "as" "dsymutil" "install_name_tool"
"ld" "strip" "otool" "lipo" "nm" "strings" "size"
···
ln -s ${cctools}/libexec $out/libexec
'';
+
+
passthru = {
+
inherit prefix;
+
};
}
+9 -6
pkgs/os-specific/darwin/cctools/port.nix
···
{ stdenv, fetchFromGitHub, makeWrapper, autoconf, automake, libtool_2
, llvm, libcxx, libcxxabi, clang, libuuid
, libobjc ? null, maloader ? null, xctoolchain ? null
-
, buildPlatform, hostPlatform, targetPlatform
+
, hostPlatform, targetPlatform
}:
let
+
# The prefix prepended to binary names to allow multiple binuntils on the
+
# PATH to both be usable.
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
···
enableParallelBuilding = true;
+
# TODO(@Ericson2314): Always pass "--target" and always prefix.
+
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = stdenv.lib.optionals (!stdenv.isDarwin) [
"CXXFLAGS=-I${libcxx}/include/c++/v1"
-
] ++ stdenv.lib.optionals (targetPlatform != buildPlatform) [
-
# TODO make unconditional next hash break
-
"--build=${buildPlatform.config}"
-
"--host=${hostPlatform.config}"
-
"--target=${targetPlatform.config}"
];
postPatch = ''
···
ln -s "$out/bin/${targetPlatform.config}-$tool" "$out/bin/$tool"
done
'';
+
+
passthru = {
+
inherit prefix;
+
};
meta = {
homepage = "http://www.opensource.apple.com/source/cctools/";
+1 -5
pkgs/os-specific/linux/busybox/default.nix
···
CONFIG_DEFAULT_SETFONT_DIR "/etc/kbd"
${extraConfig}
-
$extraCrossConfig
+
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
EOF
make oldconfig
···
nativeBuildInputs = lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ];
-
-
extraCrossConfig = if hostPlatform == buildPlatform then null else ''
-
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
-
'';
enableParallelBuilding = true;
+3 -1
pkgs/tools/archivers/unzip/cross-cc.patch pkgs/tools/archivers/unzip/dont-hardcode-cc.patch
···
--- a/unix/Makefile
+++ b/unix/Makefile
-
@@ -42,9 +42,7 @@
+
@@ -42,9 +42,9 @@
# such as -DDOSWILD).
# UnZip flags
-CC = cc# try using "gcc" target rather than changing this (CC and LD
+
+CC ?= cc# try using "gcc" target rather than changing this (CC and LD
LD = $(CC)# must match, else "unresolved symbol: ___main" is possible)
-AS = as
+
+AS ?= as
LOC = $(D_USE_BZ2) $(LOCAL_UNZIP)
AF = $(LOC)
CFLAGS = -O
+2 -3
pkgs/tools/archivers/unzip/default.nix
···
{ stdenv, fetchurl
, bzip2
, enableNLS ? false, libnatspec
-
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation {
···
./CVE-2015-7697.diff
./CVE-2014-9913.patch
./CVE-2016-9844.patch
+
./dont-hardcode-cc.patch
] ++ stdenv.lib.optional enableNLS
(fetchurl {
url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1";
name = "unzip-6.0-natspec.patch";
sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
-
})
-
++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch;
+
});
nativeBuildInputs = [ bzip2 ];
buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec;
+3 -3
pkgs/tools/misc/coreutils/default.nix
···
&& builtins.storeDir == "/nix/store";
# Prevents attempts of running 'help2man' on cross-built binaries.
-
${if hostPlatform == buildPlatform then null else "PERL"} = "missing";
+
PERL = if hostPlatform == buildPlatform then null else "missing";
# Saw random failures like ‘help2man: can't get '--help' info from
# man/sha512sum.td/sha512sum’.
···
# Works around a bug with 8.26:
# Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
-
${if hostPlatform == buildPlatform then null else "preInstall"} = ''
+
preInstall = optionalString (hostPlatform != buildPlatform) ''
sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
'';
-
${if hostPlatform == buildPlatform then null else "postInstall"} = ''
+
postInstall = optionalString (hostPlatform != buildPlatform) ''
rm $out/share/man/man1/*
cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
'';
-5
pkgs/tools/system/ddrescue/default.nix
···
doCheck = hostPlatform == buildPlatform;
-
${if hostPlatform != buildPlatform then "crossPlatforms" else null} = [ ];
-
${if hostPlatform != buildPlatform then "configureFlags" else null} = [
-
"CXX=${stdenv.cc.prefix}c++"
-
];
-
meta = with stdenv.lib; {
description = "GNU ddrescue, a data recovery tool";
+1 -1
pkgs/tools/text/gnupatch/default.nix
···
buildInputs = stdenv.lib.optional doCheck ed;
-
configureFlags = if hostPlatform == buildPlatform then null else [
+
configureFlags = stdenv.lib.optionals (hostPlatform != buildPlatform) [
"ac_cv_func_strnlen_working=yes"
];