Merge some merged cross-compilation PRs into into staging

This commit is contained in:
John Ericson 2017-06-23 20:24:27 -04:00
commit 87fab3d6a5
63 changed files with 567 additions and 959 deletions

View File

@ -640,6 +640,16 @@ script) if it exists.</para>
true.</para></listitem> true.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>configurePlatforms</varname></term>
<listitem><para>
By default, when cross compiling, the configure script has <option>--build=...</option> and <option>--host=...</option> passed.
Packages can instead pass <literal>[ "build" "host" "target" ]</literal> or a subset to control exactly which platform flags are passed.
Compilers and other tools should use this to also pass the target platform, for example.
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.
</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>preConfigure</varname></term> <term><varname>preConfigure</varname></term>
<listitem><para>Hook executed at the start of the configure <listitem><para>Hook executed at the start of the configure

View File

@ -1,4 +1,7 @@
{stdenv, fetchurl, alsaLib }: { stdenv
, fetchurl, alsaLib
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "mpg123-1.23.8"; name = "mpg123-1.23.8";
@ -10,10 +13,8 @@ stdenv.mkDerivation rec {
buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib; buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
crossAttrs = { ${if buildPlatform != hostPlatform then "configureFlags" else null} =
configureFlags = if stdenv.cross ? mpg123 then stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";
"--with-cpu=${stdenv.cross.mpg123.cpu}" else "";
};
meta = { meta = {
description = "Fast console MPEG Audio Player and decoder library"; description = "Fast console MPEG Audio Player and decoder library";

View File

@ -1,4 +1,6 @@
{ fetchurl, stdenv }: { stdenv, fetchurl
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "ed-${version}"; name = "ed-${version}";
@ -28,11 +30,12 @@ stdenv.mkDerivation rec {
make: *** [check] Error 127 make: *** [check] Error 127
*/ */
doCheck = !stdenv.isDarwin; doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform);
crossAttrs = { configureFlags = if hostPlatform == buildPlatform then null else [
compileFlags = [ "CC=${stdenv.cross.config}-gcc" ]; "--exec-prefix=${stdenv.cc.prefix}"
}; "CC=${stdenv.cc.prefix}cc"
];
meta = { meta = {
description = "An implementation of the standard Unix editor"; description = "An implementation of the standard Unix editor";

View File

@ -6,7 +6,9 @@
sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c"; sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c";
} }
# apple frameworks # apple frameworks
, Carbon, Cocoa }: , Carbon, Cocoa
, buildPlatform, hostPlatform
}:
let let
common = callPackage ./common.nix {}; common = callPackage ./common.nix {};
@ -17,12 +19,26 @@ stdenv.mkDerivation rec {
inherit (common) version src postPatch hardeningDisable enableParallelBuilding meta; inherit (common) version src postPatch hardeningDisable enableParallelBuilding meta;
buildInputs = [ ncurses pkgconfig ] buildInputs = [ ncurses pkgconfig ]
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ]; ++ stdenv.lib.optionals hostPlatform.isDarwin [ Carbon Cocoa ];
nativeBuildInputs = [ gettext ]; nativeBuildInputs = [ gettext ];
configureFlags = [ configureFlags = [
"--enable-multibyte" "--enable-multibyte"
"--enable-nls" "--enable-nls"
] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
"vim_cv_toupper_broken=no"
"--with-tlib=ncurses"
"vim_cv_terminfo=yes"
"vim_cv_tty_group=tty"
"vim_cv_tty_mode=0660"
"vim_cv_getcwd_broken=no"
"vim_cv_stat_ignores_slash=yes"
"ac_cv_sizeof_int=4"
"vim_cv_memmove_handles_overlap=yes"
"vim_cv_memmove_handles_overlap=yes"
# TODO(@Ericson2314): wont' be needed soon.
"STRIP=${hostPlatform.config}-strip"
]; ];
postInstall = '' postInstall = ''
@ -31,22 +47,6 @@ stdenv.mkDerivation rec {
cp "${vimrc}" $out/share/vim/vimrc cp "${vimrc}" $out/share/vim/vimrc
''; '';
crossAttrs = {
configureFlags = [
"vim_cv_toupper_broken=no"
"--with-tlib=ncurses"
"vim_cv_terminfo=yes"
"vim_cv_tty_group=tty"
"vim_cv_tty_mode=0660"
"vim_cv_getcwd_broken=no"
"vim_cv_stat_ignores_slash=yes"
"ac_cv_sizeof_int=4"
"vim_cv_memmove_handles_overlap=yes"
"vim_cv_memmove_handles_overlap=yes"
"STRIP=${stdenv.cross.config}-strip"
];
};
__impureHostDeps = [ "/dev/ptmx" ]; __impureHostDeps = [ "/dev/ptmx" ];
# To fix the trouble in vim73, that it cannot cross-build with this patch # To fix the trouble in vim73, that it cannot cross-build with this patch

View File

@ -1,5 +1,7 @@
{ stdenv, fetchurl, ncurses, gzip, pkgconfig { stdenv, buildPackages
, fetchurl, pkgconfig, ncurses, gzip
, sslSupport ? true, openssl ? null , sslSupport ? true, openssl ? null
, buildPlatform, hostPlatform
}: }:
assert sslSupport -> openssl != null; assert sslSupport -> openssl != null;
@ -15,7 +17,9 @@ stdenv.mkDerivation rec {
configureFlags = [ "--enable-widec" ] ++ stdenv.lib.optional sslSupport "--with-ssl"; configureFlags = [ "--enable-widec" ] ++ stdenv.lib.optional sslSupport "--with-ssl";
nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig; nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig
++ stdenv.lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
buildInputs = [ ncurses gzip ] ++ stdenv.lib.optional sslSupport openssl.dev; buildInputs = [ ncurses gzip ] ++ stdenv.lib.optional sslSupport openssl.dev;
meta = with stdenv.lib; { meta = with stdenv.lib; {

View File

@ -25,6 +25,7 @@
, libjpegSupport ? true, libjpeg ? null , libjpegSupport ? true, libjpeg ? null
, useUnfreeCodecs ? false , useUnfreeCodecs ? false
, darwin ? null , darwin ? null
, hostPlatform
}: }:
assert fontconfigSupport -> (fontconfig != null); assert fontconfigSupport -> (fontconfig != null);
@ -185,13 +186,14 @@ stdenv.mkDerivation rec {
''; '';
crossAttrs = { crossAttrs = {
dontSetConfigureCross = true; configurePlatforms = [];
# Some things (vidix) are nanonote specific. Once someone cares, we can make options from them. # Some things (vidix) are nanonote specific. Once someone cares, we can make options from them.
# Note, the `target` vs `host` confusion is intensional.
preConfigure = '' preConfigure = ''
configureFlags="`echo $configureFlags | configureFlags="`echo $configureFlags |
sed -e 's/--codecsdir[^ ]\+//' \ sed -e 's/--codecsdir[^ ]\+//' \
-e 's/--enable-runtime-cpudetection//' `" -e 's/--enable-runtime-cpudetection//' `"
configureFlags="$configureFlags --target=${stdenv.cross.arch}-linux configureFlags="$configureFlags --target=${hostPlatform.arch}-linux
--enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as --enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as
--disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc" --disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc"
''; '';

View File

@ -44,7 +44,7 @@ let
enableParallelBuilding = true; enableParallelBuilding = true;
crossAttrs = { crossAttrs = {
dontSetConfigureCross = true; configurePlatforms = [];
configureFlags = configureFlags ++ [ configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cross.config}-" "--cross-prefix=${stdenv.cross.config}-"
"--enable-cross-compile" "--enable-cross-compile"

View File

@ -5,11 +5,13 @@
# script that sets up the right environment variables so that the # script that sets up the right environment variables so that the
# compiler and the linker just "work". # compiler and the linker just "work".
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" { name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell , cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell
, zlib ? null, extraPackages ? [], extraBuildCommands ? "" , zlib ? null, extraPackages ? [], extraBuildCommands ? ""
, dyld ? null # TODO: should this be a setup-hook on dyld? , dyld ? null # TODO: should this be a setup-hook on dyld?
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, hostPlatform, targetPlatform
, runCommand ? null
}: }:
with stdenv.lib; with stdenv.lib;
@ -17,32 +19,113 @@ with stdenv.lib;
assert nativeTools -> nativePrefix != ""; assert nativeTools -> nativePrefix != "";
assert !nativeTools -> assert !nativeTools ->
cc != null && binutils != null && coreutils != null && gnugrep != null; cc != null && binutils != null && coreutils != null && gnugrep != null;
assert !nativeLibc -> libc != null; assert !(nativeLibc && noLibc);
assert (noLibc || nativeLibc) == (libc == null);
assert targetPlatform != hostPlatform -> runCommand != null;
# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
assert cc.langVhdl or false -> zlib != null; assert cc.langVhdl or false -> zlib != null;
let let
# Prefix for binaries. Customarily ends with a dash separator.
#
# TODO(@Ericson2314) Make unconditional, or optional but always true by
# default.
prefix = stdenv.lib.optionalString (targetPlatform != hostPlatform)
(targetPlatform.config + "-");
ccVersion = (builtins.parseDrvName cc.name).version; ccVersion = (builtins.parseDrvName cc.name).version;
ccName = (builtins.parseDrvName cc.name).name; ccName = (builtins.parseDrvName cc.name).name;
libc_bin = if nativeLibc then null else getBin libc; libc_bin = if libc == null then null else getBin libc;
libc_dev = if nativeLibc then null else getDev libc; libc_dev = if libc == null then null else getDev libc;
libc_lib = if nativeLibc then null else getLib libc; libc_lib = if libc == null then null else getLib libc;
cc_solib = getLib cc; cc_solib = getLib cc;
binutils_bin = if nativeTools then "" else getBin binutils; binutils_bin = if nativeTools then "" else getBin binutils;
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils. # The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
coreutils_bin = if nativeTools then "" else getBin coreutils; coreutils_bin = if nativeTools then "" else getBin coreutils;
default_cxx_stdlib_compile=optionalString (stdenv.isLinux && !(cc.isGNU or false)) default_cxx_stdlib_compile=optionalString (targetPlatform.isLinux && !(cc.isGNU or false))
"-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)"; "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)";
dashlessTarget = stdenv.lib.replaceStrings ["-"] ["_"] targetPlatform.config;
# TODO(@Ericson2314) Make unconditional
infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) dashlessTarget;
infixSalt_ = stdenv.lib.optionalString (targetPlatform != hostPlatform) (dashlessTarget + "_");
_infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) ("_" + dashlessTarget);
# We want to prefix all NIX_ flags with the target triple
preWrap = textFile:
# TODO: Do even when not cross on next mass-rebuild
# TODO: use @target_tripple@ for consistency
if targetPlatform == hostPlatform
then textFile
else runCommand "sed-nix-env-vars" {} (''
cp --no-preserve=mode ${textFile} $out
sed -i $out \
-e 's^NIX_^NIX_${infixSalt_}^g' \
-e 's^addCVars^addCVars${_infixSalt}^g' \
-e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g'
'' + stdenv.lib.optionalString (textFile == ./setup-hook.sh) ''
cat << 'EOF' >> $out
for CMD in ar as nm objcopy ranlib strip strings size ld
do
# which is not part of stdenv, but compgen will do for now
if
PATH=$_PATH type -p ${prefix}$CMD > /dev/null
then
export ''$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=${prefix}''${CMD};
fi
done
EOF
sed -i $out -e 's_envHooks_crossEnvHooks_g'
'' + ''
# NIX_ things which we don't both use and define, we revert them
#asymmetric=$(
# for pre in "" "\\$"
# do
# grep -E -ho $pre'NIX_[a-zA-Z_]*' ./* | sed 's/\$//' | sort | uniq
# done | sort | uniq -c | sort -nr | sed -n 's/^1 NIX_//gp')
# hard-code for now
asymmetric=("CXXSTDLIB_COMPILE" "CC")
# The ([^a-zA-Z_]|$) bussiness is to ensure environment variables that
# begin with `NIX_CC` don't also get blacklisted.
for var in "''${asymmetric[@]}"
do
sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g"
done
'');
# The dynamic linker has different names on different platforms.
dynamicLinker =
if !nativeLibc then
(if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else
if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
# ARM with a wildcard, which can be "" or "-armhf".
if targetPlatform.isArm32 then "ld-linux*.so.3" else
if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else
if targetPlatform.system == "powerpc-linux" then "ld.so.1" else
if targetPlatform.system == "mips64el-linux" then "ld.so.1" else
if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else
if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else
builtins.trace
"Don't know the name of the dynamic linker for platform ${targetPlatform.config}, so guessing instead."
null)
else "";
in in
stdenv.mkDerivation { stdenv.mkDerivation {
name = name = prefix
(if name != "" then name else ccName + "-wrapper") + + (if name != "" then name else "${ccName}-wrapper")
(if cc != null && ccVersion != "" then "-" + ccVersion else ""); + (stdenv.lib.optionalString (cc != null && ccVersion != "") "-${ccVersion}");
preferLocalBuild = true; preferLocalBuild = true;
@ -51,17 +134,18 @@ stdenv.mkDerivation {
passthru = { passthru = {
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile; inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile
prefix infixSalt infixSalt_ _infixSalt;
emacsBufferSetup = pkgs: '' emacsBufferSetup = pkgs: ''
; We should handle propagation here too ; We should handle propagation here too
(mapc (lambda (arg) (mapc (lambda (arg)
(when (file-directory-p (concat arg "/include")) (when (file-directory-p (concat arg "/include"))
(setenv "NIX_CFLAGS_COMPILE" (concat (getenv "NIX_CFLAGS_COMPILE") " -isystem " arg "/include"))) (setenv "NIX_${infixSalt_}CFLAGS_COMPILE" (concat (getenv "NIX_${infixSalt_}CFLAGS_COMPILE") " -isystem " arg "/include")))
(when (file-directory-p (concat arg "/lib")) (when (file-directory-p (concat arg "/lib"))
(setenv "NIX_LDFLAGS" (concat (getenv "NIX_LDFLAGS") " -L" arg "/lib"))) (setenv "NIX_${infixSalt_}LDFLAGS" (concat (getenv "NIX_${infixSalt_}LDFLAGS") " -L" arg "/lib")))
(when (file-directory-p (concat arg "/lib64")) (when (file-directory-p (concat arg "/lib64"))
(setenv "NIX_LDFLAGS" (concat (getenv "NIX_LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)})) (setenv "NIX_${infixSalt_}LDFLAGS" (concat (getenv "NIX_${infixSalt_}LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
''; '';
}; };
@ -78,7 +162,12 @@ stdenv.mkDerivation {
} }
'' ''
+ optionalString (!nativeLibc) (if (!stdenv.isDarwin) then '' # TODO(@Ericson2314): Unify logic next hash break
+ optionalString (libc != null) (if (targetPlatform.isDarwin) then ''
echo $dynamicLinker > $out/nix-support/dynamic-linker
echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook
'' else if dynamicLinker != null then ''
dynamicLinker="${libc_lib}/lib/$dynamicLinker" dynamicLinker="${libc_lib}/lib/$dynamicLinker"
echo $dynamicLinker > $out/nix-support/dynamic-linker echo $dynamicLinker > $out/nix-support/dynamic-linker
@ -91,12 +180,24 @@ stdenv.mkDerivation {
# (the *last* value counts, so ours should come first). # (the *last* value counts, so ours should come first).
echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before
'' else '' '' else ''
echo $dynamicLinker > $out/nix-support/dynamic-linker dynamicLinker=`eval 'echo $libc/lib/ld*.so.?'`
if [ -n "$dynamicLinker" ]; then
echo $dynamicLinker > $out/nix-support/dynamic-linker
echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
fi
ldflagsBefore="-dynamic-linker $dlinker"
fi
# The dynamic linker is passed in `ldflagsBefore' to allow
# explicit overrides of the dynamic linker by callers to gcc/ld
# (the *last* value counts, so ours should come first).
echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
'') '')
+ optionalString (!nativeLibc) '' + optionalString (libc != null) ''
# The "-B${libc_lib}/lib/" flag is a quick hack to force gcc to link # The "-B${libc_lib}/lib/" flag is a quick hack to force gcc to link
# against the crt1.o from our own glibc, rather than the one in # against the crt1.o from our own glibc, rather than the one in
# /usr/lib. (This is only an issue when using an `impure' # /usr/lib. (This is only an issue when using an `impure'
@ -117,7 +218,7 @@ stdenv.mkDerivation {
'' ''
+ (if nativeTools then '' + (if nativeTools then ''
ccPath="${if stdenv.isDarwin then cc else nativePrefix}/bin" ccPath="${if targetPlatform.isDarwin then cc else nativePrefix}/bin"
ldPath="${nativePrefix}/bin" ldPath="${nativePrefix}/bin"
'' else '' '' else ''
echo $cc > $out/nix-support/orig-cc echo $cc > $out/nix-support/orig-cc
@ -161,136 +262,114 @@ stdenv.mkDerivation {
# Propagate the wrapped cc so that if you install the wrapper, # Propagate the wrapped cc so that if you install the wrapper,
# you get tools like gcov, the manpages, etc. as well (including # you get tools like gcov, the manpages, etc. as well (including
# for binutils and Glibc). # for binutils and Glibc).
echo ${cc} ${cc.man or ""} ${binutils_bin} ${libc_bin} > $out/nix-support/propagated-user-env-packages echo ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs
'' ''
+ optionalString (stdenv.isSunOS && nativePrefix != "") '' + optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
# Solaris needs an additional ld wrapper. # Solaris needs an additional ld wrapper.
ldPath="${nativePrefix}/bin" ldPath="${nativePrefix}/bin"
exec="$ldPath/ld" exec="$ldPath/${prefix}ld"
wrap ld-solaris ${./ld-solaris-wrapper.sh} wrap ld-solaris ${preWrap ./ld-solaris-wrapper.sh}
'') '')
+ '' + ''
# Create a symlink to as (the assembler). This is useful when a # Create a symlink to as (the assembler). This is useful when a
# cc-wrapper is installed in a user environment, as it ensures that # cc-wrapper is installed in a user environment, as it ensures that
# the right assembler is called. # the right assembler is called.
if [ -e $ldPath/as ]; then if [ -e $ldPath/${prefix}as ]; then
ln -s $ldPath/as $out/bin/as ln -s $ldPath/${prefix}as $out/bin/${prefix}as
fi fi
wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld} wrap ${prefix}ld ${preWrap ./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
if [ -e ${binutils_bin}/bin/ld.gold ]; then if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
wrap ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.gold wrap ${prefix}ld.gold ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
fi fi
if [ -e ${binutils_bin}/bin/ld.bfd ]; then if [ -e ${binutils_bin}/bin/ld.bfd ]; then
wrap ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.bfd wrap ${prefix}ld.bfd ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
fi fi
export real_cc=cc export real_cc=${prefix}cc
export real_cxx=c++ export real_cxx=${prefix}c++
export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}" export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
if [ -e $ccPath/gcc ]; then if [ -e $ccPath/${prefix}gcc ]; then
wrap gcc ${./cc-wrapper.sh} $ccPath/gcc wrap ${prefix}gcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcc
ln -s gcc $out/bin/cc ln -s ${prefix}gcc $out/bin/${prefix}cc
export real_cc=gcc export real_cc=${prefix}gcc
export real_cxx=g++ export real_cxx=${prefix}g++
elif [ -e $ccPath/clang ]; then elif [ -e $ccPath/clang ]; then
wrap clang ${./cc-wrapper.sh} $ccPath/clang wrap ${prefix}clang ${preWrap ./cc-wrapper.sh} $ccPath/clang
ln -s clang $out/bin/cc ln -s ${prefix}clang $out/bin/${prefix}cc
export real_cc=clang export real_cc=clang
export real_cxx=clang++ export real_cxx=clang++
fi fi
if [ -e $ccPath/g++ ]; then if [ -e $ccPath/${prefix}g++ ]; then
wrap g++ ${./cc-wrapper.sh} $ccPath/g++ wrap ${prefix}g++ ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}g++
ln -s g++ $out/bin/c++ ln -s ${prefix}g++ $out/bin/${prefix}c++
elif [ -e $ccPath/clang++ ]; then elif [ -e $ccPath/clang++ ]; then
wrap clang++ ${./cc-wrapper.sh} $ccPath/clang++ wrap ${prefix}clang++ ${preWrap ./cc-wrapper.sh} $ccPath/clang++
ln -s clang++ $out/bin/c++ ln -s ${prefix}clang++ $out/bin/${prefix}c++
fi fi
if [ -e $ccPath/cpp ]; then if [ -e $ccPath/cpp ]; then
wrap cpp ${./cc-wrapper.sh} $ccPath/cpp wrap ${prefix}cpp ${preWrap ./cc-wrapper.sh} $ccPath/cpp
fi fi
'' ''
+ optionalString cc.langFortran or false '' + optionalString cc.langFortran or false ''
wrap gfortran ${./cc-wrapper.sh} $ccPath/gfortran wrap ${prefix}gfortran ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gfortran
ln -sv gfortran $out/bin/g77 ln -sv ${prefix}gfortran $out/bin/${prefix}g77
ln -sv gfortran $out/bin/f77 ln -sv ${prefix}gfortran $out/bin/${prefix}f77
'' ''
+ optionalString cc.langJava or false '' + optionalString cc.langJava or false ''
wrap gcj ${./cc-wrapper.sh} $ccPath/gcj wrap ${prefix}gcj ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcj
'' ''
+ optionalString cc.langGo or false '' + optionalString cc.langGo or false ''
wrap gccgo ${./cc-wrapper.sh} $ccPath/gccgo wrap ${prefix}gccgo ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gccgo
'' ''
+ optionalString cc.langAda or false '' + optionalString cc.langAda or false ''
wrap gnatgcc ${./cc-wrapper.sh} $ccPath/gnatgcc wrap ${prefix}gnatgcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gnatgcc
wrap gnatmake ${./gnat-wrapper.sh} $ccPath/gnatmake wrap ${prefix}gnatmake ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatmake
wrap gnatbind ${./gnat-wrapper.sh} $ccPath/gnatbind wrap ${prefix}gnatbind ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatbind
wrap gnatlink ${./gnatlink-wrapper.sh} $ccPath/gnatlink wrap ${prefix}gnatlink ${preWrap ./gnatlink-wrapper.sh} $ccPath/${prefix}gnatlink
'' ''
+ optionalString cc.langVhdl or false '' + optionalString cc.langVhdl or false ''
ln -s $ccPath/ghdl $out/bin/ghdl ln -s $ccPath/${prefix}ghdl $out/bin/${prefix}ghdl
'' ''
+ '' + ''
substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook.tmp substituteAll ${preWrap ./setup-hook.sh} $out/nix-support/setup-hook.tmp
cat $out/nix-support/setup-hook.tmp >> $out/nix-support/setup-hook cat $out/nix-support/setup-hook.tmp >> $out/nix-support/setup-hook
rm $out/nix-support/setup-hook.tmp rm $out/nix-support/setup-hook.tmp
# some linkers on some platforms don't support specific -z flags # some linkers on some platforms don't support specific -z flags
hardening_unsupported_flags="" hardening_unsupported_flags=""
if [[ "$($ldPath/ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then if [[ "$($ldPath/${prefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
hardening_unsupported_flags+=" bindnow" hardening_unsupported_flags+=" bindnow"
fi fi
if [[ "$($ldPath/ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then if [[ "$($ldPath/${prefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
hardening_unsupported_flags+=" relro" hardening_unsupported_flags+=" relro"
fi fi
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh substituteAll ${preWrap ./add-flags.sh} $out/nix-support/add-flags.sh
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh substituteAll ${preWrap ./add-hardening.sh} $out/nix-support/add-hardening.sh
cp -p ${./utils.sh} $out/nix-support/utils.sh cp -p ${preWrap ./utils.sh} $out/nix-support/utils.sh
'' ''
+ extraBuildCommands; + extraBuildCommands;
# The dynamic linker has different names on different Linux platforms. inherit dynamicLinker;
dynamicLinker =
if !nativeLibc then
(if stdenv.system == "i686-linux" then "ld-linux.so.2" else
if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
# ARM with a wildcard, which can be "" or "-armhf".
if stdenv.isArm then "ld-linux*.so.3" else
if stdenv.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else
if stdenv.system == "powerpc-linux" then "ld.so.1" else
if stdenv.system == "mips64el-linux" then "ld.so.1" else
if stdenv.system == "x86_64-darwin" then "/usr/lib/dyld" else
abort "Don't know the name of the dynamic linker for this platform.")
else "";
crossAttrs = { crossAttrs = {
shell = shell.crossDrv + shell.crossDrv.shellPath; shell = shell.crossDrv + shell.crossDrv.shellPath;
libc = stdenv.ccCross.libc;
#
# This is not the best way to do this. I think the reference should be
# the style in the gcc-cross-wrapper, but to keep a stable stdenv now I
# do this sufficient if/else.
dynamicLinker =
(if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
if stdenv.cross.arch == "mips" then "ld.so.1" else
if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
abort "don't know the name of the dynamic linker for this platform");
}; };
meta = meta =

View File

@ -1,5 +0,0 @@
export NIX_CROSS_CFLAGS_COMPILE="@cflagsCompile@ $NIX_CROSS_CFLAGS_COMPILE"
export NIX_CROSS_CFLAGS_LINK="@cflagsLink@ $NIX_CROSS_CFLAGS_LINK"
export NIX_CROSS_LDFLAGS="@ldflags@ $NIX_CROSS_LDFLAGS"
export NIX_CROSS_LDFLAGS_BEFORE="@ldflagsBefore@ $NIX_CROSS_LDFLAGS_BEFORE"
export NIX_CROSS_GLIBC_FLAGS_SET=1

View File

@ -1,120 +0,0 @@
source $stdenv/setup
mkdir $out
mkdir $out/bin
mkdir $out/nix-support
# Force gcc to use ld-wrapper.sh when calling ld.
cflagsCompile="-B$out/bin/"
if test -z "$nativeLibc" -a -n "$libc"; then
cflagsCompile="$cflagsCompile -B$gccLibs/lib -B$libc/lib/ -isystem $libc_dev/include"
ldflags="$ldflags -L$libc/lib"
# Get the proper dynamic linker for glibc and uclibc.
dlinker=`eval 'echo $libc/lib/ld*.so.?'`
if [ -n "$dlinker" ]; then
ldflagsBefore="-dynamic-linker $dlinker"
# The same as above, but put into files, useful for the gcc builder.
echo $dlinker > $out/nix-support/dynamic-linker
# This trick is to avoid dependencies on the cross-toolchain gcc
# for libgcc, libstdc++, ...
# -L is for libtool's .la files, and -rpath for the usual fixupPhase
# shrinking rpaths.
if [ -n "$gccLibs" ]; then
ldflagsBefore="$ldflagsBefore -rpath $gccLibs/lib"
fi
fi
if [ -n "$osxMinVersion" ]; then
cflagsCompile="$cflagsCompile -mmacosx-version-min=$osxMinVersion"
fi
echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags
# The dynamic linker is passed in `ldflagsBefore' to allow
# explicit overrides of the dynamic linker by callers to gcc/ld
# (the *last* value counts, so ours should come first).
echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
fi
if test -n "$nativeTools"; then
gccPath="$nativePrefix/bin"
ldPath="$nativePrefix/bin"
else
ldflags="$ldflags -L$gcc/lib -L$gcc/lib64"
gccPath="$gcc/bin"
ldPath="$binutils/$crossConfig/bin"
fi
doSubstitute() {
local src=$1
local dst=$2
substitute "$src" "$dst" \
--subst-var "out" \
--subst-var "shell" \
--subst-var "gcc" \
--subst-var "gccProg" \
--subst-var "binutils" \
--subst-var "libc" \
--subst-var "cflagsCompile" \
--subst-var "cflagsLink" \
--subst-var "ldflags" \
--subst-var "ldflagsBefore" \
--subst-var "ldPath" \
--subst-var-by "ld" "$ldPath/ld"
}
# Make wrapper scripts around gcc, g++, and g77. Also make symlinks
# cc, c++, and f77.
mkGccWrapper() {
local dst=$1
local src=$2
if ! test -f "$src"; then
echo "$src does not exist (skipping)"
return
fi
gccProg="$src"
doSubstitute "$gccWrapper" "$dst"
chmod +x "$dst"
}
mkGccWrapper $out/bin/$crossConfig-gcc $gccPath/$crossConfig-gcc
#ln -s gcc $out/bin/cc
mkGccWrapper $out/bin/$crossConfig-g++ $gccPath/$crossConfig-g++
ln -s $crossConfig-g++ $out/bin/$crossConfig-c++
mkGccWrapper $out/bin/$crossConfig-cpp $gccPath/$crossConfig-cpp
mkGccWrapper $out/bin/$crossConfig-g77 $gccPath/$crossConfig-g77
ln -s $crossConfig-g77 $out/bin/$crossConfig-f77
ln -s $binutils/bin/$crossConfig-ar $out/bin/$crossConfig-ar
ln -s $binutils/bin/$crossConfig-as $out/bin/$crossConfig-as
ln -s $binutils/bin/$crossConfig-nm $out/bin/$crossConfig-nm
ln -s $binutils/bin/$crossConfig-strip $out/bin/$crossConfig-strip
# Make a wrapper around the linker.
doSubstitute "$ldWrapper" "$out/bin/$crossConfig-ld"
chmod +x "$out/bin/$crossConfig-ld"
# Emit a setup hook. Also store the path to the original GCC and
# Glibc.
test -n "$gcc" && echo $gcc > $out/nix-support/orig-cc
test -n "$libc" && echo $libc > $out/nix-support/orig-libc
test -n "$libc_dev" && echo $libc_dev > $out/nix-support/orig-libc-dev
doSubstitute "$addFlags" "$out/nix-support/add-flags"
doSubstitute "$setupHook" "$out/nix-support/setup-hook"
cp -p $utils $out/nix-support/utils

View File

@ -1,65 +0,0 @@
# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
# know where the C library and standard header files are. Therefore
# the compiler produced by that package cannot be installed directly
# in a user environment and used from the command line. This
# stdenv.mkDerivation provides a wrapper that sets up the right environment
# variables so that the compiler and the linker just "work".
{ name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? ""
, gcc ? null, libc ? null, binutils ? null, shell ? "", cross
}:
assert nativeTools -> nativePrefix != "";
assert !nativeTools -> gcc != null && binutils != null;
assert !noLibc -> (!nativeLibc -> libc != null);
let
chosenName = if name == "" then gcc.name else name;
gccLibs = stdenv.mkDerivation {
name = chosenName + "-libs";
phases = [ "installPhase" ];
installPhase = ''
echo $out
mkdir -p "$out"
if [ -d "${gcc}/${cross.config}/lib" ]
then
cp -Rd "${gcc}/${cross.config}/lib" "$out/lib"
chmod -R +w "$out/lib"
for a in "$out/lib/"*.la; do
sed -i -e "s,${gcc}/${cross.config}/lib,$out/lib,g" $a
done
rm -f "$out/lib/"*.py
else
# The MinGW cross-compiler falls into this category.
mkdir "$out/lib"
fi
'';
};
in
stdenv.mkDerivation {
builder = ./builder.sh;
setupHook = ./setup-hook.sh;
gccWrapper = ./gcc-wrapper.sh;
ldWrapper = ./ld-wrapper.sh;
utils = ./utils.sh;
addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix gcc binutils;
libc = if libc ? out then libc.out else libc;
libc_dev = if libc ? dev then libc.dev else libc;
crossConfig = if cross != null then cross.config else null;
osxMinVersion = cross.osxMinVersion or null;
gccLibs = if gcc != null then gccLibs else null;
name = chosenName;
langC = if nativeTools then true else gcc.langC;
langCC = if nativeTools then true else gcc.langCC;
langF77 = if nativeTools then false else gcc ? langFortran;
shell = if shell == "" then stdenv.shell else shell;
meta = if gcc != null then gcc.meta else
{ description = "System C compiler wrapper";
};
passthru = {
target = cross;
};
}

View File

@ -1,117 +0,0 @@
#! @shell@ -e
if test -n "$NIX_CC_WRAPPER_START_HOOK"; then
source "$NIX_CC_WRAPPER_START_HOOK"
fi
if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then
source @out@/nix-support/add-flags
fi
source @out@/nix-support/utils
# Figure out if linker flags should be passed. GCC prints annoying
# warnings when they are not needed.
dontLink=0
if test "$*" = "-v" -o -z "$*"; then
dontLink=1
else
for i in "$@"; do
if test "$i" = "-c"; then
dontLink=1
elif test "$i" = "-S"; then
dontLink=1
elif test "$i" = "-E"; then
dontLink=1
elif test "$i" = "-E"; then
dontLink=1
elif test "$i" = "-M"; then
dontLink=1
elif test "$i" = "-MM"; then
dontLink=1
fi
done
fi
# Optionally filter out paths not refering to the store.
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
rest=()
n=0
while test $n -lt ${#params[*]}; do
p=${params[n]}
p2=${params[$((n+1))]}
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
skip $p
elif test "$p" = "-L" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
skip $p
elif test "$p" = "-I" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-isystem" && badPath "$p2"; then
n=$((n + 1)); skip $p2
else
rest=("${rest[@]}" "$p")
fi
n=$((n + 1))
done
params=("${rest[@]}")
fi
# Add the flags for the C compiler proper.
extraAfter=($NIX_CROSS_CFLAGS_COMPILE)
extraBefore=()
if test "$dontLink" != "1"; then
# Add the flags that should only be passed to the compiler when
# linking.
extraAfter=(${extraAfter[@]} $NIX_CROSS_CFLAGS_LINK)
# Add the flags that should be passed to the linker (and prevent
# `ld-wrapper' from adding NIX_CROSS_LDFLAGS again).
for i in $NIX_CROSS_LDFLAGS_BEFORE; do
if test "${i:0:3}" = "-L/"; then
extraBefore=(${extraBefore[@]} "$i")
else
extraBefore=(${extraBefore[@]} "-Wl,$i")
fi
done
for i in $NIX_CROSS_LDFLAGS; do
if test "${i:0:3}" = "-L/"; then
extraAfter=(${extraAfter[@]} "$i")
else
extraAfter=(${extraAfter[@]} "-Wl,$i")
fi
done
export NIX_CROSS_LDFLAGS_SET=1
fi
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
echo "original flags to @gccProg@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
done
echo "extraBefore flags to @gccProg@:" >&2
for i in ${extraBefore[@]}; do
echo " $i" >&2
done
echo "extraAfter flags to @gccProg@:" >&2
for i in ${extraAfter[@]}; do
echo " $i" >&2
done
fi
if test -n "$NIX_CC_WRAPPER_EXEC_HOOK"; then
source "$NIX_CC_WRAPPER_EXEC_HOOK"
fi
# We want gcc to call the wrapper linker, not that of binutils.
export PATH="@ldPath@:$PATH"
exec @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}

View File

@ -1,145 +0,0 @@
#! @shell@ -e
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
source "$NIX_LD_WRAPPER_START_HOOK"
fi
if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then
source @out@/nix-support/add-flags
fi
source @out@/nix-support/utils
# Optionally filter out paths not refering to the store.
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
-a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_CROSS_LDFLAGS_SET" \); then
rest=()
n=0
while test $n -lt ${#params[*]}; do
p=${params[n]}
p2=${params[$((n+1))]}
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
skip $p
elif test "$p" = "-L" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-rpath" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "${p:0:1}" = "/" && badPath "$p"; then
# We cannot skip this; barf.
echo "impure path \`$p' used in link" >&2
exit 1
else
rest=("${rest[@]}" "$p")
fi
n=$((n + 1))
done
params=("${rest[@]}")
fi
extra=()
extraBefore=()
if test -z "$NIX_CROSS_LDFLAGS_SET"; then
extra=(${extra[@]} $NIX_CROSS_LDFLAGS)
extraBefore=(${extraBefore[@]} $NIX_CROSS_LDFLAGS_BEFORE)
fi
# Add all used dynamic libraries to the rpath.
if test "$NIX_DONT_SET_RPATH" != "1"; then
# First, find all -L... switches.
allParams=("${params[@]}" ${extra[@]})
libPath=""
addToLibPath() {
local path="$1"
if test "${path:0:1}" != "/"; then return 0; fi
case "$path" in
*..*|*./*|*/.*|*//*)
local path2
if path2=$(readlink -f "$path"); then
path="$path2"
fi
;;
esac
case $libPath in
*\ $path\ *) return 0 ;;
esac
libPath="$libPath $path "
}
n=0
while test $n -lt ${#allParams[*]}; do
p=${allParams[n]}
p2=${allParams[$((n+1))]}
if test "${p:0:3}" = "-L/"; then
addToLibPath ${p:2}
elif test "$p" = "-L"; then
addToLibPath ${p2}
n=$((n + 1))
fi
n=$((n + 1))
done
# Second, for each -l... switch, find the directory containing the
# library and add it to the rpath.
rpath=""
addToRPath() {
# If the path is not in the store, don't add it to the rpath.
# This typically happens for libraries in /tmp that are later
# copied to $out/lib. If not, we're screwed.
if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
case $rpath in
*\ $1\ *) return 0 ;;
esac
rpath="$rpath $1 "
}
findLib() {
for i in $libPath; do
if test -f $i/lib$1.so; then
addToRPath $i
fi
done
}
n=0
while test $n -lt ${#allParams[*]}; do
p=${allParams[n]}
p2=${allParams[$((n+1))]}
if test "${p:0:2}" = "-l"; then
findLib ${p:2}
elif test "$p" = "-l"; then
# I haven't seen `-l foo', but you never know...
findLib ${p2}
n=$((n + 1))
fi
n=$((n + 1))
done
# Finally, add `-rpath' switches.
for i in $rpath; do
extra=(${extra[@]} -rpath $i -rpath-link $i)
done
fi
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
echo "original flags to @ld@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
done
echo "extra flags to @ld@:" >&2
for i in ${extra[@]}; do
echo " $i" >&2
done
fi
if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
source "$NIX_LD_WRAPPER_EXEC_HOOK"
fi
exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}

View File

@ -1,90 +0,0 @@
NIX_CROSS_CFLAGS_COMPILE=""
NIX_CROSS_LDFLAGS=""
crossAddCVars () {
if test -d $1/include; then
export NIX_CROSS_CFLAGS_COMPILE="$NIX_CROSS_CFLAGS_COMPILE -I$1/include"
fi
if test -d $1/lib; then
export NIX_CROSS_LDFLAGS="$NIX_CROSS_LDFLAGS -L$1/lib -rpath-link $1/lib"
fi
}
crossEnvHooks+=(crossAddCVars)
crossStripDirs() {
local dirs="$1"
local stripFlags="$2"
local dirsNew=
for d in ${dirs}; do
if test -d "$prefix/$d"; then
dirsNew="${dirsNew} $prefix/$d "
fi
done
dirs=${dirsNew}
if test -n "${dirs}"; then
header "cross stripping (with flags $stripFlags) in $dirs"
# libc_nonshared.a should never be stripped, or builds will break.
find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true
stopNest
fi
}
crossStrip () {
# In cross_renaming we may rename dontCrossStrip to dontStrip, and
# dontStrip to dontNativeStrip.
# TODO: strip _only_ ELF executables, and return || fail here...
if test -z "$dontCrossStrip"; then
stripDebugList=${stripDebugList:-lib lib64 libexec bin sbin}
if test -n "$stripDebugList"; then
crossStripDirs "$stripDebugList" "${stripDebugFlags:--S}"
fi
stripAllList=${stripAllList:-}
if test -n "$stripAllList"; then
crossStripDirs "$stripAllList" "${stripAllFlags:--s}"
fi
fi
}
preDistPhases=(${preDistPhases[@]} crossStrip)
# Note: these come *after* $out in the PATH (see setup.sh).
if test -n "@gcc@"; then
PATH=$PATH:@gcc@/bin
fi
if test -n "@binutils@"; then
PATH=$PATH:@binutils@/bin
fi
if test -n "@libc@"; then
PATH=$PATH:@libc@/bin
crossAddCVars @libc@
fi
if test "$dontSetConfigureCross" != "1"; then
configureFlags="$configureFlags --build=$system --host=$crossConfig"
fi
# Disabling the tests when cross compiling, as usually the tests are meant for
# native compilations.
doCheck=""
# Don't strip foreign binaries with native "strip" tool.
dontStrip=1
# Add the output as an rpath.
if test "$NIX_NO_SELF_RPATH" != "1"; then
export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
export NIX_CROSS_LDFLAGS="-rpath $out/lib64 -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
fi
fi
export CC=${crossConfig}-gcc
export CXX=${crossConfig}-g++

View File

@ -1,24 +0,0 @@
skip () {
if test "$NIX_DEBUG" = "1"; then
echo "skipping impure path $1" >&2
fi
}
# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but
# `/nix/store/.../lib/foo.so' isn't.
badPath() {
local p=$1
# Relative paths are okay (since they're presumably relative to
# the temporary build directory).
if test "${p:0:1}" != "/"; then return 1; fi
# Otherwise, the path should refer to the store or some temporary
# directory (including the build directory).
test \
"$p" != "/dev/null" -a \
"${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
"${p:0:4}" != "/tmp" -a \
"${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
}

View File

@ -61,7 +61,6 @@ stdenv.mkDerivation {
crossAttrs = { crossAttrs = {
shell = shell.crossDrv + shell.crossDrv.shellPath; shell = shell.crossDrv + shell.crossDrv.shellPath;
libc = stdenv.ccCross.libc;
coreutils = coreutils.crossDrv; coreutils = coreutils.crossDrv;
binutils = binutils.crossDrv; binutils = binutils.crossDrv;
gcc = gcc.crossDrv; gcc = gcc.crossDrv;

View File

@ -283,7 +283,7 @@ stdenv.mkDerivation ({
NM_FOR_TARGET = "${targetPlatform.config}-nm"; NM_FOR_TARGET = "${targetPlatform.config}-nm";
CXX_FOR_TARGET = "${targetPlatform.config}-g++"; CXX_FOR_TARGET = "${targetPlatform.config}-g++";
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags = ''
${if enableMultilib then "" else "--disable-multilib"} ${if enableMultilib then "" else "--disable-multilib"}

View File

@ -401,7 +401,7 @@ stdenv.mkDerivation ({
NM_FOR_TARGET = "${targetPlatform.config}-nm"; NM_FOR_TARGET = "${targetPlatform.config}-nm";
CXX_FOR_TARGET = "${targetPlatform.config}-g++"; CXX_FOR_TARGET = "${targetPlatform.config}-g++";
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags = ''
${if enableMultilib then "" else "--disable-multilib"} ${if enableMultilib then "" else "--disable-multilib"}

View File

@ -407,7 +407,7 @@ stdenv.mkDerivation ({
NM_FOR_TARGET = "${targetPlatform.config}-nm"; NM_FOR_TARGET = "${targetPlatform.config}-nm";
CXX_FOR_TARGET = "${targetPlatform.config}-g++"; CXX_FOR_TARGET = "${targetPlatform.config}-g++";
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags = ''
${if enableMultilib then "" else "--disable-multilib"} ${if enableMultilib then "" else "--disable-multilib"}

View File

@ -35,6 +35,7 @@
, cloog # unused; just for compat with gcc4, as we override the parameter on some places , cloog # unused; just for compat with gcc4, as we override the parameter on some places
, darwin ? null , darwin ? null
, buildPlatform, hostPlatform, targetPlatform , buildPlatform, hostPlatform, targetPlatform
, buildPackages
}: }:
assert langJava -> zip != null && unzip != null assert langJava -> zip != null && unzip != null
@ -312,6 +313,7 @@ stdenv.mkDerivation ({
++ (optionals langJava [ boehmgc zip unzip ]) ++ (optionals langJava [ boehmgc zip unzip ])
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
++ (optionals (targetPlatform != hostPlatform) [binutils]) ++ (optionals (targetPlatform != hostPlatform) [binutils])
++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc])
++ (optionals langAda [gnatboot]) ++ (optionals langAda [gnatboot])
++ (optionals langVhdl [gnat]) ++ (optionals langVhdl [gnat])
@ -422,7 +424,7 @@ stdenv.mkDerivation ({
NM_FOR_TARGET = "${targetPlatform.config}-nm"; NM_FOR_TARGET = "${targetPlatform.config}-nm";
CXX_FOR_TARGET = "${targetPlatform.config}-g++"; CXX_FOR_TARGET = "${targetPlatform.config}-g++";
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags = ''
${if enableMultilib then "" else "--disable-multilib"} ${if enableMultilib then "" else "--disable-multilib"}
@ -449,6 +451,8 @@ stdenv.mkDerivation ({
) )
} }
${if langAda then " --enable-libada" else ""} ${if langAda then " --enable-libada" else ""}
--build=${buildPlatform.config}
--host=${hostPlatform.config}
--target=${targetPlatform.config} --target=${targetPlatform.config}
${xwithArch} ${xwithArch}
${xwithCpu} ${xwithCpu}

View File

@ -404,7 +404,7 @@ stdenv.mkDerivation ({
NM_FOR_TARGET = "${targetPlatform.config}-nm"; NM_FOR_TARGET = "${targetPlatform.config}-nm";
CXX_FOR_TARGET = "${targetPlatform.config}-g++"; CXX_FOR_TARGET = "${targetPlatform.config}-g++";
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags = ''
${if enableMultilib then "" else "--disable-multilib"} ${if enableMultilib then "" else "--disable-multilib"}

View File

@ -405,7 +405,7 @@ stdenv.mkDerivation ({
NM_FOR_TARGET = "${targetPlatform.config}-nm"; NM_FOR_TARGET = "${targetPlatform.config}-nm";
CXX_FOR_TARGET = "${targetPlatform.config}-g++"; CXX_FOR_TARGET = "${targetPlatform.config}-g++";
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags = ''
${if enableMultilib then "" else "--disable-multilib"} ${if enableMultilib then "" else "--disable-multilib"}

View File

@ -15,8 +15,6 @@ let
version = "8.1.20170106"; version = "8.1.20170106";
rev = "b4f2afe70ddbd0576b4eba3f82ba1ddc52e9b3bd"; rev = "b4f2afe70ddbd0576b4eba3f82ba1ddc52e9b3bd";
outputs = [ "out" "doc" ];
commonPreConfigure = '' commonPreConfigure = ''
echo ${version} >VERSION echo ${version} >VERSION
echo ${rev} >GIT_COMMIT_ID echo ${rev} >GIT_COMMIT_ID
@ -77,6 +75,8 @@ in stdenv.mkDerivation (rec {
done done
''; '';
outputs = [ "out" "doc" ];
passthru = { passthru = {
inherit bootPkgs; inherit bootPkgs;
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
@ -101,26 +101,26 @@ in stdenv.mkDerivation (rec {
''; '';
configureFlags = [ configureFlags = [
"CC=${stdenv.ccCross}/bin/${cross.config}-cc" "CC=${stdenv.cc}/bin/${cross.config}-cc"
"LD=${stdenv.binutils}/bin/${cross.config}-ld" "LD=${stdenv.cc}/bin/${cross.config}-ld"
"AR=${stdenv.binutils}/bin/${cross.config}-ar" "AR=${stdenv.cc}/bin/${cross.config}-ar"
"NM=${stdenv.binutils}/bin/${cross.config}-nm" "NM=${stdenv.cc}/bin/${cross.config}-nm"
"RANLIB=${stdenv.binutils}/bin/${cross.config}-ranlib" "RANLIB=${stdenv.cc}/bin/${cross.config}-ranlib"
"--target=${cross.config}" "--target=${cross.config}"
"--enable-bootstrap-with-devel-snapshot" "--enable-bootstrap-with-devel-snapshot"
] ++ ] ++
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space"; lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ]; buildInputs = commonBuildInputs;
dontSetConfigureCross = true; configurePlatforms = [];
passthru = { passthru = {
inherit bootPkgs cross; inherit bootPkgs cross;
cc = "${stdenv.ccCross}/bin/${cross.config}-cc"; cc = "${stdenv.cc}/bin/${cross.config}-cc";
ld = "${stdenv.binutils}/bin/${cross.config}-ld"; ld = "${stdenv.cc}/bin/${cross.config}-ld";
}; };
}) })

View File

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

View File

@ -446,7 +446,7 @@ stdenv.mkDerivation rec {
fi fi
''; '';
in { in {
dontSetConfigureCross = true; configurePlatforms = [];
configureFlags = configureFlags ++ [ configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cross.config}-" "--cross-prefix=${stdenv.cross.config}-"
"--enable-cross-compile" "--enable-cross-compile"

View File

@ -187,7 +187,7 @@ stdenv.mkDerivation rec {
fi fi
''; '';
in { in {
dontSetConfigureCross = true; configurePlatforms = [];
configureFlags = configureFlags ++ [ configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cross.config}-" "--cross-prefix=${stdenv.cross.config}-"
"--enable-cross-compile" "--enable-cross-compile"

View File

@ -105,7 +105,7 @@ let
installCheckTarget = "check"; # tests need to be run *after* installation installCheckTarget = "check"; # tests need to be run *after* installation
crossAttrs = { crossAttrs = {
dontSetConfigureCross = true; configurePlatforms = [];
configureFlags = configureFlags ++ [ configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cross.config}-" "--cross-prefix=${stdenv.cross.config}-"
"--enable-cross-compile" "--enable-cross-compile"

View File

@ -0,0 +1,11 @@
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -27,7 +27,7 @@ installdirs = $(libdir) $(includedir) $(includedir)/libelf
CC = @CC@
LD = @LD@
-AR = ar
+AR ?= ar
MV = mv -f
RM = rm -f
LN_S = @LN_S@

View File

@ -1,4 +1,7 @@
{ fetchurl, stdenv, gettext, glibc }: { stdenv, fetchurl
, gettext, glibc
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "libelf-0.8.13"; name = "libelf-0.8.13";
@ -8,20 +11,20 @@ stdenv.mkDerivation rec {
sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"; sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
}; };
# TODO(@Ericson2314) Make unconditional next hash break
patches = if hostPlatform == buildPlatform then null else [
./cross-ar.patch
];
doCheck = true; doCheck = true;
# FIXME needs gcc 4.9 in bootstrap tools # FIXME needs gcc 4.9 in bootstrap tools
hardeningDisable = [ "stackprotector" ]; hardeningDisable = [ "stackprotector" ];
# For cross-compiling, native glibc is needed for the "gencat" program.
crossAttrs = {
nativeBuildInputs = [ gettext glibc ];
};
# Libelf's custom NLS macros fail to determine the catalog file extension on # Libelf's custom NLS macros fail to determine the catalog file extension on
# Darwin, so disable NLS for now. # Darwin, so disable NLS for now.
# FIXME: Eventually make Gettext a build input on all platforms. # FIXME: Eventually make Gettext a build input on all platforms.
configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-nls"; configureFlags = stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
nativeBuildInputs = [ gettext ]; nativeBuildInputs = [ gettext ];

View File

@ -1,4 +1,8 @@
{ fetchurl, stdenv, gmp, mpfr }: { stdenv, fetchurl
, gmp, mpfr
, buildPlatform, hostPlatform
}:
let let
version = "1.0.3"; version = "1.0.3";
in in
@ -14,7 +18,7 @@ stdenv.mkDerivation rec {
CFLAGS = "-I${gmp.dev}/include"; CFLAGS = "-I${gmp.dev}/include";
doCheck = true; doCheck = hostPlatform == buildPlatform;
# FIXME needs gcc 4.9 in bootstrap tools # FIXME needs gcc 4.9 in bootstrap tools
hardeningDisable = [ "stackprotector" ]; hardeningDisable = [ "stackprotector" ];

View File

@ -1,4 +1,6 @@
{ fetchurl, stdenv }: { stdenv, fetchurl
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "libsigsegv-2.11"; name = "libsigsegv-2.11";
@ -8,7 +10,7 @@ stdenv.mkDerivation rec {
sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x"; sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x";
}; };
doCheck = true; doCheck = hostPlatform == buildPlatform;
meta = { meta = {
homepage = http://www.gnu.org/software/libsigsegv/; homepage = http://www.gnu.org/software/libsigsegv/;

View File

@ -148,7 +148,7 @@ stdenv.mkDerivation rec {
isCygwin = stdenv.cross.libc == "msvcrt"; isCygwin = stdenv.cross.libc == "msvcrt";
isDarwin = stdenv.cross.libc == "libSystem"; isDarwin = stdenv.cross.libc == "libSystem";
in { in {
dontSetConfigureCross = true; configurePlatforms = [];
configureFlags = configureFlags ++ [ configureFlags = configureFlags ++ [
#"--extra-cflags=" #"--extra-cflags="
#"--extra-cxxflags=" #"--extra-cxxflags="

View File

@ -156,7 +156,7 @@ stdenv.mkDerivation rec {
isCygwin = stdenv.cross.libc == "msvcrt"; isCygwin = stdenv.cross.libc == "msvcrt";
isDarwin = stdenv.cross.libc == "libSystem"; isDarwin = stdenv.cross.libc == "libSystem";
in { in {
dontSetConfigureCross = true; configurePlatforms = [];
configureFlags = configureFlags ++ [ configureFlags = configureFlags ++ [
#"--extra-cflags=" #"--extra-cflags="
#"--prefix=" #"--prefix="

View File

@ -1,4 +1,6 @@
{ stdenv, fetchurl, gmp }: { stdenv, fetchurl, gmp
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "mpfr-3.1.3"; name = "mpfr-3.1.3";
@ -19,10 +21,10 @@ stdenv.mkDerivation rec {
hardeningDisable = [ "stackprotector" ]; hardeningDisable = [ "stackprotector" ];
configureFlags = configureFlags =
stdenv.lib.optional stdenv.isSunOS "--disable-thread-safe" ++ stdenv.lib.optional hostPlatform.isSunOS "--disable-thread-safe" ++
stdenv.lib.optional stdenv.is64bit "--with-pic"; stdenv.lib.optional hostPlatform.is64bit "--with-pic";
doCheck = true; doCheck = hostPlatform == buildPlatform;
enableParallelBuilding = true; enableParallelBuilding = true;

View File

@ -1,5 +1,7 @@
{ stdenv, fetchurl { stdenv, fetchurl
, windows ? null, variant ? null, pcre , pcre, windows ? null
, buildPlatform, hostPlatform
, variant ? null
}: }:
with stdenv.lib; with stdenv.lib;
@ -31,7 +33,9 @@ in stdenv.mkDerivation rec {
patches = [ ./CVE-2017-7186.patch ]; patches = [ ./CVE-2017-7186.patch ];
doCheck = with stdenv; !(isCygwin || isFreeBSD); buildInputs = optional (hostPlatform.libc == "msvcrt") windows.mingw_w64_pthreads;
doCheck = !(with hostPlatform; isCygwin || isFreeBSD) && hostPlatform == buildPlatform;
# XXX: test failure on Cygwin # XXX: test failure on Cygwin
# we are running out of stack on both freeBSDs on Hydra # we are running out of stack on both freeBSDs on Hydra
@ -42,10 +46,6 @@ in stdenv.mkDerivation rec {
ln -sf -t "$out/lib/" '${pcre.out}'/lib/libpcre{,posix}.{so.*.*.*,*dylib} ln -sf -t "$out/lib/" '${pcre.out}'/lib/libpcre{,posix}.{so.*.*.*,*dylib}
''; '';
crossAttrs = optionalAttrs (stdenv.cross.libc == "msvcrt") {
buildInputs = [ windows.mingw_w64_pthreads.crossDrv ];
};
meta = { meta = {
homepage = "http://www.pcre.org/"; homepage = "http://www.pcre.org/";
description = "A library for Perl Compatible Regular Expressions"; description = "A library for Perl Compatible Regular Expressions";

View File

@ -1,5 +1,7 @@
{ stdenv, fetchurl, cmake, zlib, freetype, libjpeg, libtiff, fontconfig { stdenv, fetchurl, cmake, zlib, freetype, libjpeg, libtiff, fontconfig
, gcc5, openssl, libpng, lua5, pkgconfig, libidn, expat }: , openssl, libpng, lua5, pkgconfig, libidn, expat
, gcc5 # TODO(@Dridus) remove this at next hash break
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "podofo-0.9.5"; name = "podofo-0.9.5";
@ -11,18 +13,12 @@ stdenv.mkDerivation rec {
propagatedBuildInputs = [ zlib freetype libjpeg libtiff fontconfig openssl libpng libidn expat ]; propagatedBuildInputs = [ zlib freetype libjpeg libtiff fontconfig openssl libpng libidn expat ];
# Does Linux really need gcc5? Darwin doesn't seem to... # TODO(@Dridus) remove the ++ ghc5 at next hash break
nativeBuildInputs = [ cmake pkgconfig ] ++ stdenv.lib.optional stdenv.isLinux gcc5; nativeBuildInputs = [ cmake pkgconfig ] ++ stdenv.lib.optional stdenv.isLinux gcc5;
# Does Linux really need libc here? Darwin doesn't seem to... # TODO(@Dridus) remove the ++ libc at next hash break
buildInputs = [ lua5 ] ++ stdenv.lib.optional stdenv.isLinux stdenv.cc.libc; buildInputs = [ lua5 ] ++ stdenv.lib.optional stdenv.isLinux stdenv.cc.libc;
crossAttrs = {
propagatedBuildInputs = [ zlib.crossDrv freetype.crossDrv libjpeg.crossDrv
libtiff.crossDrv fontconfig.crossDrv openssl.crossDrv libpng.crossDrv
lua5.crossDrv stdenv.ccCross.libc ];
};
cmakeFlags = "-DPODOFO_BUILD_SHARED=ON -DPODOFO_BUILD_STATIC=OFF"; cmakeFlags = "-DPODOFO_BUILD_SHARED=ON -DPODOFO_BUILD_STATIC=OFF";
meta = { meta = {

View File

@ -209,7 +209,7 @@ stdenv.mkDerivation rec {
postInstall = '' postInstall = ''
cp bin/qmake* $out/bin cp bin/qmake* $out/bin
''; '';
dontSetConfigureCross = true; configurePlatforms = [];
dontStrip = true; dontStrip = true;
} // optionalAttrs isMingw { } // optionalAttrs isMingw {
propagatedBuildInputs = [ ]; propagatedBuildInputs = [ ];

View File

@ -1,4 +1,8 @@
{ stdenv, fetchurl, static ? false }: { stdenv
, fetchurl
, buildPlatform, hostPlatform
, static ? false
}:
let version = "1.2.11"; in let version = "1.2.11"; in
@ -24,7 +28,9 @@ stdenv.mkDerivation rec {
setOutputFlags = false; setOutputFlags = false;
outputDoc = "dev"; # single tiny man3 page outputDoc = "dev"; # single tiny man3 page
preConfigure = '' # 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 if test -n "$crossConfig"; then
export CC=$crossConfig-gcc export CC=$crossConfig-gcc
fi fi
@ -53,7 +59,7 @@ stdenv.mkDerivation rec {
crossAttrs = { crossAttrs = {
dontStrip = static; dontStrip = static;
dontSetConfigureCross = true; configurePlatforms = [];
} // stdenv.lib.optionalAttrs (stdenv.cross.libc == "msvcrt") { } // stdenv.lib.optionalAttrs (stdenv.cross.libc == "msvcrt") {
installFlags = [ installFlags = [
"BINARY_PATH=$(out)/bin" "BINARY_PATH=$(out)/bin"

View File

@ -50,7 +50,8 @@ stdenv.mkDerivation rec {
++ [ "info" ] ++ [ "info" ]
++ optional (targetPlatform == hostPlatform) "dev"; ++ optional (targetPlatform == hostPlatform) "dev";
nativeBuildInputs = [ bison ]; nativeBuildInputs = [ bison ]
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
buildInputs = [ zlib ]; buildInputs = [ zlib ];
inherit noSysDirs; inherit noSysDirs;

View File

@ -6,7 +6,7 @@
, stdenv , stdenv
, coreutils , coreutils
, gnugrep , gnugrep
, targetPlatform , hostPlatform, targetPlatform
}: }:
/* As of this writing, known-good prefix/arch/simulator triples: /* As of this writing, known-good prefix/arch/simulator triples:
@ -28,14 +28,14 @@ let
sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk"; sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk";
/* TODO: Properly integrate with gcc-cross-wrapper */ in (import ../../../build-support/cc-wrapper {
wrapper = import ../../../build-support/cc-wrapper { inherit stdenv coreutils gnugrep runCommand;
inherit stdenv coreutils gnugrep;
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
inherit binutils; inherit binutils;
libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}"; libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}";
cc = clang; inherit (clang) cc;
inherit hostPlatform targetPlatform;
extraBuildCommands = '' extraBuildCommands = ''
if ! [ -d ${sdk} ]; then if ! [ -d ${sdk} ]; then
echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2 echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2
@ -49,27 +49,6 @@ let
# Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust # Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust
echo "-arch ${arch} -L${sdk}/usr/lib ${lib.optionalString simulator "-L${sdk}/usr/lib/system "}-i${if simulator then "os_simulator" else "phoneos"}_version_min 7.0.0" > $out/nix-support/libc-ldflags-before echo "-arch ${arch} -L${sdk}/usr/lib ${lib.optionalString simulator "-L${sdk}/usr/lib/system "}-i${if simulator then "os_simulator" else "phoneos"}_version_min 7.0.0" > $out/nix-support/libc-ldflags-before
''; '';
}; }) // {
in { inherit sdkType sdkVer sdk;
cc = runCommand "${prefix}-cc" { passthru = { inherit sdkType sdkVer sdk; }; } '' }
mkdir -p $out/bin
ln -sv ${wrapper}/bin/clang $out/bin/${prefix}-cc
mkdir -p $out/nix-support
echo ${llvm} > $out/nix-support/propagated-native-build-inputs
cat > $out/nix-support/setup-hook <<EOF
if test "\$dontSetConfigureCross" != "1"; then
configureFlags="\$configureFlags --host=${prefix}"
fi
EOF
fixupPhase
'';
binutils = runCommand "${prefix}-binutils" {} ''
mkdir -p $out/bin
ln -sv ${wrapper}/bin/ld $out/bin/${prefix}-ld
for prog in ar nm ranlib; do
ln -s ${binutils}/bin/$prog $out/bin/${prefix}-$prog
done
fixupPhase
'';
}

View File

@ -1,8 +1,9 @@
{ stdenv, lib, fetchurl, glibc, musl { stdenv, lib, buildPackages, fetchurl
, enableStatic ? false , enableStatic ? false
, enableMinimal ? false , enableMinimal ? false
, useMusl ? false , useMusl ? false, musl
, extraConfig ? "" , extraConfig ? ""
, buildPlatform, hostPlatform
}: }:
let let
@ -71,20 +72,16 @@ stdenv.mkDerivation rec {
''; '';
postConfigure = lib.optionalString useMusl '' postConfigure = lib.optionalString useMusl ''
makeFlagsArray+=("CC=gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib") makeFlagsArray+=("CC=${stdenv.cc.prefix}gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib")
''; '';
nativeBuildInputs = lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ]; buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ];
crossAttrs = { extraCrossConfig = if hostPlatform == buildPlatform then null else ''
extraCrossConfig = '' CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cross.config}-" '';
'';
postConfigure = stdenv.lib.optionalString useMusl ''
makeFlagsArray+=("CC=$crossConfig-gcc -isystem ${musl.crossDrv}/include -B${musl.crossDrv}/lib -L${musl.crossDrv}/lib")
'';
};
enableParallelBuilding = true; enableParallelBuilding = true;

View File

@ -0,0 +1,11 @@
{ fetchurl }:
rec {
version = "4.0.6";
name = "mingw-w64-${version}";
src = fetchurl {
url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2";
sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c";
};
}

View File

@ -1,36 +1,7 @@
{ stdenv, fetchurl, binutils ? null, gccCross ? null { stdenv, callPackage, windows }:
, onlyHeaders ? false
, onlyPthreads ? false
}:
let
version = "4.0.6";
name = "mingw-w64-${version}";
in
stdenv.mkDerivation ({
inherit name;
src = fetchurl {
url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2";
sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c";
};
} //
(if onlyHeaders then {
name = name + "-headers";
preConfigure = ''
cd mingw-w64-headers
'';
configureFlags = "--without-crt";
} else if onlyPthreads then {
name = name + "-pthreads";
preConfigure = ''
cd mingw-w64-libraries/winpthreads
'';
} else {
buildInputs = [ gccCross binutils ];
crossConfig = gccCross.crossConfig;
stdenv.mkDerivation {
inherit (callPackage ./common.nix {}) name src;
buildInputs = [ windows.mingw_w64_headers ];
dontStrip = true; dontStrip = true;
}) }
)

View File

@ -0,0 +1,13 @@
{ stdenvNoCC, callPackage }:
let
inherit (callPackage ./common.nix {}) name src;
in stdenvNoCC.mkDerivation {
name = name + "-headers";
inherit src;
preConfigure = ''
cd mingw-w64-headers
'';
}

View File

@ -0,0 +1,13 @@
{ stdenvNoCC, callPackage }:
let
inherit (callPackage ./common.nix {}) name src;
in stdenvNoCC.mkDerivation {
name = name + "-pthreads";
inherit src;
preConfigure = ''
cd mingw-w64-libraries/winpthreads
'';
}

View File

@ -1,15 +1,16 @@
{ stdenv, fetchurl, readline70 ? null, interactive ? false, texinfo ? null { stdenv, buildPackages
, binutils ? null, bison , fetchurl, readline70 ? null, texinfo ? null, binutils ? null, bison
, buildPlatform, hostPlatform
, interactive ? false
}: }:
assert interactive -> readline70 != null; assert interactive -> readline70 != null;
assert stdenv.isDarwin -> binutils != null; assert hostPlatform.isDarwin -> binutils != null;
let let
version = "4.4"; version = "4.4";
realName = "bash-${version}"; realName = "bash-${version}";
shortName = "bash44"; shortName = "bash44";
baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline";
sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"; sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq";
upstreamPatches = upstreamPatches =
@ -22,7 +23,7 @@ let
in in
import ./bash-4.4-patches.nix patch; import ./bash-4.4-patches.nix patch;
inherit (stdenv.lib) optional optionalString; inherit (stdenv.lib) optional optionals;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -52,26 +53,25 @@ stdenv.mkDerivation rec {
patchFlags = "-p0"; patchFlags = "-p0";
patches = upstreamPatches patches = upstreamPatches
++ optional stdenv.isCygwin ./cygwin-bash-4.3.33-1.src.patch; ++ optional hostPlatform.isCygwin ./cygwin-bash-4.3.33-1.src.patch;
crossAttrs = { configureFlags = [
configureFlags = baseConfigureFlags + (if interactive then "--with-installed-readline" else "--disable-readline")
" bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" + ] ++ optionals (hostPlatform != buildPlatform) [
optionalString stdenv.isCygwin '' "bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes"
--without-libintl-prefix --without-libiconv-prefix ] ++ optionals hostPlatform.isCygwin [
--with-installed-readline "--without-libintl-prefix --without-libiconv-prefix"
bash_cv_dev_stdin=present "--with-installed-readline"
bash_cv_dev_fd=standard "bash_cv_dev_stdin=present"
bash_cv_termcap_lib=libncurses "bash_cv_dev_fd=standard"
''; "bash_cv_termcap_lib=libncurses"
}; ];
configureFlags = baseConfigureFlags;
# Note: Bison is needed because the patches above modify parse.y. # Note: Bison is needed because the patches above modify parse.y.
nativeBuildInputs = [bison] nativeBuildInputs = [bison]
++ optional (texinfo != null) texinfo ++ optional (texinfo != null) texinfo
++ optional stdenv.isDarwin binutils; ++ optional hostPlatform.isDarwin binutils
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
buildInputs = optional interactive readline70; buildInputs = optional interactive readline70;

View File

@ -56,16 +56,36 @@ rec {
# Return a modified stdenv that adds a cross compiler to the # Return a modified stdenv that adds a cross compiler to the
# builds. # builds.
makeStdenvCross = stdenv: cross: binutils: gccCross: stdenv // { makeStdenvCross = { stdenv
, cc
, buildPlatform, hostPlatform, targetPlatform
} @ overrideArgs: let
stdenv = overrideArgs.stdenv.override {
# TODO(@Ericson2314): Cannot do this for now because then Nix thinks the
# resulting derivation should be built on the host platform.
#hostPlatform = buildPlatform;
#targetPlatform = hostPlatform;
inherit cc;
# Overrides are surely not valid as packages built with this run on a allowedRequisites = null;
# different platform.
overrides = _: _: {};
# Overrides are surely not valid as packages built with this run on a
# different platform.
overrides = _: _: {};
};
in stdenv // {
mkDerivation = mkDerivation =
{ name ? "", buildInputs ? [], nativeBuildInputs ? [] { name ? "", buildInputs ? [], nativeBuildInputs ? []
, propagatedBuildInputs ? [], propagatedNativeBuildInputs ? [] , propagatedBuildInputs ? [], propagatedNativeBuildInputs ? []
, selfNativeBuildInput ? false, ... , # Disabling the tests by default when cross compiling, as usually the
# tests rely on being able to run produced binaries.
doCheck ? false
, configureFlags ? []
, # Target is not included by default because most programs don't care.
# Including it then would cause needless massive rebuilds.
configurePlatforms ? args.crossAttrs.configurePlatforms or [ "build" "host" ]
, selfNativeBuildInput ? args.crossAttrs.selfNativeBuildInput or false
, ...
} @ args: } @ args:
let let
@ -88,17 +108,25 @@ rec {
nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull; nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull;
in in
stdenv.mkDerivation (args // { stdenv.mkDerivation (args // {
name = name + "-" + cross.config; name = name + "-" + hostPlatform.config;
nativeBuildInputs = nativeBuildInputs nativeBuildInputs = nativeBuildInputs
++ nativeInputsFromBuildInputs ++ nativeInputsFromBuildInputs
++ [ gccCross binutils ]
++ stdenv.lib.optional selfNativeBuildInput nativeDrv ++ stdenv.lib.optional selfNativeBuildInput nativeDrv
# without proper `file` command, libtool sometimes fails # without proper `file` command, libtool sometimes fails
# to recognize 64-bit DLLs # to recognize 64-bit DLLs
++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file
++ stdenv.lib.optional (cross.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook ++ stdenv.lib.optional (hostPlatform.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook
; ;
inherit doCheck;
# This parameter is sometimes a string and sometimes a list, yuck
configureFlags = let inherit (stdenv.lib) optional elem; in
(if stdenv.lib.isString configureFlags then [configureFlags] else configureFlags)
++ optional (elem "build" configurePlatforms) "--build=${buildPlatform.config}"
++ optional (elem "host" configurePlatforms) "--host=${hostPlatform.config}"
++ optional (elem "target" configurePlatforms) "--target=${targetPlatform.config}";
# Cross-linking dynamic libraries, every buildInput should # Cross-linking dynamic libraries, every buildInput should
# be propagated because ld needs the -rpath-link to find # be propagated because ld needs the -rpath-link to find
# any library needed to link the program dynamically at # any library needed to link the program dynamically at
@ -107,12 +135,8 @@ rec {
propagatedBuildInputs = propagatedBuildInputs ++ buildInputs; propagatedBuildInputs = propagatedBuildInputs ++ buildInputs;
propagatedNativeBuildInputs = propagatedNativeBuildInputs; propagatedNativeBuildInputs = propagatedNativeBuildInputs;
crossConfig = cross.config; crossConfig = hostPlatform.config;
} // args.crossAttrs or {}); } // args.crossAttrs or {});
inherit gccCross binutils;
ccCross = gccCross;
}; };

View File

@ -31,15 +31,15 @@ in bootStages ++ [
targetPlatform = crossSystem; targetPlatform = crossSystem;
inherit config overlays; inherit config overlays;
selfBuild = false; selfBuild = false;
stdenv = if crossSystem.useiOSCross or false stdenv = buildPackages.makeStdenvCross {
then let inherit (buildPackages) stdenv;
inherit (buildPackages.darwin.ios-cross) cc binutils; buildPlatform = localSystem;
in buildPackages.makeStdenvCross hostPlatform = crossSystem;
buildPackages.stdenv crossSystem targetPlatform = crossSystem;
binutils cc cc = if crossSystem.useiOSCross or false
else buildPackages.makeStdenvCross then buildPackages.darwin.ios-cross
buildPackages.stdenv crossSystem else buildPackages.gccCrossStageFinal;
buildPackages.binutils buildPackages.gccCrossStageFinal; };
}) })
] ]

View File

@ -73,6 +73,8 @@ in rec {
nativeTools = true; nativeTools = true;
nativePrefix = bootstrapTools; nativePrefix = bootstrapTools;
nativeLibc = false; nativeLibc = false;
hostPlatform = localSystem;
targetPlatform = localSystem;
libc = last.pkgs.darwin.Libsystem; libc = last.pkgs.darwin.Libsystem;
isClang = true; isClang = true;
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; }; cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
@ -295,6 +297,8 @@ in rec {
inherit shell; inherit shell;
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit (pkgs) coreutils binutils gnugrep; inherit (pkgs) coreutils binutils gnugrep;
inherit (pkgs.darwin) dyld; inherit (pkgs.darwin) dyld;
cc = pkgs.llvmPackages.clang-unwrapped; cc = pkgs.llvmPackages.clang-unwrapped;

View File

@ -77,6 +77,8 @@ let inherit (localSystem) system; in
nativeTools = true; nativeTools = true;
nativePrefix = "/usr"; nativePrefix = "/usr";
nativeLibc = true; nativeLibc = true;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit (prevStage) stdenv; inherit (prevStage) stdenv;
cc = { cc = {
name = "clang-9.9.9"; name = "clang-9.9.9";

View File

@ -76,6 +76,8 @@ let
else lib.makeOverridable (import ../../build-support/cc-wrapper) { else lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
hostPlatform = localSystem;
targetPlatform = localSystem;
cc = prevStage.gcc-unwrapped; cc = prevStage.gcc-unwrapped;
isGNU = true; isGNU = true;
libc = prevStage.glibc; libc = prevStage.glibc;
@ -239,6 +241,8 @@ in
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
isGNU = true; isGNU = true;
hostPlatform = localSystem;
targetPlatform = localSystem;
cc = prevStage.gcc-unwrapped; cc = prevStage.gcc-unwrapped;
libc = self.glibc; libc = self.glibc;
inherit (self) stdenv binutils coreutils gnugrep; inherit (self) stdenv binutils coreutils gnugrep;

View File

@ -81,7 +81,6 @@ rec {
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.buildPackages.nukeReferences pkgs.buildPackages.nukeReferences
pkgs.buildPackages.cpio pkgs.buildPackages.cpio
pkgs.buildPackages.binutils
]; ];
buildCommand = '' buildCommand = ''

View File

@ -125,6 +125,8 @@ in
"i686-solaris" = "/usr/gnu"; "i686-solaris" = "/usr/gnu";
"x86_64-solaris" = "/opt/local/gcc47"; "x86_64-solaris" = "/opt/local/gcc47";
}.${system} or "/usr"; }.${system} or "/usr";
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit stdenv; inherit stdenv;
}; };

View File

@ -30,6 +30,8 @@ bootStages ++ [
nativeTools = false; nativeTools = false;
nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr";
nativeLibc = true; nativeLibc = true;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit stdenv; inherit stdenv;
inherit (prevStage) binutils coreutils gnugrep; inherit (prevStage) binutils coreutils gnugrep;
cc = prevStage.gcc.cc; cc = prevStage.gcc.cc;

View File

@ -0,0 +1,12 @@
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -42,9 +42,7 @@
# such as -DDOSWILD).
# UnZip flags
-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
LOC = $(D_USE_BZ2) $(LOCAL_UNZIP)
AF = $(LOC)
CFLAGS = -O

View File

@ -1,5 +1,8 @@
{ stdenv, fetchurl, bzip2 { stdenv, fetchurl
, enableNLS ? false, libnatspec }: , bzip2
, enableNLS ? false, libnatspec
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "unzip-6.0"; name = "unzip-6.0";
@ -25,14 +28,15 @@ stdenv.mkDerivation {
url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1"; url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1";
name = "unzip-6.0-natspec.patch"; name = "unzip-6.0-natspec.patch";
sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
}); })
++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch;
nativeBuildInputs = [ bzip2 ]; nativeBuildInputs = [ bzip2 ];
buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec; buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec;
makefile = "unix/Makefile"; makefile = "unix/Makefile";
NIX_LDFLAGS = [ "-lbz2" ] ++ stdenv.lib.optional enableNLS "-lnatspec"; ${"NIX_${stdenv.cc.infixSalt_}LDFLAGS"} = [ "-lbz2" ] ++ stdenv.lib.optional enableNLS "-lnatspec";
buildFlags = "generic D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2"; buildFlags = "generic D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2";

View File

@ -1,8 +1,9 @@
{ lib, stdenv, buildPackages, fetchurl, perl, xz, gmp ? null { stdenv, lib, buildPackages
, autoconf, automake114x, texinfo, fetchurl, perl, xz, libiconv, gmp ? null
, hostPlatform, buildPlatform
, aclSupport ? false, acl ? null , aclSupport ? false, acl ? null
, attrSupport ? false, attr ? null , attrSupport ? false, attr ? null
, selinuxSupport? false, libselinux ? null, libsepol ? null , selinuxSupport? false, libselinux ? null, libsepol ? null
, autoconf, automake114x, texinfo
, withPrefix ? false , withPrefix ? false
, singleBinary ? "symlinks" # you can also pass "shebangs" or false , singleBinary ? "symlinks" # you can also pass "shebangs" or false
}: }:
@ -23,10 +24,10 @@ stdenv.mkDerivation rec {
# FIXME needs gcc 4.9 in bootstrap tools # FIXME needs gcc 4.9 in bootstrap tools
hardeningDisable = [ "stackprotector" ]; hardeningDisable = [ "stackprotector" ];
patches = optional stdenv.isCygwin ./coreutils-8.23-4.cygwin.patch; patches = optional hostPlatform.isCygwin ./coreutils-8.23-4.cygwin.patch;
# The test tends to fail on btrfs and maybe other unusual filesystems. # The test tends to fail on btrfs and maybe other unusual filesystems.
postPatch = optionalString (!stdenv.isDarwin) '' postPatch = optionalString (!hostPlatform.isDarwin) ''
sed '2i echo Skipping dd sparse test && exit 0' -i ./tests/dd/sparse.sh sed '2i echo Skipping dd sparse test && exit 0' -i ./tests/dd/sparse.sh
sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh
sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh
@ -42,58 +43,54 @@ stdenv.mkDerivation rec {
configureFlags = configureFlags =
optional (singleBinary != false) optional (singleBinary != false)
("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}") ("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}")
++ optional stdenv.isSunOS "ac_cv_func_inotify_init=no" ++ optional hostPlatform.isSunOS "ac_cv_func_inotify_init=no"
++ optional withPrefix "--program-prefix=g"; ++ optional withPrefix "--program-prefix=g"
++ optionals (hostPlatform != buildPlatform && hostPlatform.libc == "glibc") [
# TODO(19b98110126fde7cbb1127af7e3fe1568eacad3d): Needed for fstatfs() I
# don't know why it is not properly detected cross building with glibc.
"fu_cv_sys_stat_statfs2_bsize=yes"
];
buildInputs = [ gmp ] buildInputs = [ gmp ]
++ optional aclSupport acl ++ optional aclSupport acl
++ optional attrSupport attr ++ optional attrSupport attr
++ optionals stdenv.isCygwin [ autoconf automake114x texinfo ] # due to patch ++ optionals hostPlatform.isCygwin [ autoconf automake114x texinfo ] # due to patch
++ optionals selinuxSupport [ libselinux libsepol ]; ++ optionals selinuxSupport [ libselinux libsepol ]
# TODO(@Ericson2314): Investigate whether Darwin could benefit too
crossAttrs = { ++ optional (hostPlatform != buildPlatform && hostPlatform.libc != "glibc") libiconv;
buildInputs = [ gmp.crossDrv ]
++ optional aclSupport acl.crossDrv
++ optional attrSupport attr.crossDrv
++ optionals selinuxSupport [ libselinux.crossDrv libsepol.crossDrv ]
++ optional (stdenv ? ccCross.libc.libiconv)
stdenv.ccCross.libc.libiconv.crossDrv;
# Prevents attempts of running 'help2man' on cross-built binaries.
PERL = "missing";
# Works around a bug with 8.26:
# Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
preInstall = ''
sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
'';
postInstall = ''
rm $out/share/man/man1/*
cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
'';
# Needed for fstatfs()
# I don't know why it is not properly detected cross building with glibc.
configureFlags = [ "fu_cv_sys_stat_statfs2_bsize=yes" ];
doCheck = false;
};
# The tests are known broken on Cygwin # The tests are known broken on Cygwin
# (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025), # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
# Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351), # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
# and {Open,Free}BSD. # and {Open,Free}BSD.
# With non-standard storeDir: https://github.com/NixOS/nix/issues/512 # With non-standard storeDir: https://github.com/NixOS/nix/issues/512
doCheck = stdenv ? glibc && builtins.storeDir == "/nix/store"; doCheck = hostPlatform == buildPlatform
&& hostPlatform.libc == "glibc"
&& builtins.storeDir == "/nix/store";
# Prevents attempts of running 'help2man' on cross-built binaries.
${if hostPlatform == buildPlatform then null else "PERL"} = "missing";
# Saw random failures like help2man: can't get '--help' info from # Saw random failures like help2man: can't get '--help' info from
# man/sha512sum.td/sha512sum. # man/sha512sum.td/sha512sum.
enableParallelBuilding = false; enableParallelBuilding = false;
NIX_LDFLAGS = optionalString selinuxSupport "-lsepol"; NIX_LDFLAGS = optionalString selinuxSupport "-lsepol";
FORCE_UNSAFE_CONFIGURE = optionalString stdenv.isSunOS "1"; FORCE_UNSAFE_CONFIGURE = optionalString hostPlatform.isSunOS "1";
makeFlags = optionalString stdenv.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0"; makeFlags = optionalString hostPlatform.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0";
# Works around a bug with 8.26:
# Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
${if hostPlatform == buildPlatform then null else "preInstall"} = ''
sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
'';
${if hostPlatform == buildPlatform then null else "postInstall"} = ''
rm $out/share/man/man1/*
cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
'';
meta = { meta = {
homepage = http://www.gnu.org/software/coreutils/; homepage = http://www.gnu.org/software/coreutils/;
@ -112,4 +109,5 @@ stdenv.mkDerivation rec {
maintainers = [ maintainers.eelco ]; maintainers = [ maintainers.eelco ];
}; };
} }

View File

@ -1,4 +1,9 @@
{ stdenv, fetchurl, coreutils }: { stdenv, fetchurl
, coreutils
, buildPlatform, hostPlatform
}:
let inherit (stdenv.lib) optionals; in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "findutils-4.6.0"; name = "findutils-4.6.0";
@ -10,20 +15,18 @@ stdenv.mkDerivation rec {
patches = [ ./memory-leak.patch ./no-install-statedir.patch ]; patches = [ ./memory-leak.patch ./no-install-statedir.patch ];
buildInputs = [ coreutils ]; # bin/updatedb script needs to call sort buildInputs = optionals (hostPlatform == buildPlatform) [ coreutils ]; # bin/updatedb script needs to call sort
# Since glibc-2.25 the i686 tests hang reliably right after test-sleep. # Since glibc-2.25 the i686 tests hang reliably right after test-sleep.
doCheck = !stdenv.isDarwin && (stdenv.system != "i686-linux"); doCheck
= !hostPlatform.isDarwin
&& !(hostPlatform.libc == "glibc" && hostPlatform.isi686)
&& hostPlatform == buildPlatform;
outputs = [ "out" "info" ]; outputs = [ "out" "info" ];
configureFlags = [ "--localstatedir=/var/cache" ]; configureFlags = [ "--localstatedir=/var/cache" ];
crossAttrs = {
# Fix the 'buildInputs = [ coreutils ]' above - that adds the cross coreutils to PATH :(
propagatedBuildInputs = [ ];
};
enableParallelBuilding = true; enableParallelBuilding = true;
meta = { meta = {

View File

@ -1,5 +1,6 @@
{ stdenv, fetchgit, libusb, libusb1, autoconf, automake, confuse, pkgconfig { stdenv, fetchgit, libusb, libusb1, autoconf, automake, confuse, pkgconfig
, gccCross ? null }: , gccCross ? null, crossPrefix
}:
let let
version = "2011-12-26"; version = "2011-12-26";
@ -18,7 +19,7 @@ stdenv.mkDerivation {
''; '';
configureFlags = if gccCross != null then configureFlags = if gccCross != null then
"--enable-firmware CROSS_COMPILE=${gccCross.crossConfig}-" "--enable-firmware CROSS_COMPILE=${crossPrefix}-"
else ""; else "";
# Not to strip cross build binaries (this is for the gcc-cross-wrapper) # Not to strip cross build binaries (this is for the gcc-cross-wrapper)

View File

@ -22,13 +22,6 @@ stdenv.mkDerivation rec {
makeFlags=VPATH=`cat $NIX_CC/nix-support/orig-libc`/lib makeFlags=VPATH=`cat $NIX_CC/nix-support/orig-libc`/lib
''; '';
crossAttrs = {
# This works for uclibc, at least.
preConfigure = ''
makeFlags=VPATH=`cat ${stdenv.ccCross}/nix-support/orig-libc`/lib
'';
};
patches = [ patches = [
# Allow sessions to inherit the PATH from the parent dropbear. # Allow sessions to inherit the PATH from the parent dropbear.
# Otherwise they only get the usual /bin:/usr/bin kind of PATH # Otherwise they only get the usual /bin:/usr/bin kind of PATH

View File

@ -1,4 +1,9 @@
{ stdenv, fetchurl, lzip }: { stdenv
, fetchurl, lzip
, hostPlatform, buildPlatform
}:
let inherit (stdenv.lib) optionals; in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "ddrescue-1.22"; name = "ddrescue-1.22";
@ -10,7 +15,12 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ lzip ]; nativeBuildInputs = [ lzip ];
doCheck = true; doCheck = hostPlatform == buildPlatform;
${if hostPlatform != buildPlatform then "crossPlatforms" else null} = [ ];
${if hostPlatform != buildPlatform then "configureFlags" else null} = [
"CXX=${stdenv.cc.prefix}c++"
];
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "GNU ddrescue, a data recovery tool"; description = "GNU ddrescue, a data recovery tool";

View File

@ -1,4 +1,7 @@
{ stdenv, fetchurl, ed }: { stdenv, fetchurl
, ed
, buildPlatform, hostPlatform
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "patch-2.7.5"; name = "patch-2.7.5";
@ -10,11 +13,11 @@ stdenv.mkDerivation rec {
buildInputs = stdenv.lib.optional doCheck ed; buildInputs = stdenv.lib.optional doCheck ed;
crossAttrs = { configureFlags = if hostPlatform == buildPlatform then null else [
configureFlags = [ "ac_cv_func_strnlen_working=yes" ]; "ac_cv_func_strnlen_working=yes"
}; ];
doCheck = true; doCheck = hostPlatform == buildPlatform;
meta = { meta = {
description = "GNU Patch, a program to apply differences to files"; description = "GNU Patch, a program to apply differences to files";

View File

@ -4816,15 +4816,16 @@ with pkgs;
x11_ssh_askpass = callPackage ../tools/networking/x11-ssh-askpass { }; x11_ssh_askpass = callPackage ../tools/networking/x11-ssh-askpass { };
xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools { xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools rec {
# It needs a cross compiler for mipsel to build the firmware it will # It needs a cross compiler for mipsel to build the firmware it will
# load into the Ben Nanonote # load into the Ben Nanonote
crossPrefix = "mipsel-unknown-linux";
gccCross = gccCross =
let let
pkgsCross = nixpkgsFun { pkgsCross = nixpkgsFun {
# Ben Nanonote system # Ben Nanonote system
crossSystem = { crossSystem = {
config = "mipsel-unknown-linux"; config = crossPrefix;
bigEndian = true; bigEndian = true;
arch = "mips"; arch = "mips";
float = "soft"; float = "soft";
@ -4843,7 +4844,7 @@ with pkgs;
}; };
}; };
in in
pkgsCross.gccCrossStageStatic; pkgsCross.buildPackages.gccCrossStageStatic;
}; };
xclip = callPackage ../tools/misc/xclip { }; xclip = callPackage ../tools/misc/xclip { };
@ -5163,13 +5164,21 @@ with pkgs;
gccApple = throw "gccApple is no longer supported"; gccApple = throw "gccApple is no longer supported";
# Can't just overrideCC, because then the stdenv-cross mkDerivation will be
# thrown away. TODO: find a better solution for this.
crossLibcStdenv = buildPackages.makeStdenvCross {
inherit (buildPackages.buildPackages) stdenv;
inherit buildPlatform hostPlatform targetPlatform;
cc = buildPackages.gccCrossStageStatic;
};
gccCrossStageStatic = assert targetPlatform != buildPlatform; let gccCrossStageStatic = assert targetPlatform != buildPlatform; let
libcCross1 = libcCross1 =
if targetPlatform.libc == "msvcrt" then windows.mingw_w64_headers if targetPlatform.libc == "msvcrt" then __targetPackages.windows.mingw_w64_headers
else if targetPlatform.libc == "libSystem" then darwin.xcode else if targetPlatform.libc == "libSystem" then darwin.xcode
else null; else null;
in wrapGCCCross { in wrapCCCross {
gcc = forcedNativePackages.gcc.cc.override { cc = forcedNativePackages.gcc.cc.override {
crossStageStatic = true; crossStageStatic = true;
langCC = false; langCC = false;
libcCross = libcCross1; libcCross = libcCross1;
@ -5179,19 +5188,17 @@ with pkgs;
}; };
libc = libcCross1; libc = libcCross1;
inherit (forcedNativePackages) binutils; inherit (forcedNativePackages) binutils;
cross = targetPlatform;
}; };
# Only needed for mingw builds # Only needed for mingw builds
gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapGCCCross { gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapCCCross {
gcc = gccCrossStageStatic.gcc; cc = gccCrossStageStatic.gcc;
libc = windows.mingw_headers2; libc = windows.mingw_headers2;
inherit (forcedNativePackages) binutils; inherit (forcedNativePackages) binutils;
cross = targetPlatform;
}; };
gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapGCCCross { gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapCCCross {
gcc = forcedNativePackages.gcc.cc.override { cc = forcedNativePackages.gcc.cc.override {
crossStageStatic = false; crossStageStatic = false;
# Why is this needed? # Why is this needed?
@ -5199,7 +5206,6 @@ with pkgs;
}; };
libc = libcCross; libc = libcCross;
inherit (forcedNativePackages) binutils; inherit (forcedNativePackages) binutils;
cross = targetPlatform;
}; };
gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 { gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 {
@ -5924,14 +5930,19 @@ with pkgs;
libc = glibc; libc = glibc;
}; };
wrapGCCCross = wrapCCCross =
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: {cc, libc, binutils, shell ? "", name ? "gcc-cross-wrapper"}:
forcedNativePackages.callPackage ../build-support/gcc-cross-wrapper { forcedNativePackages.ccWrapperFun {
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
noLibc = (libc == null); noLibc = (libc == null);
inherit gcc binutils libc shell name cross;
dyld = if stdenv.isDarwin then darwin.dyld else null;
isGNU = cc.isGNU or false;
isClang = cc.isClang or false;
inherit cc binutils libc shell name;
}; };
# prolog # prolog
@ -7798,13 +7809,7 @@ with pkgs;
# Being redundant to avoid cycles on boot. TODO: find a better way # Being redundant to avoid cycles on boot. TODO: find a better way
glibcCross = callPackage ../development/libraries/glibc { glibcCross = callPackage ../development/libraries/glibc {
installLocales = config.glibc.locales or false; installLocales = config.glibc.locales or false;
# Can't just overrideCC, because then the stdenv-cross mkDerivation will be stdenv = crossLibcStdenv;
# thrown away. TODO: find a better solution for this.
stdenv = buildPackages.makeStdenvCross
buildPackages.buildPackages.stdenv
buildPackages.targetPlatform
buildPackages.binutils
buildPackages.gccCrossStageStatic;
}; };
# We can choose: # We can choose:
@ -7813,7 +7818,7 @@ with pkgs;
# hack fixes the hack, *sigh*. # hack fixes the hack, *sigh*.
/**/ if name == "glibc" then __targetPackages.glibcCross or glibcCross /**/ if name == "glibc" then __targetPackages.glibcCross or glibcCross
else if name == "uclibc" then uclibcCross else if name == "uclibc" then uclibcCross
else if name == "msvcrt" then windows.mingw_w64 else if name == "msvcrt" then __targetPackages.windows.mingw_w64 or windows.mingw_w64
else if name == "libSystem" then darwin.xcode else if name == "libSystem" then darwin.xcode
else throw "Unknown libc"; else throw "Unknown libc";
@ -12573,17 +12578,12 @@ with pkgs;
}; };
mingw_w64 = callPackage ../os-specific/windows/mingw-w64 { mingw_w64 = callPackage ../os-specific/windows/mingw-w64 {
gccCross = gccCrossStageStatic; stdenv = crossLibcStdenv;
binutils = binutils;
}; };
mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64 { mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64/headers.nix { };
onlyHeaders = true;
};
mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64 { mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { };
onlyPthreads = true;
};
pthreads = callPackage ../os-specific/windows/pthread-w32 { pthreads = callPackage ../os-specific/windows/pthread-w32 {
mingw_headers = mingw_headers3; mingw_headers = mingw_headers3;