cc-wrapper: Learn about target prefixes
This is first step towards getting rid of gcc-wrapper-cross
This commit is contained in:
parent
c4ba2e3ef6
commit
459f1c60f5
@ -10,7 +10,7 @@
|
|||||||
, 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
|
||||||
, targetPlatform
|
, hostPlatform, targetPlatform
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
@ -24,6 +24,12 @@ assert !nativeLibc -> libc != null;
|
|||||||
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;
|
||||||
@ -41,9 +47,9 @@ let
|
|||||||
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;
|
||||||
|
|
||||||
@ -52,7 +58,8 @@ 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;
|
||||||
|
|
||||||
emacsBufferSetup = pkgs: ''
|
emacsBufferSetup = pkgs: ''
|
||||||
; We should handle propagation here too
|
; We should handle propagation here too
|
||||||
@ -170,7 +177,7 @@ stdenv.mkDerivation {
|
|||||||
+ optionalString (targetPlatform.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 ${./ld-solaris-wrapper.sh}
|
||||||
'')
|
'')
|
||||||
|
|
||||||
@ -178,72 +185,72 @@ stdenv.mkDerivation {
|
|||||||
# 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 ${./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 ${./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 ${./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 ${./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 ${./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++ ${./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++ ${./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 ${./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 ${./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 ${./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 ${./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 ${./cc-wrapper.sh} $ccPath/${prefix}gnatgcc
|
||||||
wrap gnatmake ${./gnat-wrapper.sh} $ccPath/gnatmake
|
wrap ${prefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${prefix}gnatmake
|
||||||
wrap gnatbind ${./gnat-wrapper.sh} $ccPath/gnatbind
|
wrap ${prefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${prefix}gnatbind
|
||||||
wrap gnatlink ${./gnatlink-wrapper.sh} $ccPath/gnatlink
|
wrap ${prefix}gnatlink ${./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
|
||||||
''
|
''
|
||||||
|
|
||||||
+ ''
|
+ ''
|
||||||
@ -253,10 +260,10 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ in rec {
|
|||||||
nativeTools = true;
|
nativeTools = true;
|
||||||
nativePrefix = bootstrapTools;
|
nativePrefix = bootstrapTools;
|
||||||
nativeLibc = false;
|
nativeLibc = false;
|
||||||
|
hostPlatform = localSystem;
|
||||||
targetPlatform = localSystem;
|
targetPlatform = localSystem;
|
||||||
libc = last.pkgs.darwin.Libsystem;
|
libc = last.pkgs.darwin.Libsystem;
|
||||||
isClang = true;
|
isClang = true;
|
||||||
@ -296,6 +297,7 @@ in rec {
|
|||||||
inherit shell;
|
inherit shell;
|
||||||
nativeTools = false;
|
nativeTools = false;
|
||||||
nativeLibc = false;
|
nativeLibc = false;
|
||||||
|
hostPlatform = localSystem;
|
||||||
targetPlatform = localSystem;
|
targetPlatform = localSystem;
|
||||||
inherit (pkgs) coreutils binutils gnugrep;
|
inherit (pkgs) coreutils binutils gnugrep;
|
||||||
inherit (pkgs.darwin) dyld;
|
inherit (pkgs.darwin) dyld;
|
||||||
|
@ -77,6 +77,7 @@ let inherit (localSystem) system; in
|
|||||||
nativeTools = true;
|
nativeTools = true;
|
||||||
nativePrefix = "/usr";
|
nativePrefix = "/usr";
|
||||||
nativeLibc = true;
|
nativeLibc = true;
|
||||||
|
hostPlatform = localSystem;
|
||||||
targetPlatform = localSystem;
|
targetPlatform = localSystem;
|
||||||
inherit (prevStage) stdenv;
|
inherit (prevStage) stdenv;
|
||||||
cc = {
|
cc = {
|
||||||
|
@ -76,6 +76,7 @@ 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;
|
targetPlatform = localSystem;
|
||||||
cc = prevStage.gcc-unwrapped;
|
cc = prevStage.gcc-unwrapped;
|
||||||
isGNU = true;
|
isGNU = true;
|
||||||
@ -240,6 +241,7 @@ in
|
|||||||
nativeTools = false;
|
nativeTools = false;
|
||||||
nativeLibc = false;
|
nativeLibc = false;
|
||||||
isGNU = true;
|
isGNU = true;
|
||||||
|
hostPlatform = localSystem;
|
||||||
targetPlatform = localSystem;
|
targetPlatform = localSystem;
|
||||||
cc = prevStage.gcc-unwrapped;
|
cc = prevStage.gcc-unwrapped;
|
||||||
libc = self.glibc;
|
libc = self.glibc;
|
||||||
|
@ -125,6 +125,7 @@ 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;
|
targetPlatform = localSystem;
|
||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ 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;
|
targetPlatform = localSystem;
|
||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
inherit (prevStage) binutils coreutils gnugrep;
|
inherit (prevStage) binutils coreutils gnugrep;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user