Merge pull request #26881 from obsidiansystems/cross-hashbreak

Make hash-breaking cleanups avoided in #26007
This commit is contained in:
John Ericson 2017-06-30 10:12:05 -04:00 committed by GitHub
commit c53449ce57
18 changed files with 84 additions and 75 deletions

View File

@ -1,6 +1,6 @@
{ stdenv { stdenv
, fetchurl, alsaLib , fetchurl, alsaLib
, buildPlatform, hostPlatform , hostPlatform
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib; 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}"; stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";
meta = { meta = {

View File

@ -32,7 +32,13 @@ stdenv.mkDerivation rec {
*/ */
doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform); 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}" "--exec-prefix=${stdenv.cc.prefix}"
"CC=${stdenv.cc.prefix}cc" "CC=${stdenv.cc.prefix}cc"
]; ];

View File

@ -138,8 +138,7 @@ stdenv.mkDerivation {
inherit doCheck; inherit doCheck;
${if buildPlatform == hostPlatform then "dontSetConfigureCross" else null} = true; configurePlatforms = [];
${if buildPlatform != hostPlatform then "configurePlatforms" else null} = [];
# https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764 # https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764
# https://github.com/rust-lang/rust/issues/30181 # https://github.com/rust-lang/rust/issues/30181

View File

@ -38,8 +38,8 @@ stdenv.mkDerivation rec {
cp -r README.txt LICENSE.txt doc $out/share/doc/glew cp -r README.txt LICENSE.txt doc $out/share/doc/glew
''; '';
makeFlags = if hostPlatform == buildPlatform then null else [ makeFlags = [
"SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel}" "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
]; ];
meta = with stdenv.lib; { meta = with stdenv.lib; {

View File

@ -39,8 +39,8 @@ stdenv.mkDerivation rec {
rm $out/lib/*.a rm $out/lib/*.a
''; '';
makeFlags = if hostPlatform == buildPlatform then null else [ makeFlags = [
"SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel}" "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
]; ];
meta = with stdenv.lib; { meta = with stdenv.lib; {

View File

@ -11,9 +11,8 @@ stdenv.mkDerivation rec {
sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"; sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
}; };
# TODO(@Ericson2314) Make unconditional next hash break patches = [
patches = if hostPlatform == buildPlatform then null else [ ./dont-hardcode-ar.patch
./cross-ar.patch
]; ];
doCheck = true; doCheck = true;

View File

@ -4,10 +4,9 @@
, static ? false , static ? false
}: }:
let version = "1.2.11"; in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "zlib-${version}"; name = "zlib-${version}";
version = "1.2.11";
src = fetchurl { src = fetchurl {
urls = urls =
@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
patches = stdenv.lib.optional hostPlatform.isCygwin ./disable-cygwin-widechar.patch; patches = stdenv.lib.optional hostPlatform.isCygwin ./disable-cygwin-widechar.patch;
postPatch = stdenv.lib.optionalString stdenv.isDarwin '' postPatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
substituteInPlace configure \ substituteInPlace configure \
--replace '/usr/bin/libtool' 'ar' \ --replace '/usr/bin/libtool' 'ar' \
--replace 'AR="libtool"' 'AR="ar"' \ --replace 'AR="libtool"' 'AR="ar"' \
@ -30,14 +29,6 @@ stdenv.mkDerivation rec {
setOutputFlags = false; setOutputFlags = false;
outputDoc = "dev"; # single tiny man3 page 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 # FIXME needs gcc 4.9 in bootstrap tools
hardeningDisable = [ "stackprotector" ]; hardeningDisable = [ "stackprotector" ];
@ -49,37 +40,42 @@ stdenv.mkDerivation rec {
# jww (2015-01-06): Sometimes this library install as a .so, even on # 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 # Darwin; others time it installs as a .dylib. I haven't yet figured out
# what causes this difference. # what causes this difference.
+ stdenv.lib.optionalString stdenv.isDarwin '' + stdenv.lib.optionalString hostPlatform.isDarwin ''
for file in $out/lib/*.so* $out/lib/*.dylib* ; do for file in $out/lib/*.so* $out/lib/*.dylib* ; do
install_name_tool -id "$file" $file install_name_tool -id "$file" $file
done 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 # 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) # 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 = hostPlatform != buildPlatform && static;
dontStrip = static; configurePlatforms = [];
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";
# Non-typical naming confuses libtool which then refuses to use zlib's DLL installFlags = stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
# in some cases, e.g. when compiling libpng. "BINARY_PATH=$(out)/bin"
postInstall = postInstall + "ln -s zlib1.dll $out/bin/libz.dll"; "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"
];
passthru = {
inherit version;
}; };
passthru.version = version;
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Lossless data-compression library"; description = "Lossless data-compression library";
license = licenses.zlib; license = licenses.zlib;

View File

@ -8,10 +8,13 @@ let
version = "2.28"; version = "2.28";
basename = "binutils-${version}"; basename = "binutils-${version}";
inherit (stdenv.lib) optional optionals optionalString; 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 in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-" + basename; name = prefix + basename;
src = fetchurl { src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2"; url = "mirror://gnu/binutils/${basename}.tar.bz2";
@ -78,15 +81,20 @@ stdenv.mkDerivation rec {
then "-Wno-string-plus-int -Wno-deprecated-declarations" then "-Wno-string-plus-int -Wno-deprecated-declarations"
else "-static-libgcc"; else "-static-libgcc";
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = configureFlags =
[ "--enable-shared" "--enable-deterministic-archives" "--disable-werror" ] [ "--enable-shared" "--enable-deterministic-archives" "--disable-werror" ]
++ optional (stdenv.system == "mips64el-linux") "--enable-fix-loongson2f-nop" ++ 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" ] ++ optionals gold [ "--enable-gold" "--enable-plugins" ]
++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu"; ++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu";
enableParallelBuilding = true; enableParallelBuilding = true;
passthru = {
inherit prefix;
};
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Tools for manipulating binaries (linker, assembler, etc.)"; description = "Tools for manipulating binaries (linker, assembler, etc.)";
longDescription = '' longDescription = ''

View File

@ -48,6 +48,9 @@ stdenv.mkDerivation rec {
NIX_CFLAGS_COMPILE = "-Wno-format-nonliteral"; 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; [ configureFlags = with stdenv.lib; [
"--with-gmp=${gmp.dev}" "--with-mpfr=${mpfr.dev}" "--with-system-readline" "--with-gmp=${gmp.dev}" "--with-mpfr=${mpfr.dev}" "--with-system-readline"
"--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.dev}" "--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.dev}"
@ -55,8 +58,6 @@ stdenv.mkDerivation rec {
# TODO(@Ericson2314): make this conditional on whether host platform is NixOS # TODO(@Ericson2314): make this conditional on whether host platform is NixOS
"--with-separate-debug-dir=/run/current-system/sw/lib/debug" "--with-separate-debug-dir=/run/current-system/sw/lib/debug"
++ stdenv.lib.optional (!pythonSupport) "--without-python" ++ 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"; ++ stdenv.lib.optional multitarget "--enable-targets=all";
postInstall = postInstall =

View File

@ -2,11 +2,12 @@
, hostPlatform, targetPlatform , hostPlatform, targetPlatform
}: }:
let # Make sure both underlying packages claim to have prepended their binaries
prefix = stdenv.lib.optionalString # with the same prefix.
(targetPlatform != hostPlatform) assert binutils-raw.prefix == cctools.prefix;
"${targetPlatform.config}-";
let
inherit (binutils-raw) prefix;
cmds = [ cmds = [
"ar" "ranlib" "as" "dsymutil" "install_name_tool" "ar" "ranlib" "as" "dsymutil" "install_name_tool"
"ld" "strip" "otool" "lipo" "nm" "strings" "size" "ld" "strip" "otool" "lipo" "nm" "strings" "size"
@ -50,4 +51,8 @@ stdenv.mkDerivation {
ln -s ${cctools}/libexec $out/libexec ln -s ${cctools}/libexec $out/libexec
''; '';
passthru = {
inherit prefix;
};
} }

View File

@ -1,10 +1,12 @@
{ stdenv, fetchFromGitHub, makeWrapper, autoconf, automake, libtool_2 { stdenv, fetchFromGitHub, makeWrapper, autoconf, automake, libtool_2
, llvm, libcxx, libcxxabi, clang, libuuid , llvm, libcxx, libcxxabi, clang, libuuid
, libobjc ? null, maloader ? null, xctoolchain ? null , libobjc ? null, maloader ? null, xctoolchain ? null
, buildPlatform, hostPlatform, targetPlatform , hostPlatform, targetPlatform
}: }:
let let
# The prefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
prefix = stdenv.lib.optionalString prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform) (targetPlatform != hostPlatform)
"${targetPlatform.config}-"; "${targetPlatform.config}-";
@ -38,13 +40,10 @@ let
enableParallelBuilding = true; 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) [ configureFlags = stdenv.lib.optionals (!stdenv.isDarwin) [
"CXXFLAGS=-I${libcxx}/include/c++/v1" "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 = '' postPatch = ''
@ -104,6 +103,10 @@ let
done done
''; '';
passthru = {
inherit prefix;
};
meta = { meta = {
homepage = "http://www.opensource.apple.com/source/cctools/"; homepage = "http://www.opensource.apple.com/source/cctools/";
description = "Mac OS X Compiler Tools (cross-platform port)"; description = "Mac OS X Compiler Tools (cross-platform port)";

View File

@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
CONFIG_DEFAULT_SETFONT_DIR "/etc/kbd" CONFIG_DEFAULT_SETFONT_DIR "/etc/kbd"
${extraConfig} ${extraConfig}
$extraCrossConfig CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
EOF EOF
make oldconfig make oldconfig
@ -79,10 +79,6 @@ stdenv.mkDerivation rec {
buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ]; 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; enableParallelBuilding = true;
meta = with stdenv.lib; { meta = with stdenv.lib; {

View File

@ -1,7 +1,6 @@
{ stdenv, fetchurl { stdenv, fetchurl
, bzip2 , bzip2
, enableNLS ? false, libnatspec , enableNLS ? false, libnatspec
, buildPlatform, hostPlatform
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
@ -23,13 +22,13 @@ stdenv.mkDerivation {
./CVE-2015-7697.diff ./CVE-2015-7697.diff
./CVE-2014-9913.patch ./CVE-2014-9913.patch
./CVE-2016-9844.patch ./CVE-2016-9844.patch
./dont-hardcode-cc.patch
] ++ stdenv.lib.optional enableNLS ] ++ stdenv.lib.optional enableNLS
(fetchurl { (fetchurl {
url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1"; 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"; name = "unzip-6.0-natspec.patch";
sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
}) });
++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch;
nativeBuildInputs = [ bzip2 ]; nativeBuildInputs = [ bzip2 ];
buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec; buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec;

View File

@ -1,12 +1,14 @@
--- a/unix/Makefile --- a/unix/Makefile
+++ b/unix/Makefile +++ b/unix/Makefile
@@ -42,9 +42,7 @@ @@ -42,9 +42,9 @@
# such as -DDOSWILD). # such as -DDOSWILD).
# UnZip flags # 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
+CC ?= cc# try using "gcc" target rather than changing this (CC and LD
LD = $(CC)# must match, else "unresolved symbol: ___main" is possible) LD = $(CC)# must match, else "unresolved symbol: ___main" is possible)
-AS = as -AS = as
+AS ?= as
LOC = $(D_USE_BZ2) $(LOCAL_UNZIP) LOC = $(D_USE_BZ2) $(LOCAL_UNZIP)
AF = $(LOC) AF = $(LOC)
CFLAGS = -O CFLAGS = -O

View File

@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
&& builtins.storeDir == "/nix/store"; && builtins.storeDir == "/nix/store";
# Prevents attempts of running 'help2man' on cross-built binaries. # 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 # Saw random failures like help2man: can't get '--help' info from
# man/sha512sum.td/sha512sum. # man/sha512sum.td/sha512sum.
@ -83,11 +83,11 @@ stdenv.mkDerivation rec {
# Works around a bug with 8.26: # Works around a bug with 8.26:
# Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop. # 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|' 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/* rm $out/share/man/man1/*
cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1 cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
''; '';

View File

@ -17,11 +17,6 @@ stdenv.mkDerivation rec {
doCheck = hostPlatform == buildPlatform; 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; { meta = with stdenv.lib; {
description = "GNU ddrescue, a data recovery tool"; description = "GNU ddrescue, a data recovery tool";

View File

@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
buildInputs = stdenv.lib.optional doCheck ed; 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" "ac_cv_func_strnlen_working=yes"
]; ];