Skip to content

Commit

Permalink
misc pkgs: Remove unneeded *Platform == *Platform comparisons
Browse files Browse the repository at this point in the history
PR #26007 used these to avoid causing a mass rebuild. Now that we know
things work, we do that to clean up.
  • Loading branch information
Ericson2314 committed Jun 30, 2017
1 parent d61c223 commit 95c8277
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 75 deletions.
4 changes: 2 additions & 2 deletions pkgs/applications/audio/mpg123/default.nix
@@ -1,6 +1,6 @@
{ stdenv
, fetchurl, alsaLib
, buildPlatform, hostPlatform
, hostPlatform
}:

stdenv.mkDerivation rec {
Expand All @@ -13,7 +13,7 @@ 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 = {
Expand Down
8 changes: 7 additions & 1 deletion pkgs/applications/editors/ed/default.nix
Expand Up @@ -32,7 +32,13 @@ stdenv.mkDerivation rec {
*/
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"
];
Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/rust/rustc.nix
Expand Up @@ -138,8 +138,7 @@ stdenv.mkDerivation {

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
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/libraries/glew/1.10.nix
Expand Up @@ -38,8 +38,8 @@ stdenv.mkDerivation rec {
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; {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/libraries/glew/default.nix
Expand Up @@ -39,8 +39,8 @@ stdenv.mkDerivation rec {
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; {
Expand Down
5 changes: 2 additions & 3 deletions pkgs/development/libraries/libelf/default.nix
Expand Up @@ -11,9 +11,8 @@ stdenv.mkDerivation rec {
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;
Expand Down
58 changes: 27 additions & 31 deletions pkgs/development/libraries/zlib/default.nix
Expand Up @@ -4,10 +4,9 @@
, static ? false
}:

let version = "1.2.11"; in

stdenv.mkDerivation rec {
name = "zlib-${version}";
version = "1.2.11";

src = fetchurl {
urls =
Expand All @@ -19,7 +18,7 @@ stdenv.mkDerivation rec {

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"' \
Expand All @@ -30,14 +29,6 @@ stdenv.mkDerivation rec {
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" ];

Expand All @@ -49,36 +40,41 @@ stdenv.mkDerivation rec {
# 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";

This comment has been minimized.

Copy link
@matthewbauer

matthewbauer Mar 16, 2018

Member

@Ericson2314 Should this be "(!hostPlatform.cc.isGNU)"? See #35636.

This comment has been minimized.

Copy link
@Ericson2314

Ericson2314 Mar 16, 2018

Author Member

Good catch, but stdenv.cc.isGNU, actually. The platform string does not speak for the C compiler.

This comment has been minimized.

Copy link
@Ericson2314

Ericson2314 Mar 16, 2018

Author Member

I should add, this whole line is a terribly leaky way to deal with bootstrapping.


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 = [];

# 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";
};
installFlags = stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
"BINARY_PATH=$(out)/bin"
"INCLUDE_PATH=$(dev)/include"
"LIBRARY_PATH=$(out)/lib"
];

passthru.version = version;
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;
};

meta = with stdenv.lib; {
description = "Lossless data-compression library";
Expand Down
12 changes: 10 additions & 2 deletions pkgs/development/tools/misc/binutils/default.nix
Expand Up @@ -8,10 +8,13 @@ let
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";
Expand Down Expand Up @@ -78,15 +81,20 @@ stdenv.mkDerivation rec {
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.)";
longDescription = ''
Expand Down
5 changes: 3 additions & 2 deletions pkgs/development/tools/misc/gdb/default.nix
Expand Up @@ -48,15 +48,16 @@ stdenv.mkDerivation rec {

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}"
] ++ stdenv.lib.optional hostPlatform.isLinux
# 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 =
Expand Down
13 changes: 9 additions & 4 deletions pkgs/os-specific/darwin/binutils/default.nix
Expand Up @@ -2,11 +2,12 @@
, hostPlatform, targetPlatform
}:

let
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
# Make sure both underlying packages claim to have prepended their binaries
# with the same prefix.
assert binutils-raw.prefix == cctools.prefix;

let
inherit (binutils-raw) prefix;
cmds = [
"ar" "ranlib" "as" "dsymutil" "install_name_tool"
"ld" "strip" "otool" "lipo" "nm" "strings" "size"
Expand Down Expand Up @@ -50,4 +51,8 @@ stdenv.mkDerivation {
ln -s ${cctools}/libexec $out/libexec
'';

passthru = {
inherit prefix;
};
}
15 changes: 9 additions & 6 deletions pkgs/os-specific/darwin/cctools/port.nix
@@ -1,10 +1,12 @@
{ 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}-";
Expand Down Expand Up @@ -38,13 +40,10 @@ let

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 = ''
Expand Down Expand Up @@ -104,6 +103,10 @@ let
done
'';

passthru = {
inherit prefix;
};

meta = {
homepage = "http://www.opensource.apple.com/source/cctools/";
description = "Mac OS X Compiler Tools (cross-platform port)";
Expand Down
6 changes: 1 addition & 5 deletions pkgs/os-specific/linux/busybox/default.nix
Expand Up @@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
CONFIG_DEFAULT_SETFONT_DIR "/etc/kbd"
${extraConfig}
$extraCrossConfig
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
EOF
make oldconfig
Expand All @@ -79,10 +79,6 @@ stdenv.mkDerivation rec {

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;

meta = with stdenv.lib; {
Expand Down
5 changes: 2 additions & 3 deletions pkgs/tools/archivers/unzip/default.nix
@@ -1,7 +1,6 @@
{ stdenv, fetchurl
, bzip2
, enableNLS ? false, libnatspec
, buildPlatform, hostPlatform
}:

stdenv.mkDerivation {
Expand All @@ -23,13 +22,13 @@ 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;
Expand Down
@@ -1,12 +1,14 @@
--- 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
6 changes: 3 additions & 3 deletions pkgs/tools/misc/coreutils/default.nix
Expand Up @@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
&& 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’.
Expand All @@ -83,11 +83,11 @@ stdenv.mkDerivation rec {

# 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
'';
Expand Down
5 changes: 0 additions & 5 deletions pkgs/tools/system/ddrescue/default.nix
Expand Up @@ -17,11 +17,6 @@ stdenv.mkDerivation rec {

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";

Expand Down

0 comments on commit 95c8277

Please sign in to comment.