Merge pull request #32098 from obsidiansystems/binPrefix

treewide: Use `targetPrefix` instead of `prefix` for platform name prefixes
This commit is contained in:
John Ericson 2017-11-27 03:20:53 -05:00 committed by GitHub
commit 1c44d5efc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 85 additions and 87 deletions

View File

@ -29,8 +29,8 @@ stdenv.mkDerivation rec {
installFlags = [ "DESTDIR=$(out)" ];
configureFlags = [
"--exec-prefix=${stdenv.cc.prefix}"
"CC=${stdenv.cc.prefix}cc"
"--exec-prefix=${stdenv.cc.targetPrefix}"
"CC=${stdenv.cc.targetPrefix}cc"
];
meta = {

View File

@ -49,7 +49,7 @@ let
crossAttrs = {
configurePlatforms = [];
configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cc.prefix}"
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"
"--target_os=linux"
"--arch=${hostPlatform.arch}"

View File

@ -32,8 +32,8 @@ let
#
# TODO(@Ericson2314) Make unconditional, or optional but always true by
# default.
prefix = stdenv.lib.optionalString (targetPlatform != hostPlatform)
(targetPlatform.config + "-");
targetPrefix = stdenv.lib.optionalString (targetPlatform != hostPlatform)
(targetPlatform.config + "-");
ccVersion = (builtins.parseDrvName cc.name).version;
ccName = (builtins.parseDrvName cc.name).name;
@ -81,7 +81,7 @@ let
in
stdenv.mkDerivation {
name = prefix
name = targetPrefix
+ (if name != "" then name else "${ccName}-wrapper")
+ (stdenv.lib.optionalString (cc != null && ccVersion != "") "-${ccVersion}");
@ -91,8 +91,7 @@ stdenv.mkDerivation {
shell = getBin shell + shell.shellPath or "";
gnugrep_bin = if nativeTools then "" else gnugrep;
binPrefix = prefix;
inherit infixSalt;
inherit targetPrefix infixSalt;
outputs = [ "out" "man" ];
@ -102,8 +101,7 @@ stdenv.mkDerivation {
# Binutils, and Apple's "cctools"; "binutils" as an attempt to find an
# unused middle-ground name that evokes both.
bintools = binutils_bin;
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile
prefix;
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile;
emacsBufferSetup = pkgs: ''
; We should handle propagation here too
@ -154,7 +152,7 @@ stdenv.mkDerivation {
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
# Solaris needs an additional ld wrapper.
ldPath="${nativePrefix}/bin"
exec="$ldPath/${prefix}ld"
exec="$ldPath/${targetPrefix}ld"
wrap ld-solaris ${./ld-solaris-wrapper.sh}
'')
@ -162,83 +160,83 @@ 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/${prefix}as ]; then
ln -s $ldPath/${prefix}as $out/bin/${prefix}as
if [ -e $ldPath/${targetPrefix}as ]; then
ln -s $ldPath/${targetPrefix}as $out/bin/${targetPrefix}as
fi
'' + (if !useMacosReexportHack then ''
wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
wrap ${targetPrefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${targetPrefix}ld}
'' else ''
ldInner="${prefix}ld-reexport-delegate"
wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${prefix}ld}
wrap "${prefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner"
ldInner="${targetPrefix}ld-reexport-delegate"
wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${targetPrefix}ld}
wrap "${targetPrefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner"
unset ldInner
'') + ''
if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
wrap ${prefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
if [ -e ${binutils_bin}/bin/${targetPrefix}ld.gold ]; then
wrap ${targetPrefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${targetPrefix}ld.gold
fi
if [ -e ${binutils_bin}/bin/ld.bfd ]; then
wrap ${prefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
wrap ${targetPrefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${targetPrefix}ld.bfd
fi
# We export environment variables pointing to the wrapped nonstandard
# cmds, lest some lousy configure script use those to guess compiler
# version.
export named_cc=${prefix}cc
export named_cxx=${prefix}c++
export named_cc=${targetPrefix}cc
export named_cxx=${targetPrefix}c++
export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
if [ -e $ccPath/${prefix}gcc ]; then
wrap ${prefix}gcc ${./cc-wrapper.sh} $ccPath/${prefix}gcc
ln -s ${prefix}gcc $out/bin/${prefix}cc
export named_cc=${prefix}gcc
export named_cxx=${prefix}g++
if [ -e $ccPath/${targetPrefix}gcc ]; then
wrap ${targetPrefix}gcc ${./cc-wrapper.sh} $ccPath/${targetPrefix}gcc
ln -s ${targetPrefix}gcc $out/bin/${targetPrefix}cc
export named_cc=${targetPrefix}gcc
export named_cxx=${targetPrefix}g++
elif [ -e $ccPath/clang ]; then
wrap ${prefix}clang ${./cc-wrapper.sh} $ccPath/clang
ln -s ${prefix}clang $out/bin/${prefix}cc
export named_cc=${prefix}clang
export named_cxx=${prefix}clang++
wrap ${targetPrefix}clang ${./cc-wrapper.sh} $ccPath/clang
ln -s ${targetPrefix}clang $out/bin/${targetPrefix}cc
export named_cc=${targetPrefix}clang
export named_cxx=${targetPrefix}clang++
fi
if [ -e $ccPath/${prefix}g++ ]; then
wrap ${prefix}g++ ${./cc-wrapper.sh} $ccPath/${prefix}g++
ln -s ${prefix}g++ $out/bin/${prefix}c++
if [ -e $ccPath/${targetPrefix}g++ ]; then
wrap ${targetPrefix}g++ ${./cc-wrapper.sh} $ccPath/${targetPrefix}g++
ln -s ${targetPrefix}g++ $out/bin/${targetPrefix}c++
elif [ -e $ccPath/clang++ ]; then
wrap ${prefix}clang++ ${./cc-wrapper.sh} $ccPath/clang++
ln -s ${prefix}clang++ $out/bin/${prefix}c++
wrap ${targetPrefix}clang++ ${./cc-wrapper.sh} $ccPath/clang++
ln -s ${targetPrefix}clang++ $out/bin/${targetPrefix}c++
fi
if [ -e $ccPath/cpp ]; then
wrap ${prefix}cpp ${./cc-wrapper.sh} $ccPath/cpp
wrap ${targetPrefix}cpp ${./cc-wrapper.sh} $ccPath/cpp
fi
''
+ optionalString cc.langFortran or false ''
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
wrap ${targetPrefix}gfortran ${./cc-wrapper.sh} $ccPath/${targetPrefix}gfortran
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}f77
''
+ optionalString cc.langJava or false ''
wrap ${prefix}gcj ${./cc-wrapper.sh} $ccPath/${prefix}gcj
wrap ${targetPrefix}gcj ${./cc-wrapper.sh} $ccPath/${targetPrefix}gcj
''
+ optionalString cc.langGo or false ''
wrap ${prefix}gccgo ${./cc-wrapper.sh} $ccPath/${prefix}gccgo
wrap ${targetPrefix}gccgo ${./cc-wrapper.sh} $ccPath/${targetPrefix}gccgo
''
+ optionalString cc.langAda or false ''
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
wrap ${targetPrefix}gnatgcc ${./cc-wrapper.sh} $ccPath/${targetPrefix}gnatgcc
wrap ${targetPrefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatmake
wrap ${targetPrefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatbind
wrap ${targetPrefix}gnatlink ${./gnatlink-wrapper.sh} $ccPath/${targetPrefix}gnatlink
''
+ optionalString cc.langVhdl or false ''
ln -s $ccPath/${prefix}ghdl $out/bin/${prefix}ghdl
ln -s $ccPath/${targetPrefix}ghdl $out/bin/${targetPrefix}ghdl
'';
propagatedBuildInputs = extraPackages;
@ -362,10 +360,10 @@ stdenv.mkDerivation {
# some linkers on some platforms don't support specific -z flags
export hardening_unsupported_flags=""
if [[ "$($ldPath/${prefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
if [[ "$($ldPath/${targetPrefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
hardening_unsupported_flags+=" bindnow"
fi
if [[ "$($ldPath/${prefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
if [[ "$($ldPath/${targetPrefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
hardening_unsupported_flags+=" relro"
fi
''

View File

@ -117,7 +117,7 @@ let
-exec sed '1i#line 1 "{}"' -i '{}' \;
)
'' + optionalString (hostPlatform.libc == "msvcrt") ''
${stdenv.cc.prefix}ranlib "$out/lib/"*.a
${stdenv.cc.targetPrefix}ranlib "$out/lib/"*.a
'';
in

View File

@ -438,7 +438,7 @@ stdenv.mkDerivation rec {
crossAttrs = {
configurePlatforms = [];
configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cc.prefix}"
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"
"--target_os=${hostPlatform.parsed.kernel.name}"
"--arch=${hostPlatform.arch}"

View File

@ -173,7 +173,7 @@ stdenv.mkDerivation rec {
crossAttrs = {
configurePlatforms = [];
configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cc.prefix}"
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"
"--target_os=${hostPlatform.parsed.kernel}"
"--arch=${hostPlatform.arch}"

View File

@ -110,7 +110,7 @@ let
crossAttrs = {
configurePlatforms = [];
configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cc.prefix}"
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"
"--target_os=linux"
"--arch=${hostPlatform.arch}"

View File

@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
'';
crossAttrs = {
makeFlags = "CROSS_COMPILE=${stdenv.cc.prefix}";
makeFlags = "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
};
meta = with stdenv.lib; {

View File

@ -229,11 +229,11 @@ stdenv.mkDerivation rec {
'' + optionalString hostPlatform.isMinGW " -xplatform win32-g++-4.6";
patches = [];
preConfigure = ''
sed -i -e 's/ g++/ ${stdenv.cc.prefix}g++/' \
-e 's/ gcc/ ${stdenv.cc.prefix}gcc/' \
-e 's/ ar/ ${stdenv.cc.prefix}ar/' \
-e 's/ strip/ ${stdenv.cc.prefix}strip/' \
-e 's/ windres/ ${stdenv.cc.prefix}windres/' \
sed -i -e 's/ g++/ ${stdenv.cc.targetPrefix}g++/' \
-e 's/ gcc/ ${stdenv.cc.targetPrefix}gcc/' \
-e 's/ ar/ ${stdenv.cc.targetPrefix}ar/' \
-e 's/ strip/ ${stdenv.cc.targetPrefix}strip/' \
-e 's/ windres/ ${stdenv.cc.targetPrefix}windres/' \
mkspecs/win32-g++/qmake.conf
'';

View File

@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
];
makeFlags = [
"PREFIX=${stdenv.cc.prefix}"
"PREFIX=${stdenv.cc.targetPrefix}"
] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
"-f" "win32/Makefile.gcc"
] ++ stdenv.lib.optionals (!static) [

View File

@ -11,13 +11,13 @@ let
version = "2.28.1";
basename = "binutils-${version}";
inherit (stdenv.lib) optional optionals optionalString;
# The prefix prepended to binary names to allow multiple binuntils on the
# The targetPrefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
prefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
targetPrefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
in
stdenv.mkDerivation rec {
name = prefix + basename;
name = targetPrefix + basename;
src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2";
@ -81,7 +81,7 @@ stdenv.mkDerivation rec {
then "-Wno-string-plus-int -Wno-deprecated-declarations"
else "-static-libgcc";
# TODO(@Ericson2314): Always pass "--target" and always prefix.
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
@ -102,7 +102,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
passthru = {
inherit prefix version;
inherit targetPrefix version;
};
meta = with stdenv.lib; {

View File

@ -63,7 +63,7 @@ let
crossAttrs = {
makeFlags = [
"ARCH=${hostPlatform.platform.kernelArch}"
"CROSS_COMPILE=${stdenv.cc.prefix}"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
};

View File

@ -3,24 +3,24 @@
}:
# Make sure both underlying packages claim to have prepended their binaries
# with the same prefix.
assert binutils-raw.prefix == cctools.prefix;
# with the same targetPrefix.
assert binutils-raw.targetPrefix == cctools.targetPrefix;
let
inherit (binutils-raw) prefix;
inherit (binutils-raw) targetPrefix;
cmds = [
"ar" "ranlib" "as" "dsymutil" "install_name_tool"
"ld" "strip" "otool" "lipo" "nm" "strings" "size"
];
in
# TODO loop over prefixed binaries too
# TODO loop over targetPrefixed binaries too
stdenv.mkDerivation {
name = "${prefix}cctools-binutils-darwin";
name = "${targetPrefix}cctools-binutils-darwin";
buildCommand = ''
mkdir -p $out/bin $out/include
ln -s ${binutils-raw.out}/bin/${prefix}c++filt $out/bin/${prefix}c++filt
ln -s ${binutils-raw.out}/bin/${targetPrefix}c++filt $out/bin/${targetPrefix}c++filt
# We specifically need:
# - ld: binutils doesn't provide it on darwin
@ -33,7 +33,7 @@ stdenv.mkDerivation {
# - strip: the binutils one seems to break mach-o files
# - lipo: gcc build assumes it exists
# - nm: the gnu one doesn't understand many new load commands
for i in ${stdenv.lib.concatStringsSep " " (builtins.map (e: prefix + e) cmds)}; do
for i in ${stdenv.lib.concatStringsSep " " (builtins.map (e: targetPrefix + e) cmds)}; do
ln -sf "${cctools}/bin/$i" "$out/bin/$i"
done
@ -44,6 +44,6 @@ stdenv.mkDerivation {
'';
passthru = {
inherit prefix;
inherit targetPrefix;
};
}

View File

@ -5,9 +5,9 @@
}:
let
# The prefix prepended to binary names to allow multiple binuntils on the
# The targetPrefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
prefix = stdenv.lib.optionalString
targetPrefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
in
@ -19,7 +19,7 @@ assert (!hostPlatform.isDarwin) -> (maloader != null && xctoolchain != null);
let
baseParams = rec {
name = "${prefix}cctools-port-${version}";
name = "${targetPrefix}cctools-port-${version}";
version = "895";
src = fetchFromGitHub {
@ -49,7 +49,7 @@ let
enableParallelBuilding = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = stdenv.lib.optionals (!stdenv.isDarwin) [
"CXXFLAGS=-I${libcxx}/include/c++/v1"
@ -113,7 +113,7 @@ let
'';
passthru = {
inherit prefix;
inherit targetPrefix;
};
meta = {

View File

@ -78,7 +78,7 @@ stdenv.mkDerivation rec {
CONFIG_DEFAULT_SETFONT_DIR "/etc/kbd"
${extraConfig}
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}"
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.targetPrefix}"
EOF
make oldconfig
@ -87,7 +87,7 @@ stdenv.mkDerivation rec {
'';
postConfigure = lib.optionalString useMusl ''
makeFlagsArray+=("CC=${stdenv.cc.prefix}gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib")
makeFlagsArray+=("CC=${stdenv.cc.targetPrefix}gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib")
'';
nativeBuildInputs = lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;

View File

@ -51,7 +51,7 @@ stdenv.mkDerivation {
/* I don't want cross-python or cross-perl -
I don't know if cross-python even works */
propagatedBuildInputs = [ elfutils.crossDrv newt.crossDrv ];
makeFlags = "CROSS_COMPILE=${stdenv.cc.prefix}";
makeFlags = "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
elfutils = elfutils.crossDrv;
inherit (kernel.crossDrv) src patches;
};

View File

@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
] # TODO(@Ericson2314): We now can get the ABI from
# `hostPlatform.parsed.abi`, is this still a good idea?
++ stdenv.lib.optional (hostPlatform.platform.kernelArch == "arm") "CONFIG_AEABI=y"
++ stdenv.lib.optional (hostPlatform != buildPlatform) "CROSS_COMPILE=${stdenv.cc.prefix}";
++ stdenv.lib.optional (hostPlatform != buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
# Install static binaries as well.
postInstall = ''

View File

@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
"MANDIR=$(out)/share/man" "RUN_DIR=/dev/.mdadm"
"STRIP="
] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.prefix}"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
nativeBuildInputs = [ groff ];

View File

@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
"MANDIR=$(out)/share/man" "RUN_DIR=/dev/.mdadm"
"STRIP="
] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.prefix}"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
nativeBuildInputs = [ groff ];

View File

@ -18,7 +18,7 @@ stdenv.mkDerivation {
QTDIR = qt48;
crossAttrs = {
# cmakeFlags = "-DWIN32=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=${stdenv.cc.prefix}windres";
# cmakeFlags = "-DWIN32=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=${stdenv.cc.targetPrefix}windres";
QTDIR = qt48.crossDrv;
preBuild = ''
export NIX_CROSS_CFLAGS_COMPILE=-fpermissive

View File

@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
makeFlags = [
"INSTALL=install"
"STRIP=${stdenv.cc.bintools.prefix}strip"
"STRIP=${stdenv.cc.bintools.targetPrefix}strip"
"prefix=$(out)"
];