git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #26007 from obsidiansystems/cc-wrapper-prefix

Get rid of gcc-cross-wrapper

commitafd2bdbad25db4b0007b52d07161345e6426ae72 authorJohn Ericson <Ericson2314@yahoo.com> dateFri 23 Jun 2017, 11:22 (9 years ago) parentc76f8d9198dcec
62 files changed+560−931
doc/stdenv.xml+10 pkgs/applications/audio/mpg123/default.nix+6−5 pkgs/applications/editors/ed/default.nix+8−5 pkgs/applications/editors/vim/default.nix+18−18 pkgs/applications/networking/browsers/lynx/default.nix+6−2 pkgs/applications/video/mplayer/default.nix+4−2 pkgs/applications/video/omxplayer/default.nix+1−1 pkgs/build-support/cc-wrapper/default.nix+161−82 pkgs/build-support/gcc-cross-wrapper/add-flags−5 pkgs/build-support/gcc-cross-wrapper/builder.sh−120 pkgs/build-support/gcc-cross-wrapper/default.nix−65 pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh−117 pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh−145 pkgs/build-support/gcc-cross-wrapper/setup-hook.sh−90 pkgs/build-support/gcc-cross-wrapper/utils.sh−24 pkgs/build-support/gcc-wrapper-old/default.nix−1 pkgs/development/compilers/gcc/4.5/default.nix+1−1 pkgs/development/compilers/gcc/4.8/default.nix+1−1 pkgs/development/compilers/gcc/4.9/default.nix+1−1 pkgs/development/compilers/gcc/5/default.nix+5−1 pkgs/development/compilers/gcc/6/default.nix+1−1 pkgs/development/compilers/gcc/snapshot/default.nix+1−1 pkgs/development/compilers/ghc/head.nix+9−9 pkgs/development/compilers/rust/rustc.nix+3−1 pkgs/development/libraries/ffmpeg-full/default.nix+1−1 pkgs/development/libraries/ffmpeg/generic.nix+1−1 pkgs/development/libraries/libav/default.nix+1−1 pkgs/development/libraries/libelf/cross-ar.patch+11 pkgs/development/libraries/libelf/default.nix+10−7 pkgs/development/libraries/libmpc/default.nix+6−2 pkgs/development/libraries/libsigsegv/default.nix+4−2 pkgs/development/libraries/libvpx/default.nix+1−1 pkgs/development/libraries/libvpx/git.nix+1−1 pkgs/development/libraries/mpfr/default.nix+6−4 pkgs/development/libraries/pcre/default.nix+6−6 pkgs/development/libraries/podofo/default.nix+5−9 pkgs/development/libraries/qt-4.x/4.8/default.nix+1−1 pkgs/development/libraries/zlib/default.nix+9−3 pkgs/development/tools/misc/binutils/default.nix+2−1 pkgs/os-specific/linux/busybox/default.nix+9−12 pkgs/os-specific/windows/mingw-w64/common.nix+11 pkgs/os-specific/windows/mingw-w64/default.nix+5−34 pkgs/os-specific/windows/mingw-w64/headers.nix+13 pkgs/os-specific/windows/mingw-w64/pthreads.nix+13 pkgs/shells/bash/4.4.nix+21−21 pkgs/stdenv/adapters.nix+40−16 pkgs/stdenv/cross/default.nix+9−9 pkgs/stdenv/darwin/default.nix+4 pkgs/stdenv/freebsd/default.nix+2 pkgs/stdenv/linux/default.nix+4 pkgs/stdenv/linux/make-bootstrap-tools-cross.nix−1 pkgs/stdenv/native/default.nix+2 pkgs/stdenv/nix/default.nix+2 pkgs/tools/archivers/unzip/cross-cc.patch+12 pkgs/tools/archivers/unzip/default.nix+8−4 pkgs/tools/misc/coreutils/default.nix+37−39 pkgs/tools/misc/findutils/default.nix+11−8 pkgs/tools/misc/xburst-tools/default.nix+3−2 pkgs/tools/networking/dropbear/default.nix−7 pkgs/tools/system/ddrescue/default.nix+12−2 pkgs/tools/text/gnupatch/default.nix+8−5 pkgs/top-level/all-packages.nix+33−33
doc/stdenv.xml+10
@@ -640,6 +640,16 @@ script) if it exists.</para>
640640 true.</para></listitem>
641641 </varlistentry>
642642
643+ <varlistentry>
644+ <term><varname>configurePlatforms</varname></term>
645+ <listitem><para>
646+ By default, when cross compiling, the configure script has <option>--build=...</option> and <option>--host=...</option> passed.
647+ Packages can instead pass <literal>[ "build" "host" "target" ]</literal> or a subset to control exactly which platform flags are passed.
648+ Compilers and other tools should use this to also pass the target platform, for example.
649+ Note eventually these will be passed when in native builds too, to improve determinism: build-time guessing, as is done today, is a risk of impurity.
650+ </para></listitem>
651+ </varlistentry>
652+
643653 <varlistentry>
644654 <term><varname>preConfigure</varname></term>
645655 <listitem><para>Hook executed at the start of the configure
pkgs/applications/audio/mpg123/default.nix+6−5
@@ -1,4 +1,7 @@
1−{stdenv, fetchurl, alsaLib }:
1+{ stdenv
2+, fetchurl, alsaLib
3+, buildPlatform, hostPlatform
4+}:
25
36stdenv.mkDerivation rec {
47 name = "mpg123-1.23.8";
@@ -10,10 +13,8 @@ stdenv.mkDerivation rec {
1013
1114 buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
1215
13− crossAttrs = {
14− configureFlags = if stdenv.cross ? mpg123 then
15− "--with-cpu=${stdenv.cross.mpg123.cpu}" else "";
16− };
16+ ${if buildPlatform != hostPlatform then "configureFlags" else null} =
17+ stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";
1718
1819 meta = {
1920 description = "Fast console MPEG Audio Player and decoder library";
pkgs/applications/editors/ed/default.nix+8−5
@@ -1,4 +1,6 @@
1−{ fetchurl, stdenv }:
1+{ stdenv, fetchurl
2+, buildPlatform, hostPlatform
3+}:
24
35stdenv.mkDerivation rec {
46 name = "ed-${version}";
@@ -28,11 +30,12 @@ stdenv.mkDerivation rec {
2830 make: *** [check] Error 127
2931
3032 */
31− doCheck = !stdenv.isDarwin;
33+ doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform);
3234
33− crossAttrs = {
34− compileFlags = [ "CC=${stdenv.cross.config}-gcc" ];
35− };
35+ configureFlags = if hostPlatform == buildPlatform then null else [
36+ "--exec-prefix=${stdenv.cc.prefix}"
37+ "CC=${stdenv.cc.prefix}cc"
38+ ];
3639
3740 meta = {
3841 description = "An implementation of the standard Unix editor";
pkgs/applications/editors/vim/default.nix+18−18
@@ -6,7 +6,9 @@
66 sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c";
77 }
88# apple frameworks
9−, Carbon, Cocoa }:
9+, Carbon, Cocoa
10+, buildPlatform, hostPlatform
11+}:
1012
1113let
1214 common = callPackage ./common.nix {};
@@ -17,12 +19,26 @@ stdenv.mkDerivation rec {
1719 inherit (common) version src postPatch hardeningDisable enableParallelBuilding meta;
1820
1921 buildInputs = [ ncurses pkgconfig ]
20− ++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
22+ ++ stdenv.lib.optionals hostPlatform.isDarwin [ Carbon Cocoa ];
2123 nativeBuildInputs = [ gettext ];
2224
2325 configureFlags = [
2426 "--enable-multibyte"
2527 "--enable-nls"
28+ ] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
29+ "vim_cv_toupper_broken=no"
30+ "--with-tlib=ncurses"
31+ "vim_cv_terminfo=yes"
32+ "vim_cv_tty_group=tty"
33+ "vim_cv_tty_mode=0660"
34+ "vim_cv_getcwd_broken=no"
35+ "vim_cv_stat_ignores_slash=yes"
36+ "ac_cv_sizeof_int=4"
37+ "vim_cv_memmove_handles_overlap=yes"
38+ "vim_cv_memmove_handles_overlap=yes"
39+
40+ # TODO(@Ericson2314): wont' be needed soon.
41+ "STRIP=${hostPlatform.config}-strip"
2642 ];
2743
2844 postInstall = ''
@@ -31,22 +47,6 @@ stdenv.mkDerivation rec {
3147 cp "${vimrc}" $out/share/vim/vimrc
3248 '';
3349
34− crossAttrs = {
35− configureFlags = [
36− "vim_cv_toupper_broken=no"
37− "--with-tlib=ncurses"
38− "vim_cv_terminfo=yes"
39− "vim_cv_tty_group=tty"
40− "vim_cv_tty_mode=0660"
41− "vim_cv_getcwd_broken=no"
42− "vim_cv_stat_ignores_slash=yes"
43− "ac_cv_sizeof_int=4"
44− "vim_cv_memmove_handles_overlap=yes"
45− "vim_cv_memmove_handles_overlap=yes"
46− "STRIP=${stdenv.cross.config}-strip"
47− ];
48− };
49−
5050 __impureHostDeps = [ "/dev/ptmx" ];
5151
5252 # To fix the trouble in vim73, that it cannot cross-build with this patch
pkgs/applications/networking/browsers/lynx/default.nix+6−2
@@ -1,5 +1,7 @@
1−{ stdenv, fetchurl, ncurses, gzip, pkgconfig
1+{ stdenv, buildPackages
2+, fetchurl, pkgconfig, ncurses, gzip
23, sslSupport ? true, openssl ? null
4+, buildPlatform, hostPlatform
35}:
46
57assert sslSupport -> openssl != null;
@@ -15,7 +17,9 @@ stdenv.mkDerivation rec {
1517
1618 configureFlags = [ "--enable-widec" ] ++ stdenv.lib.optional sslSupport "--with-ssl";
1719
18− nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig;
20+ nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig
21+ ++ stdenv.lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
22+
1923 buildInputs = [ ncurses gzip ] ++ stdenv.lib.optional sslSupport openssl.dev;
2024
2125 meta = with stdenv.lib; {
pkgs/applications/video/mplayer/default.nix+4−2
@@ -25,6 +25,7 @@
2525, libjpegSupport ? true, libjpeg ? null
2626, useUnfreeCodecs ? false
2727, darwin ? null
28+, hostPlatform
2829}:
2930
3031assert fontconfigSupport -> (fontconfig != null);
@@ -185,13 +186,14 @@ stdenv.mkDerivation rec {
185186 '';
186187
187188 crossAttrs = {
188− dontSetConfigureCross = true;
189+ configurePlatforms = [];
189190 # Some things (vidix) are nanonote specific. Once someone cares, we can make options from them.
191+ # Note, the `target` vs `host` confusion is intensional.
190192 preConfigure = ''
191193 configureFlags="`echo $configureFlags |
192194 sed -e 's/--codecsdir[^ ]\+//' \
193195 -e 's/--enable-runtime-cpudetection//' `"
194− configureFlags="$configureFlags --target=${stdenv.cross.arch}-linux
196+ configureFlags="$configureFlags --target=${hostPlatform.arch}-linux
195197 --enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as
196198 --disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc"
197199 '';
pkgs/applications/video/omxplayer/default.nix+1−1
@@ -44,7 +44,7 @@ let
4444 enableParallelBuilding = true;
4545
4646 crossAttrs = {
47− dontSetConfigureCross = true;
47+ configurePlatforms = [];
4848 configureFlags = configureFlags ++ [
4949 "--cross-prefix=${stdenv.cross.config}-"
5050 "--enable-cross-compile"
pkgs/build-support/cc-wrapper/default.nix+161−82
@@ -5,11 +5,13 @@
55# script that sets up the right environment variables so that the
66# compiler and the linker just "work".
77
8−{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
8+{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
99, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell
1010, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
1111, dyld ? null # TODO: should this be a setup-hook on dyld?
1212, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
13+, hostPlatform, targetPlatform
14+, runCommand ? null
1315}:
1416
1517with stdenv.lib;
@@ -17,32 +19,113 @@ with stdenv.lib;
1719assert nativeTools -> nativePrefix != "";
1820assert !nativeTools ->
1921 cc != null && binutils != null && coreutils != null && gnugrep != null;
20−assert !nativeLibc -> libc != null;
22+assert !(nativeLibc && noLibc);
23+assert (noLibc || nativeLibc) == (libc == null);
24+
25+assert targetPlatform != hostPlatform -> runCommand != null;
2126
2227# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
2328assert cc.langVhdl or false -> zlib != null;
2429
2530let
31+ # Prefix for binaries. Customarily ends with a dash separator.
32+ #
33+ # TODO(@Ericson2314) Make unconditional, or optional but always true by
34+ # default.
35+ prefix = stdenv.lib.optionalString (targetPlatform != hostPlatform)
36+ (targetPlatform.config + "-");
2637
2738 ccVersion = (builtins.parseDrvName cc.name).version;
2839 ccName = (builtins.parseDrvName cc.name).name;
2940
30− libc_bin = if nativeLibc then null else getBin libc;
31− libc_dev = if nativeLibc then null else getDev libc;
32− libc_lib = if nativeLibc then null else getLib libc;
41+ libc_bin = if libc == null then null else getBin libc;
42+ libc_dev = if libc == null then null else getDev libc;
43+ libc_lib = if libc == null then null else getLib libc;
3344 cc_solib = getLib cc;
3445 binutils_bin = if nativeTools then "" else getBin binutils;
3546 # The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
3647 coreutils_bin = if nativeTools then "" else getBin coreutils;
3748
38− default_cxx_stdlib_compile=optionalString (stdenv.isLinux && !(cc.isGNU or false))
49+ default_cxx_stdlib_compile=optionalString (targetPlatform.isLinux && !(cc.isGNU or false))
3950 "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)";
51+
52+ dashlessTarget = stdenv.lib.replaceStrings ["-"] ["_"] targetPlatform.config;
53+ # TODO(@Ericson2314) Make unconditional
54+ infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) dashlessTarget;
55+ infixSalt_ = stdenv.lib.optionalString (targetPlatform != hostPlatform) (dashlessTarget + "_");
56+ _infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) ("_" + dashlessTarget);
57+
58+ # We want to prefix all NIX_ flags with the target triple
59+ preWrap = textFile:
60+ # TODO: Do even when not cross on next mass-rebuild
61+ # TODO: use @target_tripple@ for consistency
62+ if targetPlatform == hostPlatform
63+ then textFile
64+ else runCommand "sed-nix-env-vars" {} (''
65+ cp --no-preserve=mode ${textFile} $out
66+
67+ sed -i $out \
68+ -e 's^NIX_^NIX_${infixSalt_}^g' \
69+ -e 's^addCVars^addCVars${_infixSalt}^g' \
70+ -e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g'
71+
72+ '' + stdenv.lib.optionalString (textFile == ./setup-hook.sh) ''
73+ cat << 'EOF' >> $out
74+ for CMD in ar as nm objcopy ranlib strip strings size ld
75+ do
76+ # which is not part of stdenv, but compgen will do for now
77+ if
78+ PATH=$_PATH type -p ${prefix}$CMD > /dev/null
79+ then
80+ export ''$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=${prefix}''${CMD};
81+ fi
82+ done
83+ EOF
84+
85+ sed -i $out -e 's_envHooks_crossEnvHooks_g'
86+ '' + ''
87+
88+ # NIX_ things which we don't both use and define, we revert them
89+ #asymmetric=$(
90+ # for pre in "" "\\$"
91+ # do
92+ # grep -E -ho $pre'NIX_[a-zA-Z_]*' ./* | sed 's/\$//' | sort | uniq
93+ # done | sort | uniq -c | sort -nr | sed -n 's/^1 NIX_//gp')
94+
95+ # hard-code for now
96+ asymmetric=("CXXSTDLIB_COMPILE" "CC")
97+
98+ # The ([^a-zA-Z_]|$) bussiness is to ensure environment variables that
99+ # begin with `NIX_CC` don't also get blacklisted.
100+ for var in "''${asymmetric[@]}"
101+ do
102+ sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g"
103+ done
104+ '');
105+
106+ # The dynamic linker has different names on different platforms.
107+ dynamicLinker =
108+ if !nativeLibc then
109+ (if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else
110+ if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
111+ # ARM with a wildcard, which can be "" or "-armhf".
112+ if targetPlatform.isArm32 then "ld-linux*.so.3" else
113+ if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else
114+ if targetPlatform.system == "powerpc-linux" then "ld.so.1" else
115+ if targetPlatform.system == "mips64el-linux" then "ld.so.1" else
116+ if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else
117+ if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else
118+ builtins.trace
119+ "Don't know the name of the dynamic linker for platform ${targetPlatform.config}, so guessing instead."
120+ null)
121+ else "";
122+
40123in
41124
42125stdenv.mkDerivation {
43− name =
44− (if name != "" then name else ccName + "-wrapper") +
45− (if cc != null && ccVersion != "" then "-" + ccVersion else "");
126+ name = prefix
127+ + (if name != "" then name else "${ccName}-wrapper")
128+ + (stdenv.lib.optionalString (cc != null && ccVersion != "") "-${ccVersion}");
46129
47130 preferLocalBuild = true;
48131
@@ -51,17 +134,18 @@ stdenv.mkDerivation {
51134
52135
53136 passthru = {
54− inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile;
137+ inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile
138+ prefix infixSalt infixSalt_ _infixSalt;
55139
56140 emacsBufferSetup = pkgs: ''
57141 ; We should handle propagation here too
58142 (mapc (lambda (arg)
59143 (when (file-directory-p (concat arg "/include"))
60− (setenv "NIX_CFLAGS_COMPILE" (concat (getenv "NIX_CFLAGS_COMPILE") " -isystem " arg "/include")))
144+ (setenv "NIX_${infixSalt_}CFLAGS_COMPILE" (concat (getenv "NIX_${infixSalt_}CFLAGS_COMPILE") " -isystem " arg "/include")))
61145 (when (file-directory-p (concat arg "/lib"))
62− (setenv "NIX_LDFLAGS" (concat (getenv "NIX_LDFLAGS") " -L" arg "/lib")))
146+ (setenv "NIX_${infixSalt_}LDFLAGS" (concat (getenv "NIX_${infixSalt_}LDFLAGS") " -L" arg "/lib")))
63147 (when (file-directory-p (concat arg "/lib64"))
64− (setenv "NIX_LDFLAGS" (concat (getenv "NIX_LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
148+ (setenv "NIX_${infixSalt_}LDFLAGS" (concat (getenv "NIX_${infixSalt_}LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
65149 '';
66150 };
67151
@@ -78,7 +162,12 @@ stdenv.mkDerivation {
78162 }
79163 ''
80164
81− + optionalString (!nativeLibc) (if (!stdenv.isDarwin) then ''
165+ # TODO(@Ericson2314): Unify logic next hash break
166+ + optionalString (libc != null) (if (targetPlatform.isDarwin) then ''
167+ echo $dynamicLinker > $out/nix-support/dynamic-linker
168+
169+ echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook
170+ '' else if dynamicLinker != null then ''
82171 dynamicLinker="${libc_lib}/lib/$dynamicLinker"
83172 echo $dynamicLinker > $out/nix-support/dynamic-linker
84173
@@ -91,12 +180,24 @@ stdenv.mkDerivation {
91180 # (the *last* value counts, so ours should come first).
92181 echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before
93182 '' else ''
94− echo $dynamicLinker > $out/nix-support/dynamic-linker
183+ dynamicLinker=`eval 'echo $libc/lib/ld*.so.?'`
184+ if [ -n "$dynamicLinker" ]; then
185+ echo $dynamicLinker > $out/nix-support/dynamic-linker
95186
96− echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook
187+ if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
188+ echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
189+ fi
190+
191+ ldflagsBefore="-dynamic-linker $dlinker"
192+ fi
193+
194+ # The dynamic linker is passed in `ldflagsBefore' to allow
195+ # explicit overrides of the dynamic linker by callers to gcc/ld
196+ # (the *last* value counts, so ours should come first).
197+ echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
97198 '')
98199
99− + optionalString (!nativeLibc) ''
200+ + optionalString (libc != null) ''
100201 # The "-B${libc_lib}/lib/" flag is a quick hack to force gcc to link
101202 # against the crt1.o from our own glibc, rather than the one in
102203 # /usr/lib. (This is only an issue when using an `impure'
@@ -117,7 +218,7 @@ stdenv.mkDerivation {
117218 ''
118219
119220 + (if nativeTools then ''
120− ccPath="${if stdenv.isDarwin then cc else nativePrefix}/bin"
221+ ccPath="${if targetPlatform.isDarwin then cc else nativePrefix}/bin"
121222 ldPath="${nativePrefix}/bin"
122223 '' else ''
123224 echo $cc > $out/nix-support/orig-cc
@@ -161,136 +262,114 @@ stdenv.mkDerivation {
161262 # Propagate the wrapped cc so that if you install the wrapper,
162263 # you get tools like gcov, the manpages, etc. as well (including
163264 # for binutils and Glibc).
164− echo ${cc} ${cc.man or ""} ${binutils_bin} ${libc_bin} > $out/nix-support/propagated-user-env-packages
265+ echo ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
165266
166267 echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs
167268 ''
168269
169− + optionalString (stdenv.isSunOS && nativePrefix != "") ''
270+ + optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
170271 # Solaris needs an additional ld wrapper.
171272 ldPath="${nativePrefix}/bin"
172− exec="$ldPath/ld"
173− wrap ld-solaris ${./ld-solaris-wrapper.sh}
273+ exec="$ldPath/${prefix}ld"
274+ wrap ld-solaris ${preWrap ./ld-solaris-wrapper.sh}
174275 '')
175276
176277 + ''
177278 # Create a symlink to as (the assembler). This is useful when a
178279 # cc-wrapper is installed in a user environment, as it ensures that
179280 # the right assembler is called.
180− if [ -e $ldPath/as ]; then
181− ln -s $ldPath/as $out/bin/as
281+ if [ -e $ldPath/${prefix}as ]; then
282+ ln -s $ldPath/${prefix}as $out/bin/${prefix}as
182283 fi
183284
184− wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld}
285+ wrap ${prefix}ld ${preWrap ./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
185286
186− if [ -e ${binutils_bin}/bin/ld.gold ]; then
187− wrap ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.gold
287+ if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
288+ wrap ${prefix}ld.gold ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
188289 fi
189290
190291 if [ -e ${binutils_bin}/bin/ld.bfd ]; then
191− wrap ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.bfd
292+ wrap ${prefix}ld.bfd ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
192293 fi
193294
194− export real_cc=cc
195− export real_cxx=c++
295+ export real_cc=${prefix}cc
296+ export real_cxx=${prefix}c++
196297 export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
197298
198− if [ -e $ccPath/gcc ]; then
199− wrap gcc ${./cc-wrapper.sh} $ccPath/gcc
200− ln -s gcc $out/bin/cc
201− export real_cc=gcc
202− export real_cxx=g++
299+ if [ -e $ccPath/${prefix}gcc ]; then
300+ wrap ${prefix}gcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcc
301+ ln -s ${prefix}gcc $out/bin/${prefix}cc
302+ export real_cc=${prefix}gcc
303+ export real_cxx=${prefix}g++
203304 elif [ -e $ccPath/clang ]; then
204− wrap clang ${./cc-wrapper.sh} $ccPath/clang
205− ln -s clang $out/bin/cc
305+ wrap ${prefix}clang ${preWrap ./cc-wrapper.sh} $ccPath/clang
306+ ln -s ${prefix}clang $out/bin/${prefix}cc
206307 export real_cc=clang
207308 export real_cxx=clang++
208309 fi
209310
210− if [ -e $ccPath/g++ ]; then
211− wrap g++ ${./cc-wrapper.sh} $ccPath/g++
212− ln -s g++ $out/bin/c++
311+ if [ -e $ccPath/${prefix}g++ ]; then
312+ wrap ${prefix}g++ ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}g++
313+ ln -s ${prefix}g++ $out/bin/${prefix}c++
213314 elif [ -e $ccPath/clang++ ]; then
214− wrap clang++ ${./cc-wrapper.sh} $ccPath/clang++
215− ln -s clang++ $out/bin/c++
315+ wrap ${prefix}clang++ ${preWrap ./cc-wrapper.sh} $ccPath/clang++
316+ ln -s ${prefix}clang++ $out/bin/${prefix}c++
216317 fi
217318
218319 if [ -e $ccPath/cpp ]; then
219− wrap cpp ${./cc-wrapper.sh} $ccPath/cpp
320+ wrap ${prefix}cpp ${preWrap ./cc-wrapper.sh} $ccPath/cpp
220321 fi
221322 ''
222323
223324 + optionalString cc.langFortran or false ''
224− wrap gfortran ${./cc-wrapper.sh} $ccPath/gfortran
225− ln -sv gfortran $out/bin/g77
226− ln -sv gfortran $out/bin/f77
325+ wrap ${prefix}gfortran ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gfortran
326+ ln -sv ${prefix}gfortran $out/bin/${prefix}g77
327+ ln -sv ${prefix}gfortran $out/bin/${prefix}f77
227328 ''
228329
229330 + optionalString cc.langJava or false ''
230− wrap gcj ${./cc-wrapper.sh} $ccPath/gcj
331+ wrap ${prefix}gcj ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcj
231332 ''
232333
233334 + optionalString cc.langGo or false ''
234− wrap gccgo ${./cc-wrapper.sh} $ccPath/gccgo
335+ wrap ${prefix}gccgo ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gccgo
235336 ''
236337
237338 + optionalString cc.langAda or false ''
238− wrap gnatgcc ${./cc-wrapper.sh} $ccPath/gnatgcc
239− wrap gnatmake ${./gnat-wrapper.sh} $ccPath/gnatmake
240− wrap gnatbind ${./gnat-wrapper.sh} $ccPath/gnatbind
241− wrap gnatlink ${./gnatlink-wrapper.sh} $ccPath/gnatlink
339+ wrap ${prefix}gnatgcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gnatgcc
340+ wrap ${prefix}gnatmake ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatmake
341+ wrap ${prefix}gnatbind ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatbind
342+ wrap ${prefix}gnatlink ${preWrap ./gnatlink-wrapper.sh} $ccPath/${prefix}gnatlink
242343 ''
243344
244345 + optionalString cc.langVhdl or false ''
245− ln -s $ccPath/ghdl $out/bin/ghdl
346+ ln -s $ccPath/${prefix}ghdl $out/bin/${prefix}ghdl
246347 ''
247348
248349 + ''
249− substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook.tmp
350+ substituteAll ${preWrap ./setup-hook.sh} $out/nix-support/setup-hook.tmp
250351 cat $out/nix-support/setup-hook.tmp >> $out/nix-support/setup-hook
251352 rm $out/nix-support/setup-hook.tmp
252353
253354 # some linkers on some platforms don't support specific -z flags
254355 hardening_unsupported_flags=""
255− if [[ "$($ldPath/ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
356+ if [[ "$($ldPath/${prefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
256357 hardening_unsupported_flags+=" bindnow"
257358 fi
258− if [[ "$($ldPath/ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
359+ if [[ "$($ldPath/${prefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
259360 hardening_unsupported_flags+=" relro"
260361 fi
261362
262− substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
263− substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
264− cp -p ${./utils.sh} $out/nix-support/utils.sh
363+ substituteAll ${preWrap ./add-flags.sh} $out/nix-support/add-flags.sh
364+ substituteAll ${preWrap ./add-hardening.sh} $out/nix-support/add-hardening.sh
365+ cp -p ${preWrap ./utils.sh} $out/nix-support/utils.sh
265366 ''
266367 + extraBuildCommands;
267368
268− # The dynamic linker has different names on different Linux platforms.
269− dynamicLinker =
270− if !nativeLibc then
271− (if stdenv.system == "i686-linux" then "ld-linux.so.2" else
272− if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
273− # ARM with a wildcard, which can be "" or "-armhf".
274− if stdenv.isArm then "ld-linux*.so.3" else
275− if stdenv.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else
276− if stdenv.system == "powerpc-linux" then "ld.so.1" else
277− if stdenv.system == "mips64el-linux" then "ld.so.1" else
278− if stdenv.system == "x86_64-darwin" then "/usr/lib/dyld" else
279− abort "Don't know the name of the dynamic linker for this platform.")
280− else "";
369+ inherit dynamicLinker;
281370
282371 crossAttrs = {
283372 shell = shell.crossDrv + shell.crossDrv.shellPath;
284− libc = stdenv.ccCross.libc;
285− #
286− # This is not the best way to do this. I think the reference should be
287− # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I
288− # do this sufficient if/else.
289− dynamicLinker =
290− (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
291− if stdenv.cross.arch == "mips" then "ld.so.1" else
292− if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
293− abort "don't know the name of the dynamic linker for this platform");
294373 };
295374
296375 meta =
pkgs/build-support/gcc-cross-wrapper/add-flagsdeleted−5
@@ -1,5 +0,0 @@
1−export NIX_CROSS_CFLAGS_COMPILE="@cflagsCompile@ $NIX_CROSS_CFLAGS_COMPILE"
2−export NIX_CROSS_CFLAGS_LINK="@cflagsLink@ $NIX_CROSS_CFLAGS_LINK"
3−export NIX_CROSS_LDFLAGS="@ldflags@ $NIX_CROSS_LDFLAGS"
4−export NIX_CROSS_LDFLAGS_BEFORE="@ldflagsBefore@ $NIX_CROSS_LDFLAGS_BEFORE"
5−export NIX_CROSS_GLIBC_FLAGS_SET=1
pkgs/build-support/gcc-cross-wrapper/builder.shdeleted−120
@@ -1,120 +0,0 @@
1−source $stdenv/setup
2−
3−mkdir $out
4−mkdir $out/bin
5−mkdir $out/nix-support
6−
7−# Force gcc to use ld-wrapper.sh when calling ld.
8−cflagsCompile="-B$out/bin/"
9−
10−if test -z "$nativeLibc" -a -n "$libc"; then
11− cflagsCompile="$cflagsCompile -B$gccLibs/lib -B$libc/lib/ -isystem $libc_dev/include"
12− ldflags="$ldflags -L$libc/lib"
13− # Get the proper dynamic linker for glibc and uclibc.
14− dlinker=`eval 'echo $libc/lib/ld*.so.?'`
15− if [ -n "$dlinker" ]; then
16− ldflagsBefore="-dynamic-linker $dlinker"
17−
18− # The same as above, but put into files, useful for the gcc builder.
19− echo $dlinker > $out/nix-support/dynamic-linker
20− # This trick is to avoid dependencies on the cross-toolchain gcc
21− # for libgcc, libstdc++, ...
22− # -L is for libtool's .la files, and -rpath for the usual fixupPhase
23− # shrinking rpaths.
24− if [ -n "$gccLibs" ]; then
25− ldflagsBefore="$ldflagsBefore -rpath $gccLibs/lib"
26− fi
27− fi
28−
29− if [ -n "$osxMinVersion" ]; then
30− cflagsCompile="$cflagsCompile -mmacosx-version-min=$osxMinVersion"
31− fi
32−
33− echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
34−
35− echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags
36−
37− # The dynamic linker is passed in `ldflagsBefore' to allow
38− # explicit overrides of the dynamic linker by callers to gcc/ld
39− # (the *last* value counts, so ours should come first).
40− echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
41−fi
42−
43−if test -n "$nativeTools"; then
44− gccPath="$nativePrefix/bin"
45− ldPath="$nativePrefix/bin"
46−else
47− ldflags="$ldflags -L$gcc/lib -L$gcc/lib64"
48− gccPath="$gcc/bin"
49− ldPath="$binutils/$crossConfig/bin"
50−fi
51−
52−
53−doSubstitute() {
54− local src=$1
55− local dst=$2
56− substitute "$src" "$dst" \
57− --subst-var "out" \
58− --subst-var "shell" \
59− --subst-var "gcc" \
60− --subst-var "gccProg" \
61− --subst-var "binutils" \
62− --subst-var "libc" \
63− --subst-var "cflagsCompile" \
64− --subst-var "cflagsLink" \
65− --subst-var "ldflags" \
66− --subst-var "ldflagsBefore" \
67− --subst-var "ldPath" \
68− --subst-var-by "ld" "$ldPath/ld"
69−}
70−
71−
72−# Make wrapper scripts around gcc, g++, and g77. Also make symlinks
73−# cc, c++, and f77.
74−mkGccWrapper() {
75− local dst=$1
76− local src=$2
77−
78− if ! test -f "$src"; then
79− echo "$src does not exist (skipping)"
80− return
81− fi
82−
83− gccProg="$src"
84− doSubstitute "$gccWrapper" "$dst"
85− chmod +x "$dst"
86−}
87−
88−mkGccWrapper $out/bin/$crossConfig-gcc $gccPath/$crossConfig-gcc
89−#ln -s gcc $out/bin/cc
90−
91−mkGccWrapper $out/bin/$crossConfig-g++ $gccPath/$crossConfig-g++
92−ln -s $crossConfig-g++ $out/bin/$crossConfig-c++
93−
94−mkGccWrapper $out/bin/$crossConfig-cpp $gccPath/$crossConfig-cpp
95−
96−mkGccWrapper $out/bin/$crossConfig-g77 $gccPath/$crossConfig-g77
97−ln -s $crossConfig-g77 $out/bin/$crossConfig-f77
98−
99−ln -s $binutils/bin/$crossConfig-ar $out/bin/$crossConfig-ar
100−ln -s $binutils/bin/$crossConfig-as $out/bin/$crossConfig-as
101−ln -s $binutils/bin/$crossConfig-nm $out/bin/$crossConfig-nm
102−ln -s $binutils/bin/$crossConfig-strip $out/bin/$crossConfig-strip
103−
104−
105−# Make a wrapper around the linker.
106−doSubstitute "$ldWrapper" "$out/bin/$crossConfig-ld"
107−chmod +x "$out/bin/$crossConfig-ld"
108−
109−
110−# Emit a setup hook. Also store the path to the original GCC and
111−# Glibc.
112−test -n "$gcc" && echo $gcc > $out/nix-support/orig-cc
113−test -n "$libc" && echo $libc > $out/nix-support/orig-libc
114−test -n "$libc_dev" && echo $libc_dev > $out/nix-support/orig-libc-dev
115−
116−doSubstitute "$addFlags" "$out/nix-support/add-flags"
117−
118−doSubstitute "$setupHook" "$out/nix-support/setup-hook"
119−
120−cp -p $utils $out/nix-support/utils
pkgs/build-support/gcc-cross-wrapper/default.nixdeleted−65
@@ -1,65 +0,0 @@
1−# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
2−# know where the C library and standard header files are. Therefore
3−# the compiler produced by that package cannot be installed directly
4−# in a user environment and used from the command line. This
5−# stdenv.mkDerivation provides a wrapper that sets up the right environment
6−# variables so that the compiler and the linker just "work".
7−
8−{ name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? ""
9−, gcc ? null, libc ? null, binutils ? null, shell ? "", cross
10−}:
11−
12−assert nativeTools -> nativePrefix != "";
13−assert !nativeTools -> gcc != null && binutils != null;
14−assert !noLibc -> (!nativeLibc -> libc != null);
15−
16−let
17− chosenName = if name == "" then gcc.name else name;
18− gccLibs = stdenv.mkDerivation {
19− name = chosenName + "-libs";
20− phases = [ "installPhase" ];
21− installPhase = ''
22− echo $out
23− mkdir -p "$out"
24−
25− if [ -d "${gcc}/${cross.config}/lib" ]
26− then
27− cp -Rd "${gcc}/${cross.config}/lib" "$out/lib"
28− chmod -R +w "$out/lib"
29− for a in "$out/lib/"*.la; do
30− sed -i -e "s,${gcc}/${cross.config}/lib,$out/lib,g" $a
31− done
32− rm -f "$out/lib/"*.py
33− else
34− # The MinGW cross-compiler falls into this category.
35− mkdir "$out/lib"
36− fi
37− '';
38− };
39−in
40−stdenv.mkDerivation {
41− builder = ./builder.sh;
42− setupHook = ./setup-hook.sh;
43− gccWrapper = ./gcc-wrapper.sh;
44− ldWrapper = ./ld-wrapper.sh;
45− utils = ./utils.sh;
46− addFlags = ./add-flags;
47− inherit nativeTools nativeLibc nativePrefix gcc binutils;
48− libc = if libc ? out then libc.out else libc;
49− libc_dev = if libc ? dev then libc.dev else libc;
50− crossConfig = if cross != null then cross.config else null;
51− osxMinVersion = cross.osxMinVersion or null;
52− gccLibs = if gcc != null then gccLibs else null;
53− name = chosenName;
54− langC = if nativeTools then true else gcc.langC;
55− langCC = if nativeTools then true else gcc.langCC;
56− langF77 = if nativeTools then false else gcc ? langFortran;
57− shell = if shell == "" then stdenv.shell else shell;
58− meta = if gcc != null then gcc.meta else
59− { description = "System C compiler wrapper";
60− };
61−
62− passthru = {
63− target = cross;
64− };
65−}
pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.shdeleted−117
@@ -1,117 +0,0 @@
1−#! @shell@ -e
2−
3−if test -n "$NIX_CC_WRAPPER_START_HOOK"; then
4− source "$NIX_CC_WRAPPER_START_HOOK"
5−fi
6−
7−if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then
8− source @out@/nix-support/add-flags
9−fi
10−
11−source @out@/nix-support/utils
12−
13−
14−# Figure out if linker flags should be passed. GCC prints annoying
15−# warnings when they are not needed.
16−dontLink=0
17−if test "$*" = "-v" -o -z "$*"; then
18− dontLink=1
19−else
20− for i in "$@"; do
21− if test "$i" = "-c"; then
22− dontLink=1
23− elif test "$i" = "-S"; then
24− dontLink=1
25− elif test "$i" = "-E"; then
26− dontLink=1
27− elif test "$i" = "-E"; then
28− dontLink=1
29− elif test "$i" = "-M"; then
30− dontLink=1
31− elif test "$i" = "-MM"; then
32− dontLink=1
33− fi
34− done
35−fi
36−
37−
38−# Optionally filter out paths not refering to the store.
39−params=("$@")
40−if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
41− rest=()
42− n=0
43− while test $n -lt ${#params[*]}; do
44− p=${params[n]}
45− p2=${params[$((n+1))]}
46− if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
47− skip $p
48− elif test "$p" = "-L" && badPath "$p2"; then
49− n=$((n + 1)); skip $p2
50− elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
51− skip $p
52− elif test "$p" = "-I" && badPath "$p2"; then
53− n=$((n + 1)); skip $p2
54− elif test "$p" = "-isystem" && badPath "$p2"; then
55− n=$((n + 1)); skip $p2
56− else
57− rest=("${rest[@]}" "$p")
58− fi
59− n=$((n + 1))
60− done
61− params=("${rest[@]}")
62−fi
63−
64−
65−# Add the flags for the C compiler proper.
66−extraAfter=($NIX_CROSS_CFLAGS_COMPILE)
67−extraBefore=()
68−
69−if test "$dontLink" != "1"; then
70−
71− # Add the flags that should only be passed to the compiler when
72− # linking.
73− extraAfter=(${extraAfter[@]} $NIX_CROSS_CFLAGS_LINK)
74−
75− # Add the flags that should be passed to the linker (and prevent
76− # `ld-wrapper' from adding NIX_CROSS_LDFLAGS again).
77− for i in $NIX_CROSS_LDFLAGS_BEFORE; do
78− if test "${i:0:3}" = "-L/"; then
79− extraBefore=(${extraBefore[@]} "$i")
80− else
81− extraBefore=(${extraBefore[@]} "-Wl,$i")
82− fi
83− done
84− for i in $NIX_CROSS_LDFLAGS; do
85− if test "${i:0:3}" = "-L/"; then
86− extraAfter=(${extraAfter[@]} "$i")
87− else
88− extraAfter=(${extraAfter[@]} "-Wl,$i")
89− fi
90− done
91− export NIX_CROSS_LDFLAGS_SET=1
92−fi
93−
94−# Optionally print debug info.
95−if test "$NIX_DEBUG" = "1"; then
96− echo "original flags to @gccProg@:" >&2
97− for i in "${params[@]}"; do
98− echo " $i" >&2
99− done
100− echo "extraBefore flags to @gccProg@:" >&2
101− for i in ${extraBefore[@]}; do
102− echo " $i" >&2
103− done
104− echo "extraAfter flags to @gccProg@:" >&2
105− for i in ${extraAfter[@]}; do
106− echo " $i" >&2
107− done
108−fi
109−
110−if test -n "$NIX_CC_WRAPPER_EXEC_HOOK"; then
111− source "$NIX_CC_WRAPPER_EXEC_HOOK"
112−fi
113−
114−# We want gcc to call the wrapper linker, not that of binutils.
115−export PATH="@ldPath@:$PATH"
116−
117−exec @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
pkgs/build-support/gcc-cross-wrapper/ld-wrapper.shdeleted−145
@@ -1,145 +0,0 @@
1−#! @shell@ -e
2−
3−if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
4− source "$NIX_LD_WRAPPER_START_HOOK"
5−fi
6−
7−if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then
8− source @out@/nix-support/add-flags
9−fi
10−
11−source @out@/nix-support/utils
12−
13−
14−# Optionally filter out paths not refering to the store.
15−params=("$@")
16−if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
17− -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_CROSS_LDFLAGS_SET" \); then
18− rest=()
19− n=0
20− while test $n -lt ${#params[*]}; do
21− p=${params[n]}
22− p2=${params[$((n+1))]}
23− if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
24− skip $p
25− elif test "$p" = "-L" && badPath "$p2"; then
26− n=$((n + 1)); skip $p2
27− elif test "$p" = "-rpath" && badPath "$p2"; then
28− n=$((n + 1)); skip $p2
29− elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
30− n=$((n + 1)); skip $p2
31− elif test "${p:0:1}" = "/" && badPath "$p"; then
32− # We cannot skip this; barf.
33− echo "impure path \`$p' used in link" >&2
34− exit 1
35− else
36− rest=("${rest[@]}" "$p")
37− fi
38− n=$((n + 1))
39− done
40− params=("${rest[@]}")
41−fi
42−
43−
44−extra=()
45−extraBefore=()
46−
47−if test -z "$NIX_CROSS_LDFLAGS_SET"; then
48− extra=(${extra[@]} $NIX_CROSS_LDFLAGS)
49− extraBefore=(${extraBefore[@]} $NIX_CROSS_LDFLAGS_BEFORE)
50−fi
51−
52−
53−# Add all used dynamic libraries to the rpath.
54−if test "$NIX_DONT_SET_RPATH" != "1"; then
55−
56− # First, find all -L... switches.
57− allParams=("${params[@]}" ${extra[@]})
58− libPath=""
59− addToLibPath() {
60− local path="$1"
61− if test "${path:0:1}" != "/"; then return 0; fi
62− case "$path" in
63− *..*|*./*|*/.*|*//*)
64− local path2
65− if path2=$(readlink -f "$path"); then
66− path="$path2"
67− fi
68− ;;
69− esac
70− case $libPath in
71− *\ $path\ *) return 0 ;;
72− esac
73− libPath="$libPath $path "
74− }
75− n=0
76− while test $n -lt ${#allParams[*]}; do
77− p=${allParams[n]}
78− p2=${allParams[$((n+1))]}
79− if test "${p:0:3}" = "-L/"; then
80− addToLibPath ${p:2}
81− elif test "$p" = "-L"; then
82− addToLibPath ${p2}
83− n=$((n + 1))
84− fi
85− n=$((n + 1))
86− done
87−
88− # Second, for each -l... switch, find the directory containing the
89− # library and add it to the rpath.
90− rpath=""
91− addToRPath() {
92− # If the path is not in the store, don't add it to the rpath.
93− # This typically happens for libraries in /tmp that are later
94− # copied to $out/lib. If not, we're screwed.
95− if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
96− case $rpath in
97− *\ $1\ *) return 0 ;;
98− esac
99− rpath="$rpath $1 "
100− }
101− findLib() {
102− for i in $libPath; do
103− if test -f $i/lib$1.so; then
104− addToRPath $i
105− fi
106− done
107− }
108− n=0
109− while test $n -lt ${#allParams[*]}; do
110− p=${allParams[n]}
111− p2=${allParams[$((n+1))]}
112− if test "${p:0:2}" = "-l"; then
113− findLib ${p:2}
114− elif test "$p" = "-l"; then
115− # I haven't seen `-l foo', but you never know...
116− findLib ${p2}
117− n=$((n + 1))
118− fi
119− n=$((n + 1))
120− done
121−
122− # Finally, add `-rpath' switches.
123− for i in $rpath; do
124− extra=(${extra[@]} -rpath $i -rpath-link $i)
125− done
126−fi
127−
128−
129−# Optionally print debug info.
130−if test "$NIX_DEBUG" = "1"; then
131− echo "original flags to @ld@:" >&2
132− for i in "${params[@]}"; do
133− echo " $i" >&2
134− done
135− echo "extra flags to @ld@:" >&2
136− for i in ${extra[@]}; do
137− echo " $i" >&2
138− done
139−fi
140−
141−if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
142− source "$NIX_LD_WRAPPER_EXEC_HOOK"
143−fi
144−
145−exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
pkgs/build-support/gcc-cross-wrapper/setup-hook.shdeleted−90
@@ -1,90 +0,0 @@
1−NIX_CROSS_CFLAGS_COMPILE=""
2−NIX_CROSS_LDFLAGS=""
3−
4−crossAddCVars () {
5− if test -d $1/include; then
6− export NIX_CROSS_CFLAGS_COMPILE="$NIX_CROSS_CFLAGS_COMPILE -I$1/include"
7− fi
8−
9− if test -d $1/lib; then
10− export NIX_CROSS_LDFLAGS="$NIX_CROSS_LDFLAGS -L$1/lib -rpath-link $1/lib"
11− fi
12−}
13−
14−crossEnvHooks+=(crossAddCVars)
15−
16−crossStripDirs() {
17− local dirs="$1"
18− local stripFlags="$2"
19− local dirsNew=
20−
21− for d in ${dirs}; do
22− if test -d "$prefix/$d"; then
23− dirsNew="${dirsNew} $prefix/$d "
24− fi
25− done
26− dirs=${dirsNew}
27−
28− if test -n "${dirs}"; then
29− header "cross stripping (with flags $stripFlags) in $dirs"
30− # libc_nonshared.a should never be stripped, or builds will break.
31− find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true
32− stopNest
33− fi
34−}
35−
36−crossStrip () {
37− # In cross_renaming we may rename dontCrossStrip to dontStrip, and
38− # dontStrip to dontNativeStrip.
39− # TODO: strip _only_ ELF executables, and return || fail here...
40− if test -z "$dontCrossStrip"; then
41− stripDebugList=${stripDebugList:-lib lib64 libexec bin sbin}
42− if test -n "$stripDebugList"; then
43− crossStripDirs "$stripDebugList" "${stripDebugFlags:--S}"
44− fi
45−
46− stripAllList=${stripAllList:-}
47− if test -n "$stripAllList"; then
48− crossStripDirs "$stripAllList" "${stripAllFlags:--s}"
49− fi
50− fi
51−}
52−
53−preDistPhases=(${preDistPhases[@]} crossStrip)
54−
55−
56−# Note: these come *after* $out in the PATH (see setup.sh).
57−
58−if test -n "@gcc@"; then
59− PATH=$PATH:@gcc@/bin
60−fi
61−
62−if test -n "@binutils@"; then
63− PATH=$PATH:@binutils@/bin
64−fi
65−
66−if test -n "@libc@"; then
67− PATH=$PATH:@libc@/bin
68− crossAddCVars @libc@
69−fi
70−
71−if test "$dontSetConfigureCross" != "1"; then
72− configureFlags="$configureFlags --build=$system --host=$crossConfig"
73−fi
74−# Disabling the tests when cross compiling, as usually the tests are meant for
75−# native compilations.
76−doCheck=""
77−
78−# Don't strip foreign binaries with native "strip" tool.
79−dontStrip=1
80−
81−# Add the output as an rpath.
82−if test "$NIX_NO_SELF_RPATH" != "1"; then
83− export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
84− if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
85− export NIX_CROSS_LDFLAGS="-rpath $out/lib64 -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
86− fi
87−fi
88−
89−export CC=${crossConfig}-gcc
90−export CXX=${crossConfig}-g++
pkgs/build-support/gcc-cross-wrapper/utils.shdeleted−24
@@ -1,24 +0,0 @@
1−skip () {
2− if test "$NIX_DEBUG" = "1"; then
3− echo "skipping impure path $1" >&2
4− fi
5−}
6−
7−
8−# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but
9−# `/nix/store/.../lib/foo.so' isn't.
10−badPath() {
11− local p=$1
12−
13− # Relative paths are okay (since they're presumably relative to
14− # the temporary build directory).
15− if test "${p:0:1}" != "/"; then return 1; fi
16−
17− # Otherwise, the path should refer to the store or some temporary
18− # directory (including the build directory).
19− test \
20− "$p" != "/dev/null" -a \
21− "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
22− "${p:0:4}" != "/tmp" -a \
23− "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
24−}
pkgs/build-support/gcc-wrapper-old/default.nix−1
@@ -61,7 +61,6 @@ stdenv.mkDerivation {
6161
6262 crossAttrs = {
6363 shell = shell.crossDrv + shell.crossDrv.shellPath;
64− libc = stdenv.ccCross.libc;
6564 coreutils = coreutils.crossDrv;
6665 binutils = binutils.crossDrv;
6766 gcc = gcc.crossDrv;
pkgs/development/compilers/gcc/4.5/default.nix+1−1
@@ -283,7 +283,7 @@ stdenv.mkDerivation ({
283283 NM_FOR_TARGET = "${targetPlatform.config}-nm";
284284 CXX_FOR_TARGET = "${targetPlatform.config}-g++";
285285 # If we are making a cross compiler, cross != null
286− NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
286+ NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
287287 dontStrip = true;
288288 configureFlags = ''
289289 ${if enableMultilib then "" else "--disable-multilib"}
pkgs/development/compilers/gcc/4.8/default.nix+1−1
@@ -401,7 +401,7 @@ stdenv.mkDerivation ({
401401 NM_FOR_TARGET = "${targetPlatform.config}-nm";
402402 CXX_FOR_TARGET = "${targetPlatform.config}-g++";
403403 # If we are making a cross compiler, cross != null
404− NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
404+ NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
405405 dontStrip = true;
406406 configureFlags = ''
407407 ${if enableMultilib then "" else "--disable-multilib"}
pkgs/development/compilers/gcc/4.9/default.nix+1−1
@@ -407,7 +407,7 @@ stdenv.mkDerivation ({
407407 NM_FOR_TARGET = "${targetPlatform.config}-nm";
408408 CXX_FOR_TARGET = "${targetPlatform.config}-g++";
409409 # If we are making a cross compiler, cross != null
410− NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
410+ NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
411411 dontStrip = true;
412412 configureFlags = ''
413413 ${if enableMultilib then "" else "--disable-multilib"}
pkgs/development/compilers/gcc/5/default.nix+5−1
@@ -35,6 +35,7 @@
3535, cloog # unused; just for compat with gcc4, as we override the parameter on some places
3636, darwin ? null
3737, buildPlatform, hostPlatform, targetPlatform
38+, buildPackages
3839}:
3940
4041assert langJava -> zip != null && unzip != null
@@ -312,6 +313,7 @@ stdenv.mkDerivation ({
312313 ++ (optionals langJava [ boehmgc zip unzip ])
313314 ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
314315 ++ (optionals (targetPlatform != hostPlatform) [binutils])
316+ ++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc])
315317 ++ (optionals langAda [gnatboot])
316318 ++ (optionals langVhdl [gnat])
317319
@@ -422,7 +424,7 @@ stdenv.mkDerivation ({
422424 NM_FOR_TARGET = "${targetPlatform.config}-nm";
423425 CXX_FOR_TARGET = "${targetPlatform.config}-g++";
424426 # If we are making a cross compiler, cross != null
425− NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
427+ NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
426428 dontStrip = true;
427429 configureFlags = ''
428430 ${if enableMultilib then "" else "--disable-multilib"}
@@ -449,6 +451,8 @@ stdenv.mkDerivation ({
449451 )
450452 }
451453 ${if langAda then " --enable-libada" else ""}
454+ --build=${buildPlatform.config}
455+ --host=${hostPlatform.config}
452456 --target=${targetPlatform.config}
453457 ${xwithArch}
454458 ${xwithCpu}
pkgs/development/compilers/gcc/6/default.nix+1−1
@@ -404,7 +404,7 @@ stdenv.mkDerivation ({
404404 NM_FOR_TARGET = "${targetPlatform.config}-nm";
405405 CXX_FOR_TARGET = "${targetPlatform.config}-g++";
406406 # If we are making a cross compiler, cross != null
407− NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
407+ NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
408408 dontStrip = true;
409409 configureFlags = ''
410410 ${if enableMultilib then "" else "--disable-multilib"}
pkgs/development/compilers/gcc/snapshot/default.nix+1−1
@@ -405,7 +405,7 @@ stdenv.mkDerivation ({
405405 NM_FOR_TARGET = "${targetPlatform.config}-nm";
406406 CXX_FOR_TARGET = "${targetPlatform.config}-g++";
407407 # If we are making a cross compiler, cross != null
408− NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
408+ NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
409409 dontStrip = true;
410410 configureFlags = ''
411411 ${if enableMultilib then "" else "--disable-multilib"}
pkgs/development/compilers/ghc/head.nix+9−9
@@ -101,26 +101,26 @@ in stdenv.mkDerivation (rec {
101101 '';
102102
103103 configureFlags = [
104− "CC=${stdenv.ccCross}/bin/${cross.config}-cc"
105− "LD=${stdenv.binutils}/bin/${cross.config}-ld"
106− "AR=${stdenv.binutils}/bin/${cross.config}-ar"
107− "NM=${stdenv.binutils}/bin/${cross.config}-nm"
108− "RANLIB=${stdenv.binutils}/bin/${cross.config}-ranlib"
104+ "CC=${stdenv.cc}/bin/${cross.config}-cc"
105+ "LD=${stdenv.cc}/bin/${cross.config}-ld"
106+ "AR=${stdenv.cc}/bin/${cross.config}-ar"
107+ "NM=${stdenv.cc}/bin/${cross.config}-nm"
108+ "RANLIB=${stdenv.cc}/bin/${cross.config}-ranlib"
109109 "--target=${cross.config}"
110110 "--enable-bootstrap-with-devel-snapshot"
111111 ] ++
112112 # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
113113 lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
114114
115− buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ];
115+ buildInputs = commonBuildInputs;
116116
117− dontSetConfigureCross = true;
117+ configurePlatforms = [];
118118
119119 passthru = {
120120 inherit bootPkgs cross;
121121
122− cc = "${stdenv.ccCross}/bin/${cross.config}-cc";
122+ cc = "${stdenv.cc}/bin/${cross.config}-cc";
123123
124− ld = "${stdenv.binutils}/bin/${cross.config}-ld";
124+ ld = "${stdenv.cc}/bin/${cross.config}-ld";
125125 };
126126})
pkgs/development/compilers/rust/rustc.nix+3−1
@@ -10,6 +10,7 @@
1010, targetPatches
1111, targetToolchains
1212, doCheck ? true
13+, buildPlatform, hostPlatform
1314} @ args:
1415
1516let
@@ -137,7 +138,8 @@ stdenv.mkDerivation {
137138
138139 inherit doCheck;
139140
140− dontSetConfigureCross = true;
141+ ${if buildPlatform == hostPlatform then "dontSetConfigureCross" else null} = true;
142+ ${if buildPlatform != hostPlatform then "configurePlatforms" else null} = [];
141143
142144 # https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764
143145 # https://github.com/rust-lang/rust/issues/30181
pkgs/development/libraries/ffmpeg-full/default.nix+1−1
@@ -446,7 +446,7 @@ stdenv.mkDerivation rec {
446446 fi
447447 '';
448448 in {
449− dontSetConfigureCross = true;
449+ configurePlatforms = [];
450450 configureFlags = configureFlags ++ [
451451 "--cross-prefix=${stdenv.cross.config}-"
452452 "--enable-cross-compile"
pkgs/development/libraries/ffmpeg/generic.nix+1−1
@@ -187,7 +187,7 @@ stdenv.mkDerivation rec {
187187 fi
188188 '';
189189 in {
190− dontSetConfigureCross = true;
190+ configurePlatforms = [];
191191 configureFlags = configureFlags ++ [
192192 "--cross-prefix=${stdenv.cross.config}-"
193193 "--enable-cross-compile"
pkgs/development/libraries/libav/default.nix+1−1
@@ -105,7 +105,7 @@ let
105105 installCheckTarget = "check"; # tests need to be run *after* installation
106106
107107 crossAttrs = {
108− dontSetConfigureCross = true;
108+ configurePlatforms = [];
109109 configureFlags = configureFlags ++ [
110110 "--cross-prefix=${stdenv.cross.config}-"
111111 "--enable-cross-compile"
pkgs/development/libraries/libelf/cross-ar.patchnew file+11
@@ -0,0 +1,11 @@
1+--- a/lib/Makefile.in
2++++ b/lib/Makefile.in
3+@@ -27,7 +27,7 @@ installdirs = $(libdir) $(includedir) $(includedir)/libelf
4+
5+ CC = @CC@
6+ LD = @LD@
7+-AR = ar
8++AR ?= ar
9+ MV = mv -f
10+ RM = rm -f
11+ LN_S = @LN_S@
pkgs/development/libraries/libelf/default.nix+10−7
@@ -1,4 +1,7 @@
1−{ fetchurl, stdenv, gettext, glibc }:
1+{ stdenv, fetchurl
2+, gettext, glibc
3+, buildPlatform, hostPlatform
4+}:
25
36stdenv.mkDerivation rec {
47 name = "libelf-0.8.13";
@@ -8,20 +11,20 @@ stdenv.mkDerivation rec {
811 sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
912 };
1013
14+ # TODO(@Ericson2314) Make unconditional next hash break
15+ patches = if hostPlatform == buildPlatform then null else [
16+ ./cross-ar.patch
17+ ];
18+
1119 doCheck = true;
1220
1321 # FIXME needs gcc 4.9 in bootstrap tools
1422 hardeningDisable = [ "stackprotector" ];
1523
16− # For cross-compiling, native glibc is needed for the "gencat" program.
17− crossAttrs = {
18− nativeBuildInputs = [ gettext glibc ];
19− };
20−
2124 # Libelf's custom NLS macros fail to determine the catalog file extension on
2225 # Darwin, so disable NLS for now.
2326 # FIXME: Eventually make Gettext a build input on all platforms.
24− configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-nls";
27+ configureFlags = stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
2528
2629 nativeBuildInputs = [ gettext ];
2730
pkgs/development/libraries/libmpc/default.nix+6−2
@@ -1,4 +1,8 @@
1−{ fetchurl, stdenv, gmp, mpfr }:
1+{ stdenv, fetchurl
2+, gmp, mpfr
3+, buildPlatform, hostPlatform
4+}:
5+
26let
37 version = "1.0.3";
48in
@@ -14,7 +18,7 @@ stdenv.mkDerivation rec {
1418
1519 CFLAGS = "-I${gmp.dev}/include";
1620
17− doCheck = true;
21+ doCheck = hostPlatform == buildPlatform;
1822
1923 # FIXME needs gcc 4.9 in bootstrap tools
2024 hardeningDisable = [ "stackprotector" ];
pkgs/development/libraries/libsigsegv/default.nix+4−2
@@ -1,4 +1,6 @@
1−{ fetchurl, stdenv }:
1+{ stdenv, fetchurl
2+, buildPlatform, hostPlatform
3+}:
24
35stdenv.mkDerivation rec {
46 name = "libsigsegv-2.11";
@@ -8,7 +10,7 @@ stdenv.mkDerivation rec {
810 sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x";
911 };
1012
11− doCheck = true;
13+ doCheck = hostPlatform == buildPlatform;
1214
1315 meta = {
1416 homepage = http://www.gnu.org/software/libsigsegv/;
pkgs/development/libraries/libvpx/default.nix+1−1
@@ -148,7 +148,7 @@ stdenv.mkDerivation rec {
148148 isCygwin = stdenv.cross.libc == "msvcrt";
149149 isDarwin = stdenv.cross.libc == "libSystem";
150150 in {
151− dontSetConfigureCross = true;
151+ configurePlatforms = [];
152152 configureFlags = configureFlags ++ [
153153 #"--extra-cflags="
154154 #"--extra-cxxflags="
pkgs/development/libraries/libvpx/git.nix+1−1
@@ -156,7 +156,7 @@ stdenv.mkDerivation rec {
156156 isCygwin = stdenv.cross.libc == "msvcrt";
157157 isDarwin = stdenv.cross.libc == "libSystem";
158158 in {
159− dontSetConfigureCross = true;
159+ configurePlatforms = [];
160160 configureFlags = configureFlags ++ [
161161 #"--extra-cflags="
162162 #"--prefix="
pkgs/development/libraries/mpfr/default.nix+6−4
@@ -1,4 +1,6 @@
1−{ stdenv, fetchurl, gmp }:
1+{ stdenv, fetchurl, gmp
2+, buildPlatform, hostPlatform
3+}:
24
35stdenv.mkDerivation rec {
46 name = "mpfr-3.1.3";
@@ -19,10 +21,10 @@ stdenv.mkDerivation rec {
1921 hardeningDisable = [ "stackprotector" ];
2022
2123 configureFlags =
22− stdenv.lib.optional stdenv.isSunOS "--disable-thread-safe" ++
23− stdenv.lib.optional stdenv.is64bit "--with-pic";
24+ stdenv.lib.optional hostPlatform.isSunOS "--disable-thread-safe" ++
25+ stdenv.lib.optional hostPlatform.is64bit "--with-pic";
2426
25− doCheck = true;
27+ doCheck = hostPlatform == buildPlatform;
2628
2729 enableParallelBuilding = true;
2830
pkgs/development/libraries/pcre/default.nix+6−6
@@ -1,5 +1,7 @@
11{ stdenv, fetchurl
2−, windows ? null, variant ? null, pcre
2+, pcre, windows ? null
3+, buildPlatform, hostPlatform
4+, variant ? null
35}:
46
57with stdenv.lib;
@@ -31,7 +33,9 @@ in stdenv.mkDerivation rec {
3133
3234 patches = [ ./CVE-2017-7186.patch ];
3335
34− doCheck = with stdenv; !(isCygwin || isFreeBSD);
36+ buildInputs = optional (hostPlatform.libc == "msvcrt") windows.mingw_w64_pthreads;
37+
38+ doCheck = !(with hostPlatform; isCygwin || isFreeBSD) && hostPlatform == buildPlatform;
3539 # XXX: test failure on Cygwin
3640 # we are running out of stack on both freeBSDs on Hydra
3741
@@ -42,10 +46,6 @@ in stdenv.mkDerivation rec {
4246 ln -sf -t "$out/lib/" '${pcre.out}'/lib/libpcre{,posix}.{so.*.*.*,*dylib}
4347 '';
4448
45− crossAttrs = optionalAttrs (stdenv.cross.libc == "msvcrt") {
46− buildInputs = [ windows.mingw_w64_pthreads.crossDrv ];
47− };
48−
4949 meta = {
5050 homepage = "http://www.pcre.org/";
5151 description = "A library for Perl Compatible Regular Expressions";
pkgs/development/libraries/podofo/default.nix+5−9
@@ -1,5 +1,7 @@
11{ stdenv, fetchurl, cmake, zlib, freetype, libjpeg, libtiff, fontconfig
2−, gcc5, openssl, libpng, lua5, pkgconfig, libidn, expat }:
2+, openssl, libpng, lua5, pkgconfig, libidn, expat
3+, gcc5 # TODO(@Dridus) remove this at next hash break
4+}:
35
46stdenv.mkDerivation rec {
57 name = "podofo-0.9.5";
@@ -11,18 +13,12 @@ stdenv.mkDerivation rec {
1113
1214 propagatedBuildInputs = [ zlib freetype libjpeg libtiff fontconfig openssl libpng libidn expat ];
1315
14− # Does Linux really need gcc5? Darwin doesn't seem to...
16+ # TODO(@Dridus) remove the ++ ghc5 at next hash break
1517 nativeBuildInputs = [ cmake pkgconfig ] ++ stdenv.lib.optional stdenv.isLinux gcc5;
1618
17− # Does Linux really need libc here? Darwin doesn't seem to...
19+ # TODO(@Dridus) remove the ++ libc at next hash break
1820 buildInputs = [ lua5 ] ++ stdenv.lib.optional stdenv.isLinux stdenv.cc.libc;
1921
20− crossAttrs = {
21− propagatedBuildInputs = [ zlib.crossDrv freetype.crossDrv libjpeg.crossDrv
22− libtiff.crossDrv fontconfig.crossDrv openssl.crossDrv libpng.crossDrv
23− lua5.crossDrv stdenv.ccCross.libc ];
24− };
25−
2622 cmakeFlags = "-DPODOFO_BUILD_SHARED=ON -DPODOFO_BUILD_STATIC=OFF";
2723
2824 meta = {
pkgs/development/libraries/qt-4.x/4.8/default.nix+1−1
@@ -209,7 +209,7 @@ stdenv.mkDerivation rec {
209209 postInstall = ''
210210 cp bin/qmake* $out/bin
211211 '';
212− dontSetConfigureCross = true;
212+ configurePlatforms = [];
213213 dontStrip = true;
214214 } // optionalAttrs isMingw {
215215 propagatedBuildInputs = [ ];
pkgs/development/libraries/zlib/default.nix+9−3
@@ -1,4 +1,8 @@
1−{ stdenv, fetchurl, static ? false }:
1+{ stdenv
2+, fetchurl
3+, buildPlatform, hostPlatform
4+, static ? false
5+}:
26
37let version = "1.2.11"; in
48
@@ -24,7 +28,9 @@ stdenv.mkDerivation rec {
2428 setOutputFlags = false;
2529 outputDoc = "dev"; # single tiny man3 page
2630
27− preConfigure = ''
31+ # 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
32+ # cross building to avoid hash breakage. Once hash breakage is acceptable, remove preConfigure entirely.
33+ preConfigure = stdenv.lib.optionalString (hostPlatform == buildPlatform) ''
2834 if test -n "$crossConfig"; then
2935 export CC=$crossConfig-gcc
3036 fi
@@ -53,7 +59,7 @@ stdenv.mkDerivation rec {
5359
5460 crossAttrs = {
5561 dontStrip = static;
56− dontSetConfigureCross = true;
62+ configurePlatforms = [];
5763 } // stdenv.lib.optionalAttrs (stdenv.cross.libc == "msvcrt") {
5864 installFlags = [
5965 "BINARY_PATH=$(out)/bin"
pkgs/development/tools/misc/binutils/default.nix+2−1
@@ -50,7 +50,8 @@ stdenv.mkDerivation rec {
5050 ++ [ "info" ]
5151 ++ optional (targetPlatform == hostPlatform) "dev";
5252
53− nativeBuildInputs = [ bison ];
53+ nativeBuildInputs = [ bison ]
54+ ++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
5455 buildInputs = [ zlib ];
5556
5657 inherit noSysDirs;
pkgs/os-specific/linux/busybox/default.nix+9−12
@@ -1,8 +1,9 @@
1−{ stdenv, lib, fetchurl, glibc, musl
1+{ stdenv, lib, buildPackages, fetchurl
22, enableStatic ? false
33, enableMinimal ? false
4−, useMusl ? false
4+, useMusl ? false, musl
55, extraConfig ? ""
6+, buildPlatform, hostPlatform
67}:
78
89let
@@ -71,20 +72,16 @@ stdenv.mkDerivation rec {
7172 '';
7273
7374 postConfigure = lib.optionalString useMusl ''
74− makeFlagsArray+=("CC=gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib")
75+ makeFlagsArray+=("CC=${stdenv.cc.prefix}gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib")
7576 '';
7677
77− buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ];
78+ nativeBuildInputs = lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
7879
79− crossAttrs = {
80− extraCrossConfig = ''
81− CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cross.config}-"
82− '';
80+ buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ];
8381
84− postConfigure = stdenv.lib.optionalString useMusl ''
85− makeFlagsArray+=("CC=$crossConfig-gcc -isystem ${musl.crossDrv}/include -B${musl.crossDrv}/lib -L${musl.crossDrv}/lib")
86− '';
87− };
82+ extraCrossConfig = if hostPlatform == buildPlatform then null else ''
83+ CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
84+ '';
8885
8986 enableParallelBuilding = true;
9087
pkgs/os-specific/windows/mingw-w64/common.nixnew file+11
@@ -0,0 +1,11 @@
1+{ fetchurl }:
2+
3+rec {
4+ version = "4.0.6";
5+ name = "mingw-w64-${version}";
6+
7+ src = fetchurl {
8+ url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2";
9+ sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c";
10+ };
11+}
pkgs/os-specific/windows/mingw-w64/default.nix+5−34
@@ -1,36 +1,7 @@
1−{ stdenv, fetchurl, binutils ? null, gccCross ? null
2−, onlyHeaders ? false
3−, onlyPthreads ? false
4−}:
5−
6−let
7− version = "4.0.6";
8− name = "mingw-w64-${version}";
9−in
10−stdenv.mkDerivation ({
11− inherit name;
12−
13− src = fetchurl {
14− url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2";
15− sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c";
16− };
17−} //
18−(if onlyHeaders then {
19− name = name + "-headers";
20− preConfigure = ''
21− cd mingw-w64-headers
22− '';
23− configureFlags = "--without-crt";
24−} else if onlyPthreads then {
25− name = name + "-pthreads";
26− preConfigure = ''
27− cd mingw-w64-libraries/winpthreads
28− '';
29−} else {
30− buildInputs = [ gccCross binutils ];
31−
32− crossConfig = gccCross.crossConfig;
1+{ stdenv, callPackage, windows }:
332
3+stdenv.mkDerivation {
4+ inherit (callPackage ./common.nix {}) name src;
5+ buildInputs = [ windows.mingw_w64_headers ];
346 dontStrip = true;
35−})
36−)
7+}
pkgs/os-specific/windows/mingw-w64/headers.nixnew file+13
@@ -0,0 +1,13 @@
1+{ stdenvNoCC, callPackage }:
2+
3+let
4+ inherit (callPackage ./common.nix {}) name src;
5+
6+in stdenvNoCC.mkDerivation {
7+ name = name + "-headers";
8+ inherit src;
9+
10+ preConfigure = ''
11+ cd mingw-w64-headers
12+ '';
13+}
pkgs/os-specific/windows/mingw-w64/pthreads.nixnew file+13
@@ -0,0 +1,13 @@
1+{ stdenvNoCC, callPackage }:
2+
3+let
4+ inherit (callPackage ./common.nix {}) name src;
5+
6+in stdenvNoCC.mkDerivation {
7+ name = name + "-pthreads";
8+ inherit src;
9+
10+ preConfigure = ''
11+ cd mingw-w64-libraries/winpthreads
12+ '';
13+}
pkgs/shells/bash/4.4.nix+21−21
@@ -1,15 +1,16 @@
1−{ stdenv, fetchurl, readline70 ? null, interactive ? false, texinfo ? null
2−, binutils ? null, bison
1+{ stdenv, buildPackages
2+, fetchurl, readline70 ? null, texinfo ? null, binutils ? null, bison
3+, buildPlatform, hostPlatform
4+, interactive ? false
35}:
46
57assert interactive -> readline70 != null;
6−assert stdenv.isDarwin -> binutils != null;
8+assert hostPlatform.isDarwin -> binutils != null;
79
810let
911 version = "4.4";
1012 realName = "bash-${version}";
1113 shortName = "bash44";
12− baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline";
1314 sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq";
1415
1516 upstreamPatches =
@@ -22,7 +23,7 @@ let
2223 in
2324 import ./bash-4.4-patches.nix patch;
2425
25− inherit (stdenv.lib) optional optionalString;
26+ inherit (stdenv.lib) optional optionals;
2627in
2728
2829stdenv.mkDerivation rec {
@@ -52,26 +53,25 @@ stdenv.mkDerivation rec {
5253 patchFlags = "-p0";
5354
5455 patches = upstreamPatches
55− ++ optional stdenv.isCygwin ./cygwin-bash-4.3.33-1.src.patch;
56−
57− crossAttrs = {
58− configureFlags = baseConfigureFlags +
59− " bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" +
60− optionalString stdenv.isCygwin ''
61− --without-libintl-prefix --without-libiconv-prefix
62− --with-installed-readline
63− bash_cv_dev_stdin=present
64− bash_cv_dev_fd=standard
65− bash_cv_termcap_lib=libncurses
66− '';
67− };
68−
69− configureFlags = baseConfigureFlags;
56+ ++ optional hostPlatform.isCygwin ./cygwin-bash-4.3.33-1.src.patch;
57+
58+ configureFlags = [
59+ (if interactive then "--with-installed-readline" else "--disable-readline")
60+ ] ++ optionals (hostPlatform != buildPlatform) [
61+ "bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes"
62+ ] ++ optionals hostPlatform.isCygwin [
63+ "--without-libintl-prefix --without-libiconv-prefix"
64+ "--with-installed-readline"
65+ "bash_cv_dev_stdin=present"
66+ "bash_cv_dev_fd=standard"
67+ "bash_cv_termcap_lib=libncurses"
68+ ];
7069
7170 # Note: Bison is needed because the patches above modify parse.y.
7271 nativeBuildInputs = [bison]
7372 ++ optional (texinfo != null) texinfo
74− ++ optional stdenv.isDarwin binutils;
73+ ++ optional hostPlatform.isDarwin binutils
74+ ++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
7575
7676 buildInputs = optional interactive readline70;
7777
pkgs/stdenv/adapters.nix+40−16
@@ -56,16 +56,36 @@ rec {
5656
5757 # Return a modified stdenv that adds a cross compiler to the
5858 # builds.
59− makeStdenvCross = stdenv: cross: binutils: gccCross: stdenv // {
60−
61− # Overrides are surely not valid as packages built with this run on a
62− # different platform.
63− overrides = _: _: {};
64−
59+ makeStdenvCross = { stdenv
60+ , cc
61+ , buildPlatform, hostPlatform, targetPlatform
62+ } @ overrideArgs: let
63+ stdenv = overrideArgs.stdenv.override {
64+ # TODO(@Ericson2314): Cannot do this for now because then Nix thinks the
65+ # resulting derivation should be built on the host platform.
66+ #hostPlatform = buildPlatform;
67+ #targetPlatform = hostPlatform;
68+ inherit cc;
69+
70+ allowedRequisites = null;
71+
72+ # Overrides are surely not valid as packages built with this run on a
73+ # different platform.
74+ overrides = _: _: {};
75+ };
76+ in stdenv // {
6577 mkDerivation =
6678 { name ? "", buildInputs ? [], nativeBuildInputs ? []
6779 , propagatedBuildInputs ? [], propagatedNativeBuildInputs ? []
68− , selfNativeBuildInput ? false, ...
80+ , # Disabling the tests by default when cross compiling, as usually the
81+ # tests rely on being able to run produced binaries.
82+ doCheck ? false
83+ , configureFlags ? []
84+ , # Target is not included by default because most programs don't care.
85+ # Including it then would cause needless massive rebuilds.
86+ configurePlatforms ? args.crossAttrs.configurePlatforms or [ "build" "host" ]
87+ , selfNativeBuildInput ? args.crossAttrs.selfNativeBuildInput or false
88+ , ...
6989 } @ args:
7090
7191 let
@@ -88,17 +108,25 @@ rec {
88108 nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull;
89109 in
90110 stdenv.mkDerivation (args // {
91− name = name + "-" + cross.config;
111+ name = name + "-" + hostPlatform.config;
92112 nativeBuildInputs = nativeBuildInputs
93113 ++ nativeInputsFromBuildInputs
94− ++ [ gccCross binutils ]
95114 ++ stdenv.lib.optional selfNativeBuildInput nativeDrv
96115 # without proper `file` command, libtool sometimes fails
97116 # to recognize 64-bit DLLs
98− ++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file
99− ++ stdenv.lib.optional (cross.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook
117+ ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file
118+ ++ stdenv.lib.optional (hostPlatform.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook
100119 ;
101120
121+ inherit doCheck;
122+
123+ # This parameter is sometimes a string and sometimes a list, yuck
124+ configureFlags = let inherit (stdenv.lib) optional elem; in
125+ (if stdenv.lib.isString configureFlags then [configureFlags] else configureFlags)
126+ ++ optional (elem "build" configurePlatforms) "--build=${buildPlatform.config}"
127+ ++ optional (elem "host" configurePlatforms) "--host=${hostPlatform.config}"
128+ ++ optional (elem "target" configurePlatforms) "--target=${targetPlatform.config}";
129+
102130 # Cross-linking dynamic libraries, every buildInput should
103131 # be propagated because ld needs the -rpath-link to find
104132 # any library needed to link the program dynamically at
@@ -107,12 +135,8 @@ rec {
107135 propagatedBuildInputs = propagatedBuildInputs ++ buildInputs;
108136 propagatedNativeBuildInputs = propagatedNativeBuildInputs;
109137
110− crossConfig = cross.config;
138+ crossConfig = hostPlatform.config;
111139 } // args.crossAttrs or {});
112−
113− inherit gccCross binutils;
114− ccCross = gccCross;
115−
116140 };
117141
118142
pkgs/stdenv/cross/default.nix+9−9
@@ -31,15 +31,15 @@ in bootStages ++ [
3131 targetPlatform = crossSystem;
3232 inherit config overlays;
3333 selfBuild = false;
34− stdenv = if crossSystem.useiOSCross or false
35− then let
36− inherit (buildPackages.darwin.ios-cross) cc binutils;
37− in buildPackages.makeStdenvCross
38− buildPackages.stdenv crossSystem
39− binutils cc
40− else buildPackages.makeStdenvCross
41− buildPackages.stdenv crossSystem
42− buildPackages.binutils buildPackages.gccCrossStageFinal;
34+ stdenv = buildPackages.makeStdenvCross {
35+ inherit (buildPackages) stdenv;
36+ buildPlatform = localSystem;
37+ hostPlatform = crossSystem;
38+ targetPlatform = crossSystem;
39+ cc = if crossSystem.useiOSCross or false
40+ then buildPackages.darwin.ios-cross
41+ else buildPackages.gccCrossStageFinal;
42+ };
4343 })
4444
4545]
pkgs/stdenv/darwin/default.nix+4
@@ -73,6 +73,8 @@ in rec {
7373 nativeTools = true;
7474 nativePrefix = bootstrapTools;
7575 nativeLibc = false;
76+ hostPlatform = localSystem;
77+ targetPlatform = localSystem;
7678 libc = last.pkgs.darwin.Libsystem;
7779 isClang = true;
7880 cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
@@ -295,6 +297,8 @@ in rec {
295297 inherit shell;
296298 nativeTools = false;
297299 nativeLibc = false;
300+ hostPlatform = localSystem;
301+ targetPlatform = localSystem;
298302 inherit (pkgs) coreutils binutils gnugrep;
299303 inherit (pkgs.darwin) dyld;
300304 cc = pkgs.llvmPackages.clang-unwrapped;
pkgs/stdenv/freebsd/default.nix+2
@@ -77,6 +77,8 @@ let inherit (localSystem) system; in
7777 nativeTools = true;
7878 nativePrefix = "/usr";
7979 nativeLibc = true;
80+ hostPlatform = localSystem;
81+ targetPlatform = localSystem;
8082 inherit (prevStage) stdenv;
8183 cc = {
8284 name = "clang-9.9.9";
pkgs/stdenv/linux/default.nix+4
@@ -76,6 +76,8 @@ let
7676 else lib.makeOverridable (import ../../build-support/cc-wrapper) {
7777 nativeTools = false;
7878 nativeLibc = false;
79+ hostPlatform = localSystem;
80+ targetPlatform = localSystem;
7981 cc = prevStage.gcc-unwrapped;
8082 isGNU = true;
8183 libc = prevStage.glibc;
@@ -239,6 +241,8 @@ in
239241 nativeTools = false;
240242 nativeLibc = false;
241243 isGNU = true;
244+ hostPlatform = localSystem;
245+ targetPlatform = localSystem;
242246 cc = prevStage.gcc-unwrapped;
243247 libc = self.glibc;
244248 inherit (self) stdenv binutils coreutils gnugrep;
pkgs/stdenv/linux/make-bootstrap-tools-cross.nix−1
@@ -81,7 +81,6 @@ rec {
8181 nativeBuildInputs = [
8282 pkgs.buildPackages.nukeReferences
8383 pkgs.buildPackages.cpio
84− pkgs.buildPackages.binutils
8584 ];
8685
8786 buildCommand = ''
pkgs/stdenv/native/default.nix+2
@@ -125,6 +125,8 @@ in
125125 "i686-solaris" = "/usr/gnu";
126126 "x86_64-solaris" = "/opt/local/gcc47";
127127 }.${system} or "/usr";
128+ hostPlatform = localSystem;
129+ targetPlatform = localSystem;
128130 inherit stdenv;
129131 };
130132
pkgs/stdenv/nix/default.nix+2
@@ -30,6 +30,8 @@ bootStages ++ [
3030 nativeTools = false;
3131 nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr";
3232 nativeLibc = true;
33+ hostPlatform = localSystem;
34+ targetPlatform = localSystem;
3335 inherit stdenv;
3436 inherit (prevStage) binutils coreutils gnugrep;
3537 cc = prevStage.gcc.cc;
pkgs/tools/archivers/unzip/cross-cc.patchnew file+12
@@ -0,0 +1,12 @@
1+--- a/unix/Makefile
2++++ b/unix/Makefile
3+@@ -42,9 +42,7 @@
4+ # such as -DDOSWILD).
5+
6+ # UnZip flags
7+-CC = cc# try using "gcc" target rather than changing this (CC and LD
8+ LD = $(CC)# must match, else "unresolved symbol: ___main" is possible)
9+-AS = as
10+ LOC = $(D_USE_BZ2) $(LOCAL_UNZIP)
11+ AF = $(LOC)
12+ CFLAGS = -O
pkgs/tools/archivers/unzip/default.nix+8−4
@@ -1,5 +1,8 @@
1−{ stdenv, fetchurl, bzip2
2−, enableNLS ? false, libnatspec }:
1+{ stdenv, fetchurl
2+, bzip2
3+, enableNLS ? false, libnatspec
4+, buildPlatform, hostPlatform
5+}:
36
47stdenv.mkDerivation {
58 name = "unzip-6.0";
@@ -25,14 +28,15 @@ stdenv.mkDerivation {
2528 url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1";
2629 name = "unzip-6.0-natspec.patch";
2730 sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
28− });
31+ })
32+ ++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch;
2933
3034 nativeBuildInputs = [ bzip2 ];
3135 buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec;
3236
3337 makefile = "unix/Makefile";
3438
35− NIX_LDFLAGS = [ "-lbz2" ] ++ stdenv.lib.optional enableNLS "-lnatspec";
39+ ${"NIX_${stdenv.cc.infixSalt_}LDFLAGS"} = [ "-lbz2" ] ++ stdenv.lib.optional enableNLS "-lnatspec";
3640
3741 buildFlags = "generic D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2";
3842
pkgs/tools/misc/coreutils/default.nix+37−39
@@ -1,8 +1,9 @@
1−{ lib, stdenv, buildPackages, fetchurl, perl, xz, gmp ? null
1+{ stdenv, lib, buildPackages
2+, autoconf, automake114x, texinfo, fetchurl, perl, xz, libiconv, gmp ? null
3+, hostPlatform, buildPlatform
24, aclSupport ? false, acl ? null
35, attrSupport ? false, attr ? null
46, selinuxSupport? false, libselinux ? null, libsepol ? null
5−, autoconf, automake114x, texinfo
67, withPrefix ? false
78, singleBinary ? "symlinks" # you can also pass "shebangs" or false
89}:
@@ -23,10 +24,10 @@ stdenv.mkDerivation rec {
2324 # FIXME needs gcc 4.9 in bootstrap tools
2425 hardeningDisable = [ "stackprotector" ];
2526
26− patches = optional stdenv.isCygwin ./coreutils-8.23-4.cygwin.patch;
27+ patches = optional hostPlatform.isCygwin ./coreutils-8.23-4.cygwin.patch;
2728
2829 # The test tends to fail on btrfs and maybe other unusual filesystems.
29− postPatch = optionalString (!stdenv.isDarwin) ''
30+ postPatch = optionalString (!hostPlatform.isDarwin) ''
3031 sed '2i echo Skipping dd sparse test && exit 0' -i ./tests/dd/sparse.sh
3132 sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh
3233 sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh
@@ -39,58 +40,54 @@ stdenv.mkDerivation rec {
3940 configureFlags =
4041 optional (singleBinary != false)
4142 ("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}")
42− ++ optional stdenv.isSunOS "ac_cv_func_inotify_init=no"
43− ++ optional withPrefix "--program-prefix=g";
43+ ++ optional hostPlatform.isSunOS "ac_cv_func_inotify_init=no"
44+ ++ optional withPrefix "--program-prefix=g"
45+ ++ optionals (hostPlatform != buildPlatform && hostPlatform.libc == "glibc") [
46+ # TODO(19b98110126fde7cbb1127af7e3fe1568eacad3d): Needed for fstatfs() I
47+ # don't know why it is not properly detected cross building with glibc.
48+ "fu_cv_sys_stat_statfs2_bsize=yes"
49+ ];
50+
4451
4552 buildInputs = [ gmp ]
4653 ++ optional aclSupport acl
4754 ++ optional attrSupport attr
48− ++ optionals stdenv.isCygwin [ autoconf automake114x texinfo ] # due to patch
49− ++ optionals selinuxSupport [ libselinux libsepol ];
50−
51− crossAttrs = {
52− buildInputs = [ gmp.crossDrv ]
53− ++ optional aclSupport acl.crossDrv
54− ++ optional attrSupport attr.crossDrv
55− ++ optionals selinuxSupport [ libselinux.crossDrv libsepol.crossDrv ]
56− ++ optional (stdenv ? ccCross.libc.libiconv)
57− stdenv.ccCross.libc.libiconv.crossDrv;
58−
59− # Prevents attempts of running 'help2man' on cross-built binaries.
60− PERL = "missing";
61−
62− # Works around a bug with 8.26:
63− # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
64− preInstall = ''
65− sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
66− '';
67−
68− postInstall = ''
69− rm $out/share/man/man1/*
70− cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
71− '';
72−
73− # Needed for fstatfs()
74− # I don't know why it is not properly detected cross building with glibc.
75− configureFlags = [ "fu_cv_sys_stat_statfs2_bsize=yes" ];
76− doCheck = false;
77− };
55+ ++ optionals hostPlatform.isCygwin [ autoconf automake114x texinfo ] # due to patch
56+ ++ optionals selinuxSupport [ libselinux libsepol ]
57+ # TODO(@Ericson2314): Investigate whether Darwin could benefit too
58+ ++ optional (hostPlatform != buildPlatform && hostPlatform.libc != "glibc") libiconv;
7859
7960 # The tests are known broken on Cygwin
8061 # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
8162 # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
8263 # and {Open,Free}BSD.
8364 # With non-standard storeDir: https://github.com/NixOS/nix/issues/512
84− doCheck = stdenv ? glibc && builtins.storeDir == "/nix/store";
65+ doCheck = hostPlatform == buildPlatform
66+ && hostPlatform.libc == "glibc"
67+ && builtins.storeDir == "/nix/store";
68+
69+ # Prevents attempts of running 'help2man' on cross-built binaries.
70+ ${if hostPlatform == buildPlatform then null else "PERL"} = "missing";
8571
8672 # Saw random failures like ‘help2man: can't get '--help' info from
8773 # man/sha512sum.td/sha512sum’.
8874 enableParallelBuilding = false;
8975
9076 NIX_LDFLAGS = optionalString selinuxSupport "-lsepol";
91− FORCE_UNSAFE_CONFIGURE = optionalString stdenv.isSunOS "1";
77+ FORCE_UNSAFE_CONFIGURE = optionalString hostPlatform.isSunOS "1";
78+
79+ makeFlags = optionalString hostPlatform.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0";
80+
81+ # Works around a bug with 8.26:
82+ # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
83+ ${if hostPlatform == buildPlatform then null else "preInstall"} = ''
84+ sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
85+ '';
9286
93− makeFlags = optionalString stdenv.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0";
87+ ${if hostPlatform == buildPlatform then null else "postInstall"} = ''
88+ rm $out/share/man/man1/*
89+ cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
90+ '';
9491
9592 meta = {
9693 homepage = http://www.gnu.org/software/coreutils/;
@@ -109,4 +106,5 @@ stdenv.mkDerivation rec {
109106
110107 maintainers = [ maintainers.eelco ];
111108 };
109+
112110}
pkgs/tools/misc/findutils/default.nix+11−8
@@ -1,4 +1,9 @@
1−{ stdenv, fetchurl, coreutils }:
1+{ stdenv, fetchurl
2+, coreutils
3+, buildPlatform, hostPlatform
4+}:
5+
6+let inherit (stdenv.lib) optionals; in
27
38stdenv.mkDerivation rec {
49 name = "findutils-4.6.0";
@@ -10,20 +15,18 @@ stdenv.mkDerivation rec {
1015
1116 patches = [ ./memory-leak.patch ./no-install-statedir.patch ];
1217
13− buildInputs = [ coreutils ]; # bin/updatedb script needs to call sort
18+ buildInputs = optionals (hostPlatform == buildPlatform) [ coreutils ]; # bin/updatedb script needs to call sort
1419
1520 # Since glibc-2.25 the i686 tests hang reliably right after test-sleep.
16− doCheck = !stdenv.isDarwin && (stdenv.system != "i686-linux");
21+ doCheck
22+ = !hostPlatform.isDarwin
23+ && !(hostPlatform.libc == "glibc" && hostPlatform.isi686)
24+ && hostPlatform == buildPlatform;
1725
1826 outputs = [ "out" "info" ];
1927
2028 configureFlags = [ "--localstatedir=/var/cache" ];
2129
22− crossAttrs = {
23− # Fix the 'buildInputs = [ coreutils ]' above - that adds the cross coreutils to PATH :(
24− propagatedBuildInputs = [ ];
25− };
26−
2730 enableParallelBuilding = true;
2831
2932 meta = {
pkgs/tools/misc/xburst-tools/default.nix+3−2
@@ -1,5 +1,6 @@
11{ stdenv, fetchgit, libusb, libusb1, autoconf, automake, confuse, pkgconfig
2−, gccCross ? null }:
2+, gccCross ? null, crossPrefix
3+}:
34
45let
56 version = "2011-12-26";
@@ -18,7 +19,7 @@ stdenv.mkDerivation {
1819 '';
1920
2021 configureFlags = if gccCross != null then
21− "--enable-firmware CROSS_COMPILE=${gccCross.crossConfig}-"
22+ "--enable-firmware CROSS_COMPILE=${crossPrefix}-"
2223 else "";
2324
2425 # Not to strip cross build binaries (this is for the gcc-cross-wrapper)
pkgs/tools/networking/dropbear/default.nix−7
@@ -22,13 +22,6 @@ stdenv.mkDerivation rec {
2222 makeFlags=VPATH=`cat $NIX_CC/nix-support/orig-libc`/lib
2323 '';
2424
25− crossAttrs = {
26− # This works for uclibc, at least.
27− preConfigure = ''
28− makeFlags=VPATH=`cat ${stdenv.ccCross}/nix-support/orig-libc`/lib
29− '';
30− };
31−
3225 patches = [
3326 # Allow sessions to inherit the PATH from the parent dropbear.
3427 # Otherwise they only get the usual /bin:/usr/bin kind of PATH
pkgs/tools/system/ddrescue/default.nix+12−2
@@ -1,4 +1,9 @@
1−{ stdenv, fetchurl, lzip }:
1+{ stdenv
2+, fetchurl, lzip
3+, hostPlatform, buildPlatform
4+}:
5+
6+let inherit (stdenv.lib) optionals; in
27
38stdenv.mkDerivation rec {
49 name = "ddrescue-1.22";
@@ -10,7 +15,12 @@ stdenv.mkDerivation rec {
1015
1116 nativeBuildInputs = [ lzip ];
1217
13− doCheck = true;
18+ doCheck = hostPlatform == buildPlatform;
19+
20+ ${if hostPlatform != buildPlatform then "crossPlatforms" else null} = [ ];
21+ ${if hostPlatform != buildPlatform then "configureFlags" else null} = [
22+ "CXX=${stdenv.cc.prefix}c++"
23+ ];
1424
1525 meta = with stdenv.lib; {
1626 description = "GNU ddrescue, a data recovery tool";
pkgs/tools/text/gnupatch/default.nix+8−5
@@ -1,4 +1,7 @@
1−{ stdenv, fetchurl, ed }:
1+{ stdenv, fetchurl
2+, ed
3+, buildPlatform, hostPlatform
4+}:
25
36stdenv.mkDerivation rec {
47 name = "patch-2.7.5";
@@ -10,11 +13,11 @@ stdenv.mkDerivation rec {
1013
1114 buildInputs = stdenv.lib.optional doCheck ed;
1215
13− crossAttrs = {
14− configureFlags = [ "ac_cv_func_strnlen_working=yes" ];
15− };
16+ configureFlags = if hostPlatform == buildPlatform then null else [
17+ "ac_cv_func_strnlen_working=yes"
18+ ];
1619
17− doCheck = true;
20+ doCheck = hostPlatform == buildPlatform;
1821
1922 meta = {
2023 description = "GNU Patch, a program to apply differences to files";
pkgs/top-level/all-packages.nix+33−33
@@ -4816,15 +4816,16 @@ with pkgs;
48164816
48174817 x11_ssh_askpass = callPackage ../tools/networking/x11-ssh-askpass { };
48184818
4819− xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools {
4819+ xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools rec {
48204820 # It needs a cross compiler for mipsel to build the firmware it will
48214821 # load into the Ben Nanonote
4822+ crossPrefix = "mipsel-unknown-linux";
48224823 gccCross =
48234824 let
48244825 pkgsCross = nixpkgsFun {
48254826 # Ben Nanonote system
48264827 crossSystem = {
4827− config = "mipsel-unknown-linux";
4828+ config = crossPrefix;
48284829 bigEndian = true;
48294830 arch = "mips";
48304831 float = "soft";
@@ -4843,7 +4844,7 @@ with pkgs;
48434844 };
48444845 };
48454846 in
4846− pkgsCross.gccCrossStageStatic;
4847+ pkgsCross.buildPackages.gccCrossStageStatic;
48474848 };
48484849
48494850 xclip = callPackage ../tools/misc/xclip { };
@@ -5163,13 +5164,21 @@ with pkgs;
51635164
51645165 gccApple = throw "gccApple is no longer supported";
51655166
5167+ # Can't just overrideCC, because then the stdenv-cross mkDerivation will be
5168+ # thrown away. TODO: find a better solution for this.
5169+ crossLibcStdenv = buildPackages.makeStdenvCross {
5170+ inherit (buildPackages.buildPackages) stdenv;
5171+ inherit buildPlatform hostPlatform targetPlatform;
5172+ cc = buildPackages.gccCrossStageStatic;
5173+ };
5174+
51665175 gccCrossStageStatic = assert targetPlatform != buildPlatform; let
51675176 libcCross1 =
5168− if targetPlatform.libc == "msvcrt" then windows.mingw_w64_headers
5177+ if targetPlatform.libc == "msvcrt" then __targetPackages.windows.mingw_w64_headers
51695178 else if targetPlatform.libc == "libSystem" then darwin.xcode
51705179 else null;
5171− in wrapGCCCross {
5172− gcc = forcedNativePackages.gcc.cc.override {
5180+ in wrapCCCross {
5181+ cc = forcedNativePackages.gcc.cc.override {
51735182 crossStageStatic = true;
51745183 langCC = false;
51755184 libcCross = libcCross1;
@@ -5179,19 +5188,17 @@ with pkgs;
51795188 };
51805189 libc = libcCross1;
51815190 inherit (forcedNativePackages) binutils;
5182− cross = targetPlatform;
51835191 };
51845192
51855193 # Only needed for mingw builds
5186− gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapGCCCross {
5187− gcc = gccCrossStageStatic.gcc;
5194+ gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapCCCross {
5195+ cc = gccCrossStageStatic.gcc;
51885196 libc = windows.mingw_headers2;
51895197 inherit (forcedNativePackages) binutils;
5190− cross = targetPlatform;
51915198 };
51925199
5193− gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapGCCCross {
5194− gcc = forcedNativePackages.gcc.cc.override {
5200+ gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapCCCross {
5201+ cc = forcedNativePackages.gcc.cc.override {
51955202 crossStageStatic = false;
51965203
51975204 # Why is this needed?
@@ -5199,7 +5206,6 @@ with pkgs;
51995206 };
52005207 libc = libcCross;
52015208 inherit (forcedNativePackages) binutils;
5202− cross = targetPlatform;
52035209 };
52045210
52055211 gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 {
@@ -5924,14 +5930,19 @@ with pkgs;
59245930 libc = glibc;
59255931 };
59265932
5927− wrapGCCCross =
5928− {gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
5933+ wrapCCCross =
5934+ {cc, libc, binutils, shell ? "", name ? "gcc-cross-wrapper"}:
59295935
5930− forcedNativePackages.callPackage ../build-support/gcc-cross-wrapper {
5936+ forcedNativePackages.ccWrapperFun {
59315937 nativeTools = false;
59325938 nativeLibc = false;
59335939 noLibc = (libc == null);
5934− inherit gcc binutils libc shell name cross;
5940+
5941+ dyld = if stdenv.isDarwin then darwin.dyld else null;
5942+ isGNU = cc.isGNU or false;
5943+ isClang = cc.isClang or false;
5944+
5945+ inherit cc binutils libc shell name;
59355946 };
59365947
59375948 # prolog
@@ -7798,13 +7809,7 @@ with pkgs;
77987809 # Being redundant to avoid cycles on boot. TODO: find a better way
77997810 glibcCross = callPackage ../development/libraries/glibc {
78007811 installLocales = config.glibc.locales or false;
7801− # Can't just overrideCC, because then the stdenv-cross mkDerivation will be
7802− # thrown away. TODO: find a better solution for this.
7803− stdenv = buildPackages.makeStdenvCross
7804− buildPackages.buildPackages.stdenv
7805− buildPackages.targetPlatform
7806− buildPackages.binutils
7807− buildPackages.gccCrossStageStatic;
7812+ stdenv = crossLibcStdenv;
78087813 };
78097814
78107815 # We can choose:
@@ -7813,7 +7818,7 @@ with pkgs;
78137818 # hack fixes the hack, *sigh*.
78147819 /**/ if name == "glibc" then __targetPackages.glibcCross or glibcCross
78157820 else if name == "uclibc" then uclibcCross
7816− else if name == "msvcrt" then windows.mingw_w64
7821+ else if name == "msvcrt" then __targetPackages.windows.mingw_w64 or windows.mingw_w64
78177822 else if name == "libSystem" then darwin.xcode
78187823 else throw "Unknown libc";
78197824
@@ -12571,17 +12576,12 @@ with pkgs;
1257112576 };
1257212577
1257312578 mingw_w64 = callPackage ../os-specific/windows/mingw-w64 {
12574− gccCross = gccCrossStageStatic;
12575− binutils = binutils;
12579+ stdenv = crossLibcStdenv;
1257612580 };
1257712581
12578− mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64 {
12579− onlyHeaders = true;
12580− };
12582+ mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64/headers.nix { };
1258112583
12582− mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64 {
12583− onlyPthreads = true;
12584− };
12584+ mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { };
1258512585
1258612586 pthreads = callPackage ../os-specific/windows/pthread-w32 {
1258712587 mingw_headers = mingw_headers3;