Merge pull request #26007 from obsidiansystems/cc-wrapper-prefix
Get rid of gcc-cross-wrapper
This commit is contained in:
commit
afd2bdbad2
|
@ -640,6 +640,16 @@ script) if it exists.</para>
|
|||
true.</para></listitem>
|
||||
</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>
|
||||
<term><varname>preConfigure</varname></term>
|
||||
<listitem><para>Hook executed at the start of the configure
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{stdenv, fetchurl, alsaLib }:
|
||||
{ stdenv
|
||||
, fetchurl, alsaLib
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "mpg123-1.23.8";
|
||||
|
@ -10,10 +13,8 @@ stdenv.mkDerivation rec {
|
|||
|
||||
buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
|
||||
|
||||
crossAttrs = {
|
||||
configureFlags = if stdenv.cross ? mpg123 then
|
||||
"--with-cpu=${stdenv.cross.mpg123.cpu}" else "";
|
||||
};
|
||||
${if buildPlatform != hostPlatform then "configureFlags" else null} =
|
||||
stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";
|
||||
|
||||
meta = {
|
||||
description = "Fast console MPEG Audio Player and decoder library";
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{ fetchurl, stdenv }:
|
||||
{ stdenv, fetchurl
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "ed-${version}";
|
||||
|
@ -28,11 +30,12 @@ stdenv.mkDerivation rec {
|
|||
make: *** [check] Error 127
|
||||
|
||||
*/
|
||||
doCheck = !stdenv.isDarwin;
|
||||
doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform);
|
||||
|
||||
crossAttrs = {
|
||||
compileFlags = [ "CC=${stdenv.cross.config}-gcc" ];
|
||||
};
|
||||
configureFlags = if hostPlatform == buildPlatform then null else [
|
||||
"--exec-prefix=${stdenv.cc.prefix}"
|
||||
"CC=${stdenv.cc.prefix}cc"
|
||||
];
|
||||
|
||||
meta = {
|
||||
description = "An implementation of the standard Unix editor";
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c";
|
||||
}
|
||||
# apple frameworks
|
||||
, Carbon, Cocoa }:
|
||||
, Carbon, Cocoa
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
let
|
||||
common = callPackage ./common.nix {};
|
||||
|
@ -17,12 +19,26 @@ stdenv.mkDerivation rec {
|
|||
inherit (common) version src postPatch hardeningDisable enableParallelBuilding meta;
|
||||
|
||||
buildInputs = [ ncurses pkgconfig ]
|
||||
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
||||
++ stdenv.lib.optionals hostPlatform.isDarwin [ Carbon Cocoa ];
|
||||
nativeBuildInputs = [ gettext ];
|
||||
|
||||
configureFlags = [
|
||||
"--enable-multibyte"
|
||||
"--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 = ''
|
||||
|
@ -31,22 +47,6 @@ stdenv.mkDerivation rec {
|
|||
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" ];
|
||||
|
||||
# To fix the trouble in vim73, that it cannot cross-build with this patch
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{ stdenv, fetchurl, ncurses, gzip, pkgconfig
|
||||
{ stdenv, buildPackages
|
||||
, fetchurl, pkgconfig, ncurses, gzip
|
||||
, sslSupport ? true, openssl ? null
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
assert sslSupport -> openssl != null;
|
||||
|
@ -15,7 +17,9 @@ stdenv.mkDerivation rec {
|
|||
|
||||
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;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
, libjpegSupport ? true, libjpeg ? null
|
||||
, useUnfreeCodecs ? false
|
||||
, darwin ? null
|
||||
, hostPlatform
|
||||
}:
|
||||
|
||||
assert fontconfigSupport -> (fontconfig != null);
|
||||
|
@ -185,13 +186,14 @@ stdenv.mkDerivation rec {
|
|||
'';
|
||||
|
||||
crossAttrs = {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
# Some things (vidix) are nanonote specific. Once someone cares, we can make options from them.
|
||||
# Note, the `target` vs `host` confusion is intensional.
|
||||
preConfigure = ''
|
||||
configureFlags="`echo $configureFlags |
|
||||
sed -e 's/--codecsdir[^ ]\+//' \
|
||||
-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
|
||||
--disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc"
|
||||
'';
|
||||
|
|
|
@ -44,7 +44,7 @@ let
|
|||
enableParallelBuilding = true;
|
||||
|
||||
crossAttrs = {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
configureFlags = configureFlags ++ [
|
||||
"--cross-prefix=${stdenv.cross.config}-"
|
||||
"--enable-cross-compile"
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
# script that sets up the right environment variables so that the
|
||||
# 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
|
||||
, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
|
||||
, dyld ? null # TODO: should this be a setup-hook on dyld?
|
||||
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
|
||||
, hostPlatform, targetPlatform
|
||||
, runCommand ? null
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
@ -17,32 +19,113 @@ with stdenv.lib;
|
|||
assert nativeTools -> nativePrefix != "";
|
||||
assert !nativeTools ->
|
||||
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.
|
||||
assert cc.langVhdl or false -> zlib != null;
|
||||
|
||||
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;
|
||||
ccName = (builtins.parseDrvName cc.name).name;
|
||||
|
||||
libc_bin = if nativeLibc then null else getBin libc;
|
||||
libc_dev = if nativeLibc then null else getDev libc;
|
||||
libc_lib = if nativeLibc then null else getLib libc;
|
||||
libc_bin = if libc == null then null else getBin libc;
|
||||
libc_dev = if libc == null then null else getDev libc;
|
||||
libc_lib = if libc == null then null else getLib libc;
|
||||
cc_solib = getLib cc;
|
||||
binutils_bin = if nativeTools then "" else getBin binutils;
|
||||
# The wrapper scripts use 'cat' and 'grep', so we may need 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)";
|
||||
|
||||
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
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name =
|
||||
(if name != "" then name else ccName + "-wrapper") +
|
||||
(if cc != null && ccVersion != "" then "-" + ccVersion else "");
|
||||
name = prefix
|
||||
+ (if name != "" then name else "${ccName}-wrapper")
|
||||
+ (stdenv.lib.optionalString (cc != null && ccVersion != "") "-${ccVersion}");
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
||||
|
@ -51,17 +134,18 @@ stdenv.mkDerivation {
|
|||
|
||||
|
||||
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: ''
|
||||
; We should handle propagation here too
|
||||
(mapc (lambda (arg)
|
||||
(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"))
|
||||
(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"))
|
||||
(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"
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
|
@ -91,12 +180,24 @@ stdenv.mkDerivation {
|
|||
# (the *last* value counts, so ours should come first).
|
||||
echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before
|
||||
'' 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
|
||||
# against the crt1.o from our own glibc, rather than the one in
|
||||
# /usr/lib. (This is only an issue when using an `impure'
|
||||
|
@ -117,7 +218,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
|
||||
+ (if nativeTools then ''
|
||||
ccPath="${if stdenv.isDarwin then cc else nativePrefix}/bin"
|
||||
ccPath="${if targetPlatform.isDarwin then cc else nativePrefix}/bin"
|
||||
ldPath="${nativePrefix}/bin"
|
||||
'' else ''
|
||||
echo $cc > $out/nix-support/orig-cc
|
||||
|
@ -161,136 +262,114 @@ stdenv.mkDerivation {
|
|||
# Propagate the wrapped cc so that if you install the wrapper,
|
||||
# you get tools like gcov, the manpages, etc. as well (including
|
||||
# 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
|
||||
''
|
||||
|
||||
+ optionalString (stdenv.isSunOS && nativePrefix != "") ''
|
||||
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
|
||||
# Solaris needs an additional ld wrapper.
|
||||
ldPath="${nativePrefix}/bin"
|
||||
exec="$ldPath/ld"
|
||||
wrap ld-solaris ${./ld-solaris-wrapper.sh}
|
||||
exec="$ldPath/${prefix}ld"
|
||||
wrap ld-solaris ${preWrap ./ld-solaris-wrapper.sh}
|
||||
'')
|
||||
|
||||
+ ''
|
||||
# Create a symlink to as (the assembler). This is useful when a
|
||||
# cc-wrapper is installed in a user environment, as it ensures that
|
||||
# the right assembler is called.
|
||||
if [ -e $ldPath/as ]; then
|
||||
ln -s $ldPath/as $out/bin/as
|
||||
if [ -e $ldPath/${prefix}as ]; then
|
||||
ln -s $ldPath/${prefix}as $out/bin/${prefix}as
|
||||
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
|
||||
wrap ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.gold
|
||||
if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
|
||||
wrap ${prefix}ld.gold ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
export real_cc=cc
|
||||
export real_cxx=c++
|
||||
export real_cc=${prefix}cc
|
||||
export real_cxx=${prefix}c++
|
||||
export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
|
||||
|
||||
if [ -e $ccPath/gcc ]; then
|
||||
wrap gcc ${./cc-wrapper.sh} $ccPath/gcc
|
||||
ln -s gcc $out/bin/cc
|
||||
export real_cc=gcc
|
||||
export real_cxx=g++
|
||||
if [ -e $ccPath/${prefix}gcc ]; then
|
||||
wrap ${prefix}gcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcc
|
||||
ln -s ${prefix}gcc $out/bin/${prefix}cc
|
||||
export real_cc=${prefix}gcc
|
||||
export real_cxx=${prefix}g++
|
||||
elif [ -e $ccPath/clang ]; then
|
||||
wrap clang ${./cc-wrapper.sh} $ccPath/clang
|
||||
ln -s clang $out/bin/cc
|
||||
wrap ${prefix}clang ${preWrap ./cc-wrapper.sh} $ccPath/clang
|
||||
ln -s ${prefix}clang $out/bin/${prefix}cc
|
||||
export real_cc=clang
|
||||
export real_cxx=clang++
|
||||
fi
|
||||
|
||||
if [ -e $ccPath/g++ ]; then
|
||||
wrap g++ ${./cc-wrapper.sh} $ccPath/g++
|
||||
ln -s g++ $out/bin/c++
|
||||
if [ -e $ccPath/${prefix}g++ ]; then
|
||||
wrap ${prefix}g++ ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}g++
|
||||
ln -s ${prefix}g++ $out/bin/${prefix}c++
|
||||
elif [ -e $ccPath/clang++ ]; then
|
||||
wrap clang++ ${./cc-wrapper.sh} $ccPath/clang++
|
||||
ln -s clang++ $out/bin/c++
|
||||
wrap ${prefix}clang++ ${preWrap ./cc-wrapper.sh} $ccPath/clang++
|
||||
ln -s ${prefix}clang++ $out/bin/${prefix}c++
|
||||
fi
|
||||
|
||||
if [ -e $ccPath/cpp ]; then
|
||||
wrap cpp ${./cc-wrapper.sh} $ccPath/cpp
|
||||
wrap ${prefix}cpp ${preWrap ./cc-wrapper.sh} $ccPath/cpp
|
||||
fi
|
||||
''
|
||||
|
||||
+ optionalString cc.langFortran or false ''
|
||||
wrap gfortran ${./cc-wrapper.sh} $ccPath/gfortran
|
||||
ln -sv gfortran $out/bin/g77
|
||||
ln -sv gfortran $out/bin/f77
|
||||
wrap ${prefix}gfortran ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gfortran
|
||||
ln -sv ${prefix}gfortran $out/bin/${prefix}g77
|
||||
ln -sv ${prefix}gfortran $out/bin/${prefix}f77
|
||||
''
|
||||
|
||||
+ 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 ''
|
||||
wrap gccgo ${./cc-wrapper.sh} $ccPath/gccgo
|
||||
wrap ${prefix}gccgo ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gccgo
|
||||
''
|
||||
|
||||
+ optionalString cc.langAda or false ''
|
||||
wrap gnatgcc ${./cc-wrapper.sh} $ccPath/gnatgcc
|
||||
wrap gnatmake ${./gnat-wrapper.sh} $ccPath/gnatmake
|
||||
wrap gnatbind ${./gnat-wrapper.sh} $ccPath/gnatbind
|
||||
wrap gnatlink ${./gnatlink-wrapper.sh} $ccPath/gnatlink
|
||||
wrap ${prefix}gnatgcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gnatgcc
|
||||
wrap ${prefix}gnatmake ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatmake
|
||||
wrap ${prefix}gnatbind ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatbind
|
||||
wrap ${prefix}gnatlink ${preWrap ./gnatlink-wrapper.sh} $ccPath/${prefix}gnatlink
|
||||
''
|
||||
|
||||
+ 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
|
||||
rm $out/nix-support/setup-hook.tmp
|
||||
|
||||
# some linkers on some platforms don't support specific -z 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"
|
||||
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"
|
||||
fi
|
||||
|
||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||
cp -p ${./utils.sh} $out/nix-support/utils.sh
|
||||
substituteAll ${preWrap ./add-flags.sh} $out/nix-support/add-flags.sh
|
||||
substituteAll ${preWrap ./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||
cp -p ${preWrap ./utils.sh} $out/nix-support/utils.sh
|
||||
''
|
||||
+ extraBuildCommands;
|
||||
|
||||
# The dynamic linker has different names on different Linux platforms.
|
||||
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 "";
|
||||
inherit dynamicLinker;
|
||||
|
||||
crossAttrs = {
|
||||
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 =
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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;
|
||||
};
|
||||
}
|
|
@ -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[@]}
|
|
@ -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[@]}
|
|
@ -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++
|
|
@ -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"
|
||||
}
|
|
@ -61,7 +61,6 @@ stdenv.mkDerivation {
|
|||
|
||||
crossAttrs = {
|
||||
shell = shell.crossDrv + shell.crossDrv.shellPath;
|
||||
libc = stdenv.ccCross.libc;
|
||||
coreutils = coreutils.crossDrv;
|
||||
binutils = binutils.crossDrv;
|
||||
gcc = gcc.crossDrv;
|
||||
|
|
|
@ -283,7 +283,7 @@ stdenv.mkDerivation ({
|
|||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||
# 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;
|
||||
configureFlags = ''
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
|
|
|
@ -401,7 +401,7 @@ stdenv.mkDerivation ({
|
|||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||
# 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;
|
||||
configureFlags = ''
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
|
|
|
@ -407,7 +407,7 @@ stdenv.mkDerivation ({
|
|||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||
# 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;
|
||||
configureFlags = ''
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
|
||||
, darwin ? null
|
||||
, buildPlatform, hostPlatform, targetPlatform
|
||||
, buildPackages
|
||||
}:
|
||||
|
||||
assert langJava -> zip != null && unzip != null
|
||||
|
@ -312,6 +313,7 @@ stdenv.mkDerivation ({
|
|||
++ (optionals langJava [ boehmgc zip unzip ])
|
||||
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
|
||||
++ (optionals (targetPlatform != hostPlatform) [binutils])
|
||||
++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc])
|
||||
++ (optionals langAda [gnatboot])
|
||||
++ (optionals langVhdl [gnat])
|
||||
|
||||
|
@ -422,7 +424,7 @@ stdenv.mkDerivation ({
|
|||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||
# 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;
|
||||
configureFlags = ''
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
|
@ -449,6 +451,8 @@ stdenv.mkDerivation ({
|
|||
)
|
||||
}
|
||||
${if langAda then " --enable-libada" else ""}
|
||||
--build=${buildPlatform.config}
|
||||
--host=${hostPlatform.config}
|
||||
--target=${targetPlatform.config}
|
||||
${xwithArch}
|
||||
${xwithCpu}
|
||||
|
|
|
@ -404,7 +404,7 @@ stdenv.mkDerivation ({
|
|||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||
# 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;
|
||||
configureFlags = ''
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
|
|
|
@ -405,7 +405,7 @@ stdenv.mkDerivation ({
|
|||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||
# 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;
|
||||
configureFlags = ''
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
|
|
|
@ -101,26 +101,26 @@ in stdenv.mkDerivation (rec {
|
|||
'';
|
||||
|
||||
configureFlags = [
|
||||
"CC=${stdenv.ccCross}/bin/${cross.config}-cc"
|
||||
"LD=${stdenv.binutils}/bin/${cross.config}-ld"
|
||||
"AR=${stdenv.binutils}/bin/${cross.config}-ar"
|
||||
"NM=${stdenv.binutils}/bin/${cross.config}-nm"
|
||||
"RANLIB=${stdenv.binutils}/bin/${cross.config}-ranlib"
|
||||
"CC=${stdenv.cc}/bin/${cross.config}-cc"
|
||||
"LD=${stdenv.cc}/bin/${cross.config}-ld"
|
||||
"AR=${stdenv.cc}/bin/${cross.config}-ar"
|
||||
"NM=${stdenv.cc}/bin/${cross.config}-nm"
|
||||
"RANLIB=${stdenv.cc}/bin/${cross.config}-ranlib"
|
||||
"--target=${cross.config}"
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++
|
||||
# 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";
|
||||
|
||||
buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ];
|
||||
buildInputs = commonBuildInputs;
|
||||
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
|
||||
passthru = {
|
||||
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";
|
||||
};
|
||||
})
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
, targetPatches
|
||||
, targetToolchains
|
||||
, doCheck ? true
|
||||
, buildPlatform, hostPlatform
|
||||
} @ args:
|
||||
|
||||
let
|
||||
|
@ -137,7 +138,8 @@ stdenv.mkDerivation {
|
|||
|
||||
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/rust-lang/rust/issues/30181
|
||||
|
|
|
@ -446,7 +446,7 @@ stdenv.mkDerivation rec {
|
|||
fi
|
||||
'';
|
||||
in {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
configureFlags = configureFlags ++ [
|
||||
"--cross-prefix=${stdenv.cross.config}-"
|
||||
"--enable-cross-compile"
|
||||
|
|
|
@ -187,7 +187,7 @@ stdenv.mkDerivation rec {
|
|||
fi
|
||||
'';
|
||||
in {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
configureFlags = configureFlags ++ [
|
||||
"--cross-prefix=${stdenv.cross.config}-"
|
||||
"--enable-cross-compile"
|
||||
|
|
|
@ -105,7 +105,7 @@ let
|
|||
installCheckTarget = "check"; # tests need to be run *after* installation
|
||||
|
||||
crossAttrs = {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
configureFlags = configureFlags ++ [
|
||||
"--cross-prefix=${stdenv.cross.config}-"
|
||||
"--enable-cross-compile"
|
||||
|
|
11
pkgs/development/libraries/libelf/cross-ar.patch
Normal file
11
pkgs/development/libraries/libelf/cross-ar.patch
Normal 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@
|
|
@ -1,4 +1,7 @@
|
|||
{ fetchurl, stdenv, gettext, glibc }:
|
||||
{ stdenv, fetchurl
|
||||
, gettext, glibc
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "libelf-0.8.13";
|
||||
|
@ -8,20 +11,20 @@ stdenv.mkDerivation rec {
|
|||
sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
|
||||
};
|
||||
|
||||
# TODO(@Ericson2314) Make unconditional next hash break
|
||||
patches = if hostPlatform == buildPlatform then null else [
|
||||
./cross-ar.patch
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
# FIXME needs gcc 4.9 in bootstrap tools
|
||||
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
|
||||
# Darwin, so disable NLS for now.
|
||||
# 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 ];
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
{ fetchurl, stdenv, gmp, mpfr }:
|
||||
{ stdenv, fetchurl
|
||||
, gmp, mpfr
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
let
|
||||
version = "1.0.3";
|
||||
in
|
||||
|
@ -14,7 +18,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
CFLAGS = "-I${gmp.dev}/include";
|
||||
|
||||
doCheck = true;
|
||||
doCheck = hostPlatform == buildPlatform;
|
||||
|
||||
# FIXME needs gcc 4.9 in bootstrap tools
|
||||
hardeningDisable = [ "stackprotector" ];
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{ fetchurl, stdenv }:
|
||||
{ stdenv, fetchurl
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "libsigsegv-2.11";
|
||||
|
@ -8,7 +10,7 @@ stdenv.mkDerivation rec {
|
|||
sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x";
|
||||
};
|
||||
|
||||
doCheck = true;
|
||||
doCheck = hostPlatform == buildPlatform;
|
||||
|
||||
meta = {
|
||||
homepage = http://www.gnu.org/software/libsigsegv/;
|
||||
|
|
|
@ -148,7 +148,7 @@ stdenv.mkDerivation rec {
|
|||
isCygwin = stdenv.cross.libc == "msvcrt";
|
||||
isDarwin = stdenv.cross.libc == "libSystem";
|
||||
in {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
configureFlags = configureFlags ++ [
|
||||
#"--extra-cflags="
|
||||
#"--extra-cxxflags="
|
||||
|
|
|
@ -156,7 +156,7 @@ stdenv.mkDerivation rec {
|
|||
isCygwin = stdenv.cross.libc == "msvcrt";
|
||||
isDarwin = stdenv.cross.libc == "libSystem";
|
||||
in {
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
configureFlags = configureFlags ++ [
|
||||
#"--extra-cflags="
|
||||
#"--prefix="
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{ stdenv, fetchurl, gmp }:
|
||||
{ stdenv, fetchurl, gmp
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "mpfr-3.1.3";
|
||||
|
@ -19,10 +21,10 @@ stdenv.mkDerivation rec {
|
|||
hardeningDisable = [ "stackprotector" ];
|
||||
|
||||
configureFlags =
|
||||
stdenv.lib.optional stdenv.isSunOS "--disable-thread-safe" ++
|
||||
stdenv.lib.optional stdenv.is64bit "--with-pic";
|
||||
stdenv.lib.optional hostPlatform.isSunOS "--disable-thread-safe" ++
|
||||
stdenv.lib.optional hostPlatform.is64bit "--with-pic";
|
||||
|
||||
doCheck = true;
|
||||
doCheck = hostPlatform == buildPlatform;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{ stdenv, fetchurl
|
||||
, windows ? null, variant ? null, pcre
|
||||
, pcre, windows ? null
|
||||
, buildPlatform, hostPlatform
|
||||
, variant ? null
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
@ -31,7 +33,9 @@ in stdenv.mkDerivation rec {
|
|||
|
||||
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
|
||||
# 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}
|
||||
'';
|
||||
|
||||
crossAttrs = optionalAttrs (stdenv.cross.libc == "msvcrt") {
|
||||
buildInputs = [ windows.mingw_w64_pthreads.crossDrv ];
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://www.pcre.org/";
|
||||
description = "A library for Perl Compatible Regular Expressions";
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{ 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 {
|
||||
name = "podofo-0.9.5";
|
||||
|
@ -11,18 +13,12 @@ stdenv.mkDerivation rec {
|
|||
|
||||
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;
|
||||
|
||||
# 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;
|
||||
|
||||
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";
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -209,7 +209,7 @@ stdenv.mkDerivation rec {
|
|||
postInstall = ''
|
||||
cp bin/qmake* $out/bin
|
||||
'';
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
dontStrip = true;
|
||||
} // optionalAttrs isMingw {
|
||||
propagatedBuildInputs = [ ];
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
{ stdenv, fetchurl, static ? false }:
|
||||
{ stdenv
|
||||
, fetchurl
|
||||
, buildPlatform, hostPlatform
|
||||
, static ? false
|
||||
}:
|
||||
|
||||
let version = "1.2.11"; in
|
||||
|
||||
|
@ -24,7 +28,9 @@ stdenv.mkDerivation rec {
|
|||
setOutputFlags = false;
|
||||
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
|
||||
export CC=$crossConfig-gcc
|
||||
fi
|
||||
|
@ -53,7 +59,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
crossAttrs = {
|
||||
dontStrip = static;
|
||||
dontSetConfigureCross = true;
|
||||
configurePlatforms = [];
|
||||
} // stdenv.lib.optionalAttrs (stdenv.cross.libc == "msvcrt") {
|
||||
installFlags = [
|
||||
"BINARY_PATH=$(out)/bin"
|
||||
|
|
|
@ -50,7 +50,8 @@ stdenv.mkDerivation rec {
|
|||
++ [ "info" ]
|
||||
++ optional (targetPlatform == hostPlatform) "dev";
|
||||
|
||||
nativeBuildInputs = [ bison ];
|
||||
nativeBuildInputs = [ bison ]
|
||||
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
|
||||
buildInputs = [ zlib ];
|
||||
|
||||
inherit noSysDirs;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{ stdenv, lib, fetchurl, glibc, musl
|
||||
{ stdenv, lib, buildPackages, fetchurl
|
||||
, enableStatic ? false
|
||||
, enableMinimal ? false
|
||||
, useMusl ? false
|
||||
, useMusl ? false, musl
|
||||
, extraConfig ? ""
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -71,20 +72,16 @@ stdenv.mkDerivation rec {
|
|||
'';
|
||||
|
||||
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 ];
|
||||
|
||||
crossAttrs = {
|
||||
extraCrossConfig = ''
|
||||
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")
|
||||
'';
|
||||
};
|
||||
extraCrossConfig = if hostPlatform == buildPlatform then null else ''
|
||||
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
|
|
11
pkgs/os-specific/windows/mingw-w64/common.nix
Normal file
11
pkgs/os-specific/windows/mingw-w64/common.nix
Normal 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";
|
||||
};
|
||||
}
|
|
@ -1,36 +1,7 @@
|
|||
{ stdenv, fetchurl, binutils ? null, gccCross ? null
|
||||
, 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, callPackage, windows }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
inherit (callPackage ./common.nix {}) name src;
|
||||
buildInputs = [ windows.mingw_w64_headers ];
|
||||
dontStrip = true;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
13
pkgs/os-specific/windows/mingw-w64/headers.nix
Normal file
13
pkgs/os-specific/windows/mingw-w64/headers.nix
Normal 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
|
||||
'';
|
||||
}
|
13
pkgs/os-specific/windows/mingw-w64/pthreads.nix
Normal file
13
pkgs/os-specific/windows/mingw-w64/pthreads.nix
Normal 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
|
||||
'';
|
||||
}
|
|
@ -1,15 +1,16 @@
|
|||
{ stdenv, fetchurl, readline70 ? null, interactive ? false, texinfo ? null
|
||||
, binutils ? null, bison
|
||||
{ stdenv, buildPackages
|
||||
, fetchurl, readline70 ? null, texinfo ? null, binutils ? null, bison
|
||||
, buildPlatform, hostPlatform
|
||||
, interactive ? false
|
||||
}:
|
||||
|
||||
assert interactive -> readline70 != null;
|
||||
assert stdenv.isDarwin -> binutils != null;
|
||||
assert hostPlatform.isDarwin -> binutils != null;
|
||||
|
||||
let
|
||||
version = "4.4";
|
||||
realName = "bash-${version}";
|
||||
shortName = "bash44";
|
||||
baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline";
|
||||
sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq";
|
||||
|
||||
upstreamPatches =
|
||||
|
@ -22,7 +23,7 @@ let
|
|||
in
|
||||
import ./bash-4.4-patches.nix patch;
|
||||
|
||||
inherit (stdenv.lib) optional optionalString;
|
||||
inherit (stdenv.lib) optional optionals;
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
|
@ -52,26 +53,25 @@ stdenv.mkDerivation rec {
|
|||
patchFlags = "-p0";
|
||||
|
||||
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 = baseConfigureFlags +
|
||||
" bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" +
|
||||
optionalString stdenv.isCygwin ''
|
||||
--without-libintl-prefix --without-libiconv-prefix
|
||||
--with-installed-readline
|
||||
bash_cv_dev_stdin=present
|
||||
bash_cv_dev_fd=standard
|
||||
bash_cv_termcap_lib=libncurses
|
||||
'';
|
||||
};
|
||||
|
||||
configureFlags = baseConfigureFlags;
|
||||
configureFlags = [
|
||||
(if interactive then "--with-installed-readline" else "--disable-readline")
|
||||
] ++ optionals (hostPlatform != buildPlatform) [
|
||||
"bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes"
|
||||
] ++ optionals hostPlatform.isCygwin [
|
||||
"--without-libintl-prefix --without-libiconv-prefix"
|
||||
"--with-installed-readline"
|
||||
"bash_cv_dev_stdin=present"
|
||||
"bash_cv_dev_fd=standard"
|
||||
"bash_cv_termcap_lib=libncurses"
|
||||
];
|
||||
|
||||
# Note: Bison is needed because the patches above modify parse.y.
|
||||
nativeBuildInputs = [bison]
|
||||
++ optional (texinfo != null) texinfo
|
||||
++ optional stdenv.isDarwin binutils;
|
||||
++ optional hostPlatform.isDarwin binutils
|
||||
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
|
||||
|
||||
buildInputs = optional interactive readline70;
|
||||
|
||||
|
|
|
@ -56,16 +56,36 @@ rec {
|
|||
|
||||
# Return a modified stdenv that adds a cross compiler to the
|
||||
# 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
|
||||
# different platform.
|
||||
overrides = _: _: {};
|
||||
allowedRequisites = null;
|
||||
|
||||
# Overrides are surely not valid as packages built with this run on a
|
||||
# different platform.
|
||||
overrides = _: _: {};
|
||||
};
|
||||
in stdenv // {
|
||||
mkDerivation =
|
||||
{ name ? "", buildInputs ? [], nativeBuildInputs ? []
|
||||
, 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:
|
||||
|
||||
let
|
||||
|
@ -88,17 +108,25 @@ rec {
|
|||
nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull;
|
||||
in
|
||||
stdenv.mkDerivation (args // {
|
||||
name = name + "-" + cross.config;
|
||||
name = name + "-" + hostPlatform.config;
|
||||
nativeBuildInputs = nativeBuildInputs
|
||||
++ nativeInputsFromBuildInputs
|
||||
++ [ gccCross binutils ]
|
||||
++ stdenv.lib.optional selfNativeBuildInput nativeDrv
|
||||
# without proper `file` command, libtool sometimes fails
|
||||
# to recognize 64-bit DLLs
|
||||
++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file
|
||||
++ stdenv.lib.optional (cross.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook
|
||||
++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file
|
||||
++ 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
|
||||
# be propagated because ld needs the -rpath-link to find
|
||||
# any library needed to link the program dynamically at
|
||||
|
@ -107,12 +135,8 @@ rec {
|
|||
propagatedBuildInputs = propagatedBuildInputs ++ buildInputs;
|
||||
propagatedNativeBuildInputs = propagatedNativeBuildInputs;
|
||||
|
||||
crossConfig = cross.config;
|
||||
crossConfig = hostPlatform.config;
|
||||
} // args.crossAttrs or {});
|
||||
|
||||
inherit gccCross binutils;
|
||||
ccCross = gccCross;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -31,15 +31,15 @@ in bootStages ++ [
|
|||
targetPlatform = crossSystem;
|
||||
inherit config overlays;
|
||||
selfBuild = false;
|
||||
stdenv = if crossSystem.useiOSCross or false
|
||||
then let
|
||||
inherit (buildPackages.darwin.ios-cross) cc binutils;
|
||||
in buildPackages.makeStdenvCross
|
||||
buildPackages.stdenv crossSystem
|
||||
binutils cc
|
||||
else buildPackages.makeStdenvCross
|
||||
buildPackages.stdenv crossSystem
|
||||
buildPackages.binutils buildPackages.gccCrossStageFinal;
|
||||
stdenv = buildPackages.makeStdenvCross {
|
||||
inherit (buildPackages) stdenv;
|
||||
buildPlatform = localSystem;
|
||||
hostPlatform = crossSystem;
|
||||
targetPlatform = crossSystem;
|
||||
cc = if crossSystem.useiOSCross or false
|
||||
then buildPackages.darwin.ios-cross
|
||||
else buildPackages.gccCrossStageFinal;
|
||||
};
|
||||
})
|
||||
|
||||
]
|
||||
|
|
|
@ -73,6 +73,8 @@ in rec {
|
|||
nativeTools = true;
|
||||
nativePrefix = bootstrapTools;
|
||||
nativeLibc = false;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
libc = last.pkgs.darwin.Libsystem;
|
||||
isClang = true;
|
||||
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
|
||||
|
@ -295,6 +297,8 @@ in rec {
|
|||
inherit shell;
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit (pkgs) coreutils binutils gnugrep;
|
||||
inherit (pkgs.darwin) dyld;
|
||||
cc = pkgs.llvmPackages.clang-unwrapped;
|
||||
|
|
|
@ -77,6 +77,8 @@ let inherit (localSystem) system; in
|
|||
nativeTools = true;
|
||||
nativePrefix = "/usr";
|
||||
nativeLibc = true;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit (prevStage) stdenv;
|
||||
cc = {
|
||||
name = "clang-9.9.9";
|
||||
|
|
|
@ -76,6 +76,8 @@ let
|
|||
else lib.makeOverridable (import ../../build-support/cc-wrapper) {
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
isGNU = true;
|
||||
libc = prevStage.glibc;
|
||||
|
@ -239,6 +241,8 @@ in
|
|||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
isGNU = true;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
libc = self.glibc;
|
||||
inherit (self) stdenv binutils coreutils gnugrep;
|
||||
|
|
|
@ -81,7 +81,6 @@ rec {
|
|||
nativeBuildInputs = [
|
||||
pkgs.buildPackages.nukeReferences
|
||||
pkgs.buildPackages.cpio
|
||||
pkgs.buildPackages.binutils
|
||||
];
|
||||
|
||||
buildCommand = ''
|
||||
|
|
|
@ -125,6 +125,8 @@ in
|
|||
"i686-solaris" = "/usr/gnu";
|
||||
"x86_64-solaris" = "/opt/local/gcc47";
|
||||
}.${system} or "/usr";
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit stdenv;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ bootStages ++ [
|
|||
nativeTools = false;
|
||||
nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr";
|
||||
nativeLibc = true;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit stdenv;
|
||||
inherit (prevStage) binutils coreutils gnugrep;
|
||||
cc = prevStage.gcc.cc;
|
||||
|
|
12
pkgs/tools/archivers/unzip/cross-cc.patch
Normal file
12
pkgs/tools/archivers/unzip/cross-cc.patch
Normal 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
|
|
@ -1,5 +1,8 @@
|
|||
{ stdenv, fetchurl, bzip2
|
||||
, enableNLS ? false, libnatspec }:
|
||||
{ stdenv, fetchurl
|
||||
, bzip2
|
||||
, enableNLS ? false, libnatspec
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
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";
|
||||
name = "unzip-6.0-natspec.patch";
|
||||
sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
|
||||
});
|
||||
})
|
||||
++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch;
|
||||
|
||||
nativeBuildInputs = [ bzip2 ];
|
||||
buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec;
|
||||
|
||||
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";
|
||||
|
||||
|
|
|
@ -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
|
||||
, attrSupport ? false, attr ? null
|
||||
, selinuxSupport? false, libselinux ? null, libsepol ? null
|
||||
, autoconf, automake114x, texinfo
|
||||
, withPrefix ? 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
|
||||
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.
|
||||
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 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
|
||||
|
@ -39,58 +40,54 @@ stdenv.mkDerivation rec {
|
|||
configureFlags =
|
||||
optional (singleBinary != false)
|
||||
("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}")
|
||||
++ optional stdenv.isSunOS "ac_cv_func_inotify_init=no"
|
||||
++ optional withPrefix "--program-prefix=g";
|
||||
++ optional hostPlatform.isSunOS "ac_cv_func_inotify_init=no"
|
||||
++ 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 ]
|
||||
++ optional aclSupport acl
|
||||
++ optional attrSupport attr
|
||||
++ optionals stdenv.isCygwin [ autoconf automake114x texinfo ] # due to patch
|
||||
++ optionals selinuxSupport [ libselinux libsepol ];
|
||||
|
||||
crossAttrs = {
|
||||
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;
|
||||
};
|
||||
++ optionals hostPlatform.isCygwin [ autoconf automake114x texinfo ] # due to patch
|
||||
++ optionals selinuxSupport [ libselinux libsepol ]
|
||||
# TODO(@Ericson2314): Investigate whether Darwin could benefit too
|
||||
++ optional (hostPlatform != buildPlatform && hostPlatform.libc != "glibc") libiconv;
|
||||
|
||||
# The tests are known broken on Cygwin
|
||||
# (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
|
||||
# Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
|
||||
# and {Open,Free}BSD.
|
||||
# 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
|
||||
# man/sha512sum.td/sha512sum’.
|
||||
enableParallelBuilding = false;
|
||||
|
||||
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 = {
|
||||
homepage = http://www.gnu.org/software/coreutils/;
|
||||
|
@ -109,4 +106,5 @@ stdenv.mkDerivation rec {
|
|||
|
||||
maintainers = [ maintainers.eelco ];
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{ stdenv, fetchurl, coreutils }:
|
||||
{ stdenv, fetchurl
|
||||
, coreutils
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
let inherit (stdenv.lib) optionals; in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "findutils-4.6.0";
|
||||
|
@ -10,20 +15,18 @@ stdenv.mkDerivation rec {
|
|||
|
||||
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.
|
||||
doCheck = !stdenv.isDarwin && (stdenv.system != "i686-linux");
|
||||
doCheck
|
||||
= !hostPlatform.isDarwin
|
||||
&& !(hostPlatform.libc == "glibc" && hostPlatform.isi686)
|
||||
&& hostPlatform == buildPlatform;
|
||||
|
||||
outputs = [ "out" "info" ];
|
||||
|
||||
configureFlags = [ "--localstatedir=/var/cache" ];
|
||||
|
||||
crossAttrs = {
|
||||
# Fix the 'buildInputs = [ coreutils ]' above - that adds the cross coreutils to PATH :(
|
||||
propagatedBuildInputs = [ ];
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ stdenv, fetchgit, libusb, libusb1, autoconf, automake, confuse, pkgconfig
|
||||
, gccCross ? null }:
|
||||
, gccCross ? null, crossPrefix
|
||||
}:
|
||||
|
||||
let
|
||||
version = "2011-12-26";
|
||||
|
@ -18,7 +19,7 @@ stdenv.mkDerivation {
|
|||
'';
|
||||
|
||||
configureFlags = if gccCross != null then
|
||||
"--enable-firmware CROSS_COMPILE=${gccCross.crossConfig}-"
|
||||
"--enable-firmware CROSS_COMPILE=${crossPrefix}-"
|
||||
else "";
|
||||
|
||||
# Not to strip cross build binaries (this is for the gcc-cross-wrapper)
|
||||
|
|
|
@ -22,13 +22,6 @@ stdenv.mkDerivation rec {
|
|||
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 = [
|
||||
# Allow sessions to inherit the PATH from the parent dropbear.
|
||||
# Otherwise they only get the usual /bin:/usr/bin kind of PATH
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{ stdenv, fetchurl, lzip }:
|
||||
{ stdenv
|
||||
, fetchurl, lzip
|
||||
, hostPlatform, buildPlatform
|
||||
}:
|
||||
|
||||
let inherit (stdenv.lib) optionals; in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "ddrescue-1.22";
|
||||
|
@ -10,7 +15,12 @@ stdenv.mkDerivation rec {
|
|||
|
||||
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; {
|
||||
description = "GNU ddrescue, a data recovery tool";
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{ stdenv, fetchurl, ed }:
|
||||
{ stdenv, fetchurl
|
||||
, ed
|
||||
, buildPlatform, hostPlatform
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "patch-2.7.5";
|
||||
|
@ -10,11 +13,11 @@ stdenv.mkDerivation rec {
|
|||
|
||||
buildInputs = stdenv.lib.optional doCheck ed;
|
||||
|
||||
crossAttrs = {
|
||||
configureFlags = [ "ac_cv_func_strnlen_working=yes" ];
|
||||
};
|
||||
configureFlags = if hostPlatform == buildPlatform then null else [
|
||||
"ac_cv_func_strnlen_working=yes"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
doCheck = hostPlatform == buildPlatform;
|
||||
|
||||
meta = {
|
||||
description = "GNU Patch, a program to apply differences to files";
|
||||
|
|
|
@ -4816,15 +4816,16 @@ with pkgs;
|
|||
|
||||
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
|
||||
# load into the Ben Nanonote
|
||||
crossPrefix = "mipsel-unknown-linux";
|
||||
gccCross =
|
||||
let
|
||||
pkgsCross = nixpkgsFun {
|
||||
# Ben Nanonote system
|
||||
crossSystem = {
|
||||
config = "mipsel-unknown-linux";
|
||||
config = crossPrefix;
|
||||
bigEndian = true;
|
||||
arch = "mips";
|
||||
float = "soft";
|
||||
|
@ -4843,7 +4844,7 @@ with pkgs;
|
|||
};
|
||||
};
|
||||
in
|
||||
pkgsCross.gccCrossStageStatic;
|
||||
pkgsCross.buildPackages.gccCrossStageStatic;
|
||||
};
|
||||
|
||||
xclip = callPackage ../tools/misc/xclip { };
|
||||
|
@ -5163,13 +5164,21 @@ with pkgs;
|
|||
|
||||
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
|
||||
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 null;
|
||||
in wrapGCCCross {
|
||||
gcc = forcedNativePackages.gcc.cc.override {
|
||||
in wrapCCCross {
|
||||
cc = forcedNativePackages.gcc.cc.override {
|
||||
crossStageStatic = true;
|
||||
langCC = false;
|
||||
libcCross = libcCross1;
|
||||
|
@ -5179,19 +5188,17 @@ with pkgs;
|
|||
};
|
||||
libc = libcCross1;
|
||||
inherit (forcedNativePackages) binutils;
|
||||
cross = targetPlatform;
|
||||
};
|
||||
|
||||
# Only needed for mingw builds
|
||||
gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapGCCCross {
|
||||
gcc = gccCrossStageStatic.gcc;
|
||||
gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapCCCross {
|
||||
cc = gccCrossStageStatic.gcc;
|
||||
libc = windows.mingw_headers2;
|
||||
inherit (forcedNativePackages) binutils;
|
||||
cross = targetPlatform;
|
||||
};
|
||||
|
||||
gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapGCCCross {
|
||||
gcc = forcedNativePackages.gcc.cc.override {
|
||||
gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapCCCross {
|
||||
cc = forcedNativePackages.gcc.cc.override {
|
||||
crossStageStatic = false;
|
||||
|
||||
# Why is this needed?
|
||||
|
@ -5199,7 +5206,6 @@ with pkgs;
|
|||
};
|
||||
libc = libcCross;
|
||||
inherit (forcedNativePackages) binutils;
|
||||
cross = targetPlatform;
|
||||
};
|
||||
|
||||
gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 {
|
||||
|
@ -5924,14 +5930,19 @@ with pkgs;
|
|||
libc = glibc;
|
||||
};
|
||||
|
||||
wrapGCCCross =
|
||||
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
|
||||
wrapCCCross =
|
||||
{cc, libc, binutils, shell ? "", name ? "gcc-cross-wrapper"}:
|
||||
|
||||
forcedNativePackages.callPackage ../build-support/gcc-cross-wrapper {
|
||||
forcedNativePackages.ccWrapperFun {
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
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
|
||||
|
@ -7798,13 +7809,7 @@ with pkgs;
|
|||
# Being redundant to avoid cycles on boot. TODO: find a better way
|
||||
glibcCross = callPackage ../development/libraries/glibc {
|
||||
installLocales = config.glibc.locales or false;
|
||||
# Can't just overrideCC, because then the stdenv-cross mkDerivation will be
|
||||
# thrown away. TODO: find a better solution for this.
|
||||
stdenv = buildPackages.makeStdenvCross
|
||||
buildPackages.buildPackages.stdenv
|
||||
buildPackages.targetPlatform
|
||||
buildPackages.binutils
|
||||
buildPackages.gccCrossStageStatic;
|
||||
stdenv = crossLibcStdenv;
|
||||
};
|
||||
|
||||
# We can choose:
|
||||
|
@ -7813,7 +7818,7 @@ with pkgs;
|
|||
# hack fixes the hack, *sigh*.
|
||||
/**/ if name == "glibc" then __targetPackages.glibcCross or glibcCross
|
||||
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 throw "Unknown libc";
|
||||
|
||||
|
@ -12571,17 +12576,12 @@ with pkgs;
|
|||
};
|
||||
|
||||
mingw_w64 = callPackage ../os-specific/windows/mingw-w64 {
|
||||
gccCross = gccCrossStageStatic;
|
||||
binutils = binutils;
|
||||
stdenv = crossLibcStdenv;
|
||||
};
|
||||
|
||||
mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64 {
|
||||
onlyHeaders = true;
|
||||
};
|
||||
mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64/headers.nix { };
|
||||
|
||||
mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64 {
|
||||
onlyPthreads = true;
|
||||
};
|
||||
mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { };
|
||||
|
||||
pthreads = callPackage ../os-specific/windows/pthread-w32 {
|
||||
mingw_headers = mingw_headers3;
|
||||
|
|
Loading…
Reference in a new issue