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 ? ""
|
||||
, dyld ? null # TODO: should this be a setup-hook on dyld?
|
||||
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
|
||||
, targetPlatform
|
||||
, hostPlatform, targetPlatform
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
@ -24,6 +24,12 @@ assert !nativeLibc -> libc != null;
|
||||
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;
|
||||
@ -41,9 +47,9 @@ let
|
||||
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;
|
||||
|
||||
@ -52,7 +58,8 @@ 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;
|
||||
|
||||
emacsBufferSetup = pkgs: ''
|
||||
; We should handle propagation here too
|
||||
@ -170,7 +177,7 @@ stdenv.mkDerivation {
|
||||
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
|
||||
# Solaris needs an additional ld wrapper.
|
||||
ldPath="${nativePrefix}/bin"
|
||||
exec="$ldPath/ld"
|
||||
exec="$ldPath/${prefix}ld"
|
||||
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
|
||||
# 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 ${./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 ${./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 ${./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 ${./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 ${./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++ ${./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++ ${./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 ${./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 ${./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 ${./cc-wrapper.sh} $ccPath/${prefix}gcj
|
||||
''
|
||||
|
||||
+ 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 ''
|
||||
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 ${./cc-wrapper.sh} $ccPath/${prefix}gnatgcc
|
||||
wrap ${prefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${prefix}gnatmake
|
||||
wrap ${prefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${prefix}gnatbind
|
||||
wrap ${prefix}gnatlink ${./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
|
||||
''
|
||||
|
||||
+ ''
|
||||
@ -253,10 +260,10 @@ stdenv.mkDerivation {
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -73,6 +73,7 @@ in rec {
|
||||
nativeTools = true;
|
||||
nativePrefix = bootstrapTools;
|
||||
nativeLibc = false;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
libc = last.pkgs.darwin.Libsystem;
|
||||
isClang = true;
|
||||
@ -296,6 +297,7 @@ in rec {
|
||||
inherit shell;
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit (pkgs) coreutils binutils gnugrep;
|
||||
inherit (pkgs.darwin) dyld;
|
||||
|
@ -77,6 +77,7 @@ let inherit (localSystem) system; in
|
||||
nativeTools = true;
|
||||
nativePrefix = "/usr";
|
||||
nativeLibc = true;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit (prevStage) stdenv;
|
||||
cc = {
|
||||
|
@ -76,6 +76,7 @@ let
|
||||
else lib.makeOverridable (import ../../build-support/cc-wrapper) {
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
isGNU = true;
|
||||
@ -240,6 +241,7 @@ in
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
isGNU = true;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
libc = self.glibc;
|
||||
|
@ -125,6 +125,7 @@ in
|
||||
"i686-solaris" = "/usr/gnu";
|
||||
"x86_64-solaris" = "/opt/local/gcc47";
|
||||
}.${system} or "/usr";
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit stdenv;
|
||||
};
|
||||
|
@ -30,6 +30,7 @@ bootStages ++ [
|
||||
nativeTools = false;
|
||||
nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr";
|
||||
nativeLibc = true;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit stdenv;
|
||||
inherit (prevStage) binutils coreutils gnugrep;
|
||||
|
Loading…
Reference in New Issue
Block a user