Merge #92089: {cc,bintools}-wrapper: Some fixes
This commit is contained in:
commit
9dcb508f2d
@ -132,15 +132,15 @@ stdenv.mkDerivation {
|
||||
ldPath="${bintools_bin}/bin"
|
||||
''
|
||||
|
||||
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
|
||||
# Solaris needs an additional ld wrapper.
|
||||
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
|
||||
ldPath="${nativePrefix}/bin"
|
||||
exec="$ldPath/${targetPrefix}ld"
|
||||
wrap ld-solaris ${./ld-solaris-wrapper.sh}
|
||||
'')
|
||||
|
||||
+ ''
|
||||
# Create a symlink to as (the assembler).
|
||||
+ ''
|
||||
if [ -e $ldPath/${targetPrefix}as ]; then
|
||||
ln -s $ldPath/${targetPrefix}as $out/bin/${targetPrefix}as
|
||||
fi
|
||||
@ -200,26 +200,29 @@ stdenv.mkDerivation {
|
||||
];
|
||||
|
||||
postFixup =
|
||||
optionalString (libc != null) (''
|
||||
##
|
||||
## General libc support
|
||||
##
|
||||
|
||||
echo "-L${libc_lib}${libc.libdir or "/lib"}" > $out/nix-support/libc-ldflags
|
||||
optionalString (libc != null) (''
|
||||
touch "$out/nix-support/libc-ldflags"
|
||||
echo "-L${libc_lib}${libc.libdir or "/lib"}" >> $out/nix-support/libc-ldflags
|
||||
|
||||
echo "${libc_lib}" > $out/nix-support/orig-libc
|
||||
echo "${libc_dev}" > $out/nix-support/orig-libc-dev
|
||||
''
|
||||
|
||||
##
|
||||
## Dynamic linker support
|
||||
##
|
||||
|
||||
+ ''
|
||||
if [[ -z ''${dynamicLinker+x} ]]; then
|
||||
echo "Don't know the name of the dynamic linker for platform '${targetPlatform.config}', so guessing instead." >&2
|
||||
local dynamicLinker="${libc_lib}/lib/ld*.so.?"
|
||||
fi
|
||||
''
|
||||
|
||||
# Expand globs to fill array of options
|
||||
+ ''
|
||||
dynamicLinker=($dynamicLinker)
|
||||
|
||||
case ''${#dynamicLinker[@]} in
|
||||
@ -228,7 +231,7 @@ stdenv.mkDerivation {
|
||||
*) echo "Multiple dynamic linkers found for platform '${targetPlatform.config}'." >&2;;
|
||||
esac
|
||||
|
||||
if [ -n "''${dynamicLinker:-}" ]; then
|
||||
if [ -n "''${dynamicLinker-}" ]; then
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
'' + (if targetPlatform.isDarwin then ''
|
||||
@ -237,23 +240,21 @@ stdenv.mkDerivation {
|
||||
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
|
||||
|
||||
local ldflagsBefore=(-dynamic-linker "$dynamicLinker")
|
||||
'') + ''
|
||||
fi
|
||||
|
||||
''
|
||||
# The dynamic linker is passed in `ldflagsBefore' to allow
|
||||
# explicit overrides of the dynamic linker by callers to ld
|
||||
# (the *last* value counts, so ours should come first).
|
||||
printWords "''${ldflagsBefore[@]}" > $out/nix-support/libc-ldflags-before
|
||||
+ ''
|
||||
echo -dynamic-linker "$dynamicLinker" >> $out/nix-support/libc-ldflags-before
|
||||
'') + ''
|
||||
fi
|
||||
'')
|
||||
|
||||
+ optionalString stdenv.targetPlatform.isMacOS ''
|
||||
# Ensure consistent LC_VERSION_MIN_MACOSX and remove LC_UUID.
|
||||
+ optionalString stdenv.targetPlatform.isMacOS ''
|
||||
echo "-macosx_version_min 10.12 -sdk_version 10.12 -no_uuid" >> $out/nix-support/libc-ldflags-before
|
||||
''
|
||||
|
||||
+ optionalString (!nativeTools) ''
|
||||
##
|
||||
## User env support
|
||||
##
|
||||
@ -261,25 +262,25 @@ stdenv.mkDerivation {
|
||||
# Propagate the underling unwrapped bintools so that if you
|
||||
# install the wrapper, you get tools like objdump (same for any
|
||||
# binaries of libc).
|
||||
+ optionalString (!nativeTools) ''
|
||||
printWords ${bintools_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
|
||||
''
|
||||
|
||||
+ optionalString propagateDoc (''
|
||||
##
|
||||
## Man page and info support
|
||||
##
|
||||
|
||||
+ optionalString propagateDoc (''
|
||||
ln -s ${bintools.man} $man
|
||||
'' + optionalString (bintools ? info) ''
|
||||
ln -s ${bintools.info} $info
|
||||
'')
|
||||
|
||||
+ ''
|
||||
##
|
||||
## Hardening support
|
||||
##
|
||||
|
||||
# some linkers on some platforms don't support specific -z flags
|
||||
+ ''
|
||||
export hardening_unsupported_flags=""
|
||||
if [[ "$($ldPath/${targetPrefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
|
||||
hardening_unsupported_flags+=" bindnow"
|
||||
@ -304,15 +305,18 @@ stdenv.mkDerivation {
|
||||
''
|
||||
|
||||
+ ''
|
||||
for flags in "$out/nix-support"/*flags*; do
|
||||
substituteInPlace "$flags" --replace $'\n' ' '
|
||||
done
|
||||
|
||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
||||
''
|
||||
|
||||
##
|
||||
## Extra custom steps
|
||||
##
|
||||
''
|
||||
|
||||
+ extraBuildCommands;
|
||||
|
||||
inherit dynamicLinker expand-response-params;
|
||||
|
@ -154,16 +154,18 @@ stdenv.mkDerivation {
|
||||
ccPath="${cc}/bin"
|
||||
'')
|
||||
|
||||
+ ''
|
||||
# Create symlinks to everything in the bintools wrapper.
|
||||
+ ''
|
||||
for bbin in $bintools/bin/*; do
|
||||
mkdir -p "$out/bin"
|
||||
ln -s "$bbin" "$out/bin/$(basename $bbin)"
|
||||
done
|
||||
''
|
||||
|
||||
# We export environment variables pointing to the wrapped nonstandard
|
||||
# cmds, lest some lousy configure script use those to guess compiler
|
||||
# version.
|
||||
+ ''
|
||||
export named_cc=${targetPrefix}cc
|
||||
export named_cxx=${targetPrefix}c++
|
||||
|
||||
@ -228,12 +230,19 @@ stdenv.mkDerivation {
|
||||
];
|
||||
|
||||
postFixup =
|
||||
# Ensure flags files exists, as some other programs cat them. (That these
|
||||
# are considered an exposed interface is a bit dubious, but fine for now.)
|
||||
''
|
||||
touch "$out/nix-support/cc-cflags"
|
||||
touch "$out/nix-support/cc-ldflags"
|
||||
''
|
||||
|
||||
# Backwards compatability for packages expecting this file, e.g. with
|
||||
# `$NIX_CC/nix-support/dynamic-linker`.
|
||||
#
|
||||
# TODO(@Ericson2314): Remove this after stable release and force
|
||||
# everyone to refer to bintools-wrapper directly.
|
||||
+ ''
|
||||
if [[ -f "$bintools/nix-support/dynamic-linker" ]]; then
|
||||
ln -s "$bintools/nix-support/dynamic-linker" "$out/nix-support"
|
||||
fi
|
||||
@ -242,25 +251,24 @@ stdenv.mkDerivation {
|
||||
fi
|
||||
''
|
||||
|
||||
+ optionalString isClang ''
|
||||
##
|
||||
## General Clang support
|
||||
##
|
||||
+ optionalString isClang ''
|
||||
|
||||
echo "-target ${targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
|
||||
+ optionalString (isClang && libcxx == null && cc ? gcc) ''
|
||||
##
|
||||
## GCC libs for non-GCC support
|
||||
##
|
||||
+ optionalString (isClang && libcxx == null && cc ? gcc) ''
|
||||
|
||||
echo "-B${cc.gcc}/lib/gcc/${targetPlatform.config}/${cc.gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${cc.gcc}/lib/gcc/${targetPlatform.config}/${cc.gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${cc.gcc.lib}/${targetPlatform.config}/lib" >> $out/nix-support/cc-ldflags
|
||||
''
|
||||
|
||||
+ optionalString (libc != null) (''
|
||||
##
|
||||
## General libc support
|
||||
##
|
||||
@ -276,6 +284,9 @@ stdenv.mkDerivation {
|
||||
# compile, because it uses "#include_next <limits.h>" to find the
|
||||
# limits.h file in ../includes-fixed. To remedy the problem,
|
||||
# another -idirafter is necessary to add that directory again.
|
||||
+ optionalString (libc != null) (''
|
||||
touch "$out/nix-support/libc-cflags"
|
||||
touch "$out/nix-support/libc-ldflags"
|
||||
echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-cflags
|
||||
'' + optionalString (!(cc.langD or false)) ''
|
||||
echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags
|
||||
@ -289,13 +300,16 @@ stdenv.mkDerivation {
|
||||
echo "${libc_dev}" > $out/nix-support/orig-libc-dev
|
||||
'')
|
||||
|
||||
+ ''
|
||||
##
|
||||
## General libc++ support
|
||||
##
|
||||
|
||||
''
|
||||
+ optionalString (libcxx == null && cc ? gcc) ''
|
||||
# We have a libc++ directly, we have one via "smuggled" GCC, or we have one
|
||||
# bundled with the C compiler because it is GCC
|
||||
+ optionalString (libcxx != null || cc.gcc.langCC or false || (isGNU && cc.langCC or false)) ''
|
||||
touch "$out/nix-support/libcxx-cxxflags"
|
||||
touch "$out/nix-support/libcxx-ldflags"
|
||||
'' + optionalString (libcxx == null && cc ? gcc) ''
|
||||
for dir in ${cc.gcc}/include/c++/*; do
|
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||
done
|
||||
@ -310,7 +324,6 @@ stdenv.mkDerivation {
|
||||
echo "-lc++abi" >> $out/nix-support/libcxx-ldflags
|
||||
'')
|
||||
|
||||
+ optionalString (!nativeTools) ''
|
||||
##
|
||||
## Initial CFLAGS
|
||||
##
|
||||
@ -319,6 +332,7 @@ stdenv.mkDerivation {
|
||||
# ${cc_solib}/lib64 (even though it does actually search there...)..
|
||||
# This confuses libtool. So add it to the compiler tool search
|
||||
# path explicitly.
|
||||
+ optionalString (!nativeTools) ''
|
||||
if [ -e "${cc_solib}/lib64" -a ! -L "${cc_solib}/lib64" ]; then
|
||||
ccLDFlags+=" -L${cc_solib}/lib64"
|
||||
ccCFlags+=" -B${cc_solib}/lib64"
|
||||
@ -327,32 +341,34 @@ stdenv.mkDerivation {
|
||||
ccCFlags+=" -B${cc_solib}/lib"
|
||||
|
||||
'' + optionalString cc.langAda or false ''
|
||||
touch "$out/nix-support/gnat-cflags"
|
||||
touch "$out/nix-support/gnat-ldflags"
|
||||
basePath=$(echo $cc/lib/*/*/*)
|
||||
ccCFlags+=" -B$basePath -I$basePath/adainclude"
|
||||
gnatCFlags="-I$basePath/adainclude -I$basePath/adalib"
|
||||
|
||||
echo "$gnatCFlags" > $out/nix-support/gnat-cflags
|
||||
echo "$gnatCFlags" >> $out/nix-support/gnat-cflags
|
||||
'' + ''
|
||||
echo "$ccLDFlags" > $out/nix-support/cc-ldflags
|
||||
echo "$ccCFlags" > $out/nix-support/cc-cflags
|
||||
echo "$ccLDFlags" >> $out/nix-support/cc-ldflags
|
||||
echo "$ccCFlags" >> $out/nix-support/cc-cflags
|
||||
'' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) ''
|
||||
echo " -L${libcxx}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + optionalString propagateDoc ''
|
||||
''
|
||||
|
||||
##
|
||||
## Man page and info support
|
||||
##
|
||||
|
||||
+ optionalString propagateDoc ''
|
||||
ln -s ${cc.man} $man
|
||||
ln -s ${cc.info} $info
|
||||
'' + optionalString (cc.langD or false) ''
|
||||
echo "-B${zlib}${zlib.libdir or "/lib/"}" >> $out/nix-support/libc-cflags
|
||||
''
|
||||
|
||||
+ ''
|
||||
##
|
||||
## Hardening support
|
||||
##
|
||||
|
||||
+ ''
|
||||
export hardening_unsupported_flags="${builtins.concatStringsSep " " (cc.hardeningUnsupportedFlags or [])}"
|
||||
''
|
||||
|
||||
@ -420,19 +436,18 @@ stdenv.mkDerivation {
|
||||
# There are a few tools (to name one libstdcxx5) which do not work
|
||||
# well with multi line flags, so make the flags single line again
|
||||
+ ''
|
||||
for flags in "$out/nix-support"/*flags; do
|
||||
for flags in "$out/nix-support"/*flags*; do
|
||||
substituteInPlace "$flags" --replace $'\n' ' '
|
||||
done
|
||||
|
||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
||||
''
|
||||
|
||||
##
|
||||
## Extra custom steps
|
||||
##
|
||||
''
|
||||
|
||||
+ extraBuildCommands;
|
||||
|
||||
inherit expand-response-params;
|
||||
|
Loading…
Reference in New Issue
Block a user