*-wrapper; Switch from infixSalt to suffixSalt

I hate the thing too even though I made it, and rather just get rid of
it. But we can't do that yet. In the meantime, this brings us more
inline with autoconf and will make it slightly easier for me to write a
pkg-config wrapper, which we need.
This commit is contained in:
John Ericson 2020-04-28 00:08:48 -04:00 committed by John Cotton Ericson
parent f7a93031a2
commit 1ac5398589
42 changed files with 183 additions and 180 deletions

View file

@ -367,6 +367,12 @@ php.override {
The default output of <literal>buildGoPackage</literal> is now <literal>$out</literal> instead of <literal>$bin</literal>. The default output of <literal>buildGoPackage</literal> is now <literal>$out</literal> instead of <literal>$bin</literal>.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The cc- and binutils-wrapper's "infix salt" and <literal>_BUILD_</literal> and <literal>_TARGET_</literal> user infixes have been replaced with with a "suffix salt" and suffixes and <literal>_FOR_BUILD</literal> and <literal>_FOR_TARGET</literal>.
This matches the autotools convention for env vars which standard for these things, making interfacing with other tools easier.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
</section> </section>

View file

@ -182,7 +182,7 @@ stdenv.mkDerivation rec {
preConfigure = '' preConfigure = ''
configureFlagsArray+=( configureFlagsArray+=(
"--cc=$CC" "--cc=$CC"
"--host-cc=$BUILD_CC" "--host-cc=$CC_FOR_BUILD"
"--as=$AS" "--as=$AS"
"--nm=$NM" "--nm=$NM"
"--ar=$AR" "--ar=$AR"

View file

@ -1,32 +1,32 @@
# See cc-wrapper for comments. # See cc-wrapper for comments.
var_templates_list=( var_templates_list=(
NIX+IGNORE_LD_THROUGH_GCC NIX_IGNORE_LD_THROUGH_GCC
NIX+LDFLAGS NIX_LDFLAGS
NIX+LDFLAGS_BEFORE NIX_LDFLAGS_BEFORE
NIX+LDFLAGS_AFTER NIX_LDFLAGS_AFTER
NIX+LDFLAGS_HARDEN NIX_LDFLAGS_HARDEN
NIX+HARDENING_ENABLE NIX_HARDENING_ENABLE
) )
var_templates_bool=( var_templates_bool=(
NIX+SET_BUILD_ID NIX_SET_BUILD_ID
NIX+DONT_SET_RPATH NIX_DONT_SET_RPATH
) )
accumulateRoles accumulateRoles
for var in "${var_templates_list[@]}"; do for var in "${var_templates_list[@]}"; do
mangleVarList "$var" ${role_infixes[@]+"${role_infixes[@]}"} mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
done done
for var in "${var_templates_bool[@]}"; do for var in "${var_templates_bool[@]}"; do
mangleVarBool "$var" ${role_infixes[@]+"${role_infixes[@]}"} mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
done done
if [ -e @out@/nix-support/libc-ldflags ]; then if [ -e @out@/nix-support/libc-ldflags ]; then
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)" NIX_LDFLAGS_@suffixSalt@+=" $(< @out@/nix-support/libc-ldflags)"
fi fi
if [ -e @out@/nix-support/libc-ldflags-before ]; then if [ -e @out@/nix-support/libc-ldflags-before ]; then
NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE" NIX_LDFLAGS_BEFORE_@suffixSalt@="$(< @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE_@suffixSalt@"
fi fi
export NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET=1 export NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@=1

View file

@ -5,7 +5,7 @@ declare -A hardeningEnableMap=()
# Intentionally word-split in case 'NIX_HARDENING_ENABLE' is defined in Nix. The # Intentionally word-split in case 'NIX_HARDENING_ENABLE' is defined in Nix. The
# array expansion also prevents undefined variables from causing trouble with # array expansion also prevents undefined variables from causing trouble with
# `set -u`. # `set -u`.
for flag in ${NIX_@infixSalt@_HARDENING_ENABLE-}; do for flag in ${NIX_HARDENING_ENABLE_@suffixSalt@-}; do
hardeningEnableMap["$flag"]=1 hardeningEnableMap["$flag"]=1
done done

View file

@ -45,7 +45,7 @@ let
coreutils_bin = if nativeTools then "" else getBin coreutils; coreutils_bin = if nativeTools then "" else getBin coreutils;
# See description in cc-wrapper. # See description in cc-wrapper.
infixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
# The dynamic linker has different names on different platforms. This is a # The dynamic linker has different names on different platforms. This is a
# shell glob that ought to match it. # shell glob that ought to match it.
@ -83,7 +83,7 @@ stdenv.mkDerivation {
shell = getBin shell + shell.shellPath or ""; shell = getBin shell + shell.shellPath or "";
gnugrep_bin = if nativeTools then "" else gnugrep; gnugrep_bin = if nativeTools then "" else gnugrep;
inherit targetPrefix infixSalt; inherit targetPrefix suffixSalt;
outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (bintools ? info) "info"); outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (bintools ? info) "info");
@ -95,9 +95,9 @@ stdenv.mkDerivation {
(mapc (mapc
(lambda (arg) (lambda (arg)
(when (file-directory-p (concat arg "/lib")) (when (file-directory-p (concat arg "/lib"))
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib"))) (setenv "NIX_LDFLAGS_${suffixSalt}" (concat (getenv "NIX_LDFLAGS_${suffixSalt}") " -L" arg "/lib")))
(when (file-directory-p (concat arg "/lib64")) (when (file-directory-p (concat arg "/lib64"))
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib64")))) (setenv "NIX_LDFLAGS_${suffixSalt}" (concat (getenv "NIX_LDFLAGS_${suffixSalt}") " -L" arg "/lib64"))))
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)})) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
''; '';
}; };

View file

@ -16,7 +16,7 @@ fi
source @out@/nix-support/utils.bash source @out@/nix-support/utils.bash
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
@ -24,7 +24,7 @@ fi
# Optionally filter out paths not refering to the store. # Optionally filter out paths not refering to the store.
expandResponseParams "$@" expandResponseParams "$@"
if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "${NIX_STORE:-}" if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "${NIX_STORE:-}"
&& ( -z "$NIX_@infixSalt@_IGNORE_LD_THROUGH_GCC" || -z "${NIX_@infixSalt@_LDFLAGS_SET:-}" ) ]]; then && ( -z "$NIX_IGNORE_LD_THROUGH_GCC_@suffixSalt@" || -z "${NIX_LDFLAGS_SET_@suffixSalt@:-}" ) ]]; then
rest=() rest=()
nParams=${#params[@]} nParams=${#params[@]}
declare -i n=0 declare -i n=0
@ -60,12 +60,12 @@ source @out@/nix-support/add-hardening.sh
extraAfter=() extraAfter=()
extraBefore=(${hardeningLDFlags[@]+"${hardeningLDFlags[@]}"}) extraBefore=(${hardeningLDFlags[@]+"${hardeningLDFlags[@]}"})
if [ -z "${NIX_@infixSalt@_LDFLAGS_SET:-}" ]; then if [ -z "${NIX_LDFLAGS_SET_@suffixSalt@:-}" ]; then
extraAfter+=($NIX_@infixSalt@_LDFLAGS) extraAfter+=($NIX_LDFLAGS_@suffixSalt@)
extraBefore+=($NIX_@infixSalt@_LDFLAGS_BEFORE) extraBefore+=($NIX_LDFLAGS_BEFORE_@suffixSalt@)
fi fi
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER) extraAfter+=($NIX_LDFLAGS_AFTER_@suffixSalt@)
# Specify the target emulation if nothing is passed in ("-m" overrides this # Specify the target emulation if nothing is passed in ("-m" overrides this
# environment variable). Ensures we never blindly fallback on targeting the host # environment variable). Ensures we never blindly fallback on targeting the host
@ -84,8 +84,8 @@ declare -A libs
declare -i relocatable=0 link32=0 declare -i relocatable=0 link32=0
if if
[ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] \ [ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 1 ] \
|| [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] \ || [ "$NIX_SET_BUILD_ID_@suffixSalt@" = 1 ] \
|| [ -e @out@/nix-support/dynamic-linker-m32 ] || [ -e @out@/nix-support/dynamic-linker-m32 ]
then then
prev= prev=
@ -144,7 +144,7 @@ if [ -e "@out@/nix-support/dynamic-linker-m32" ] && (( "$link32" )); then
fi fi
# Add all used dynamic libraries to the rpath. # Add all used dynamic libraries to the rpath.
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then if [ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 1 ]; then
# For each directory in the library search path (-L...), # For each directory in the library search path (-L...),
# see if it contains a dynamic library used by a -l... flag. If # see if it contains a dynamic library used by a -l... flag. If
# so, add the directory to the rpath. # so, add the directory to the rpath.
@ -186,7 +186,7 @@ fi
# Only add --build-id if this is a final link. FIXME: should build gcc # Only add --build-id if this is a final link. FIXME: should build gcc
# with --enable-linker-build-id instead? # with --enable-linker-build-id instead?
if [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] && ! (( "$relocatable" )); then if [ "$NIX_SET_BUILD_ID_@suffixSalt@" = 1 ] && ! (( "$relocatable" )); then
extraAfter+=(--build-id) extraAfter+=(--build-id)
fi fi

View file

@ -10,11 +10,11 @@
bintoolsWrapper_addLDVars () { bintoolsWrapper_addLDVars () {
# See ../setup-hooks/role.bash # See ../setup-hooks/role.bash
local role_post role_pre local role_post
getHostRoleEnvHook getHostRoleEnvHook
if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then
export NIX_${role_pre}LDFLAGS+=" -L$1/lib64" export NIX_LDFLAGS${role_post}+=" -L$1/lib64"
fi fi
if [[ -d "$1/lib" ]]; then if [[ -d "$1/lib" ]]; then
@ -24,7 +24,7 @@ bintoolsWrapper_addLDVars () {
# directories and bloats the size of the environment variable space. # directories and bloats the size of the environment variable space.
local -a glob=( $1/lib/lib* ) local -a glob=( $1/lib/lib* )
if [ "${#glob[*]}" -gt 0 ]; then if [ "${#glob[*]}" -gt 0 ]; then
export NIX_${role_pre}LDFLAGS+=" -L$1/lib" export NIX_LDFLAGS${role_post}+=" -L$1/lib"
fi fi
fi fi
} }
@ -52,7 +52,7 @@ fi
# Export tool environment variables so various build systems use the right ones. # Export tool environment variables so various build systems use the right ones.
export NIX_${role_pre}BINTOOLS=@out@ export NIX_BINTOOLS${role_post}=@out@
for cmd in \ for cmd in \
ar as ld nm objcopy objdump readelf ranlib strip strings size windres ar as ld nm objcopy objdump readelf ranlib strip strings size windres
@ -60,7 +60,6 @@ do
if if
PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null
then then
export "${role_pre}${cmd^^}=@targetPrefix@${cmd}";
export "${cmd^^}${role_post}=@targetPrefix@${cmd}"; export "${cmd^^}${role_post}=@targetPrefix@${cmd}";
fi fi
done done
@ -70,4 +69,4 @@ done
export NIX_HARDENING_ENABLE export NIX_HARDENING_ENABLE
# No local scope in sourced file # No local scope in sourced file
unset -v role_pre role_post cmd upper_case unset -v role_post cmd upper_case

View file

@ -58,7 +58,7 @@ let
# Force compilers and other tools to look in default search paths # Force compilers and other tools to look in default search paths
unset NIX_ENFORCE_PURITY unset NIX_ENFORCE_PURITY
export NIX_CC_WRAPPER_${stdenv.cc.infixSalt}_TARGET_HOST=1 export NIX_CC_WRAPPER_TARGET_HOST_${stdenv.cc.suffixSalt}=1
export NIX_CFLAGS_COMPILE='-idirafter /usr/include' export NIX_CFLAGS_COMPILE='-idirafter /usr/include'
export NIX_CFLAGS_LINK='-L/usr/lib -L/usr/lib32' export NIX_CFLAGS_LINK='-L/usr/lib -L/usr/lib32'
export NIX_LDFLAGS='-L/usr/lib -L/usr/lib32' export NIX_LDFLAGS='-L/usr/lib -L/usr/lib32'

View file

@ -5,15 +5,15 @@
# wrapped binary just inherit the work of the forker's wrapper script. # wrapped binary just inherit the work of the forker's wrapper script.
var_templates_list=( var_templates_list=(
NIX+CFLAGS_COMPILE NIX_CFLAGS_COMPILE
NIX+CFLAGS_COMPILE_BEFORE NIX_CFLAGS_COMPILE_BEFORE
NIX+CFLAGS_LINK NIX_CFLAGS_LINK
NIX+CXXSTDLIB_COMPILE NIX_CXXSTDLIB_COMPILE
NIX+CXXSTDLIB_LINK NIX_CXXSTDLIB_LINK
NIX+GNATFLAGS_COMPILE NIX_GNATFLAGS_COMPILE
) )
var_templates_bool=( var_templates_bool=(
NIX+ENFORCE_NO_NATIVE NIX_ENFORCE_NO_NATIVE
) )
accumulateRoles accumulateRoles
@ -21,37 +21,37 @@ accumulateRoles
# We need to mangle names for hygiene, but also take parameters/overrides # We need to mangle names for hygiene, but also take parameters/overrides
# from the environment. # from the environment.
for var in "${var_templates_list[@]}"; do for var in "${var_templates_list[@]}"; do
mangleVarList "$var" ${role_infixes[@]+"${role_infixes[@]}"} mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
done done
for var in "${var_templates_bool[@]}"; do for var in "${var_templates_bool[@]}"; do
mangleVarBool "$var" ${role_infixes[@]+"${role_infixes[@]}"} mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
done done
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld. # `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
NIX_@infixSalt@_CFLAGS_COMPILE="-B@out@/bin/ $NIX_@infixSalt@_CFLAGS_COMPILE" NIX_CFLAGS_COMPILE_@suffixSalt@="-B@out@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@"
# Export and assign separately in order that a failing $(..) will fail # Export and assign separately in order that a failing $(..) will fail
# the script. # the script.
if [ -e @out@/nix-support/libc-cflags ]; then if [ -e @out@/nix-support/libc-cflags ]; then
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE" NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
fi fi
if [ -e @out@/nix-support/cc-cflags ]; then if [ -e @out@/nix-support/cc-cflags ]; then
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE" NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
fi fi
if [ -e @out@/nix-support/gnat-cflags ]; then if [ -e @out@/nix-support/gnat-cflags ]; then
NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE" NIX_GNATFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE_@suffixSalt@"
fi fi
if [ -e @out@/nix-support/cc-ldflags ]; then if [ -e @out@/nix-support/cc-ldflags ]; then
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)" NIX_LDFLAGS_@suffixSalt@+=" $(< @out@/nix-support/cc-ldflags)"
fi fi
if [ -e @out@/nix-support/cc-cflags-before ]; then if [ -e @out@/nix-support/cc-cflags-before ]; then
NIX_@infixSalt@_CFLAGS_COMPILE_BEFORE="$(< @out@/nix-support/cc-cflags-before) $NIX_@infixSalt@_CFLAGS_COMPILE_BEFORE" NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="$(< @out@/nix-support/cc-cflags-before) $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
fi fi
# That way forked processes will not extend these environment variables again. # That way forked processes will not extend these environment variables again.
export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1 export NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@=1

View file

@ -5,7 +5,7 @@ declare -A hardeningEnableMap=()
# Intentionally word-split in case 'NIX_HARDENING_ENABLE' is defined in Nix. The # Intentionally word-split in case 'NIX_HARDENING_ENABLE' is defined in Nix. The
# array expansion also prevents undefined variables from causing trouble with # array expansion also prevents undefined variables from causing trouble with
# `set -u`. # `set -u`.
for flag in ${NIX_@infixSalt@_HARDENING_ENABLE-}; do for flag in ${NIX_HARDENING_ENABLE_@suffixSalt@-}; do
hardeningEnableMap["$flag"]=1 hardeningEnableMap["$flag"]=1
done done

View file

@ -18,12 +18,12 @@ fi
source @out@/nix-support/utils.bash source @out@/nix-support/utils.bash
# Flirting with a layer violation here. # Flirting with a layer violation here.
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
source @bintools@/nix-support/add-flags.sh source @bintools@/nix-support/add-flags.sh
fi fi
# Put this one second so libc ldflags take priority. # Put this one second so libc ldflags take priority.
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
@ -113,7 +113,7 @@ fi
# Clear march/mtune=native -- they bring impurity. # Clear march/mtune=native -- they bring impurity.
if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then
rest=() rest=()
# Old bash empty array hack # Old bash empty array hack
for p in ${params+"${params[@]}"}; do for p in ${params+"${params[@]}"}; do
@ -129,36 +129,36 @@ fi
if [[ "$isCpp" = 1 ]]; then if [[ "$isCpp" = 1 ]]; then
if [[ "$cppInclude" = 1 ]]; then if [[ "$cppInclude" = 1 ]]; then
NIX_@infixSalt@_CFLAGS_COMPILE+=" ${NIX_@infixSalt@_CXXSTDLIB_COMPILE:-@default_cxx_stdlib_compile@}" NIX_CFLAGS_COMPILE_@suffixSalt@+=" ${NIX_CXXSTDLIB_COMPILE_@suffixSalt@:-@default_cxx_stdlib_compile@}"
fi fi
NIX_@infixSalt@_CFLAGS_LINK+=" $NIX_@infixSalt@_CXXSTDLIB_LINK" NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@"
fi fi
source @out@/nix-support/add-hardening.sh source @out@/nix-support/add-hardening.sh
# Add the flags for the C compiler proper. # Add the flags for the C compiler proper.
extraAfter=($NIX_@infixSalt@_CFLAGS_COMPILE) extraAfter=($NIX_CFLAGS_COMPILE_@suffixSalt@)
extraBefore=(${hardeningCFlags[@]+"${hardeningCFlags[@]}"} $NIX_@infixSalt@_CFLAGS_COMPILE_BEFORE) extraBefore=(${hardeningCFlags[@]+"${hardeningCFlags[@]}"} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@)
if [ "$dontLink" != 1 ]; then if [ "$dontLink" != 1 ]; then
# Add the flags that should only be passed to the compiler when # Add the flags that should only be passed to the compiler when
# linking. # linking.
extraAfter+=($NIX_@infixSalt@_CFLAGS_LINK) extraAfter+=($NIX_CFLAGS_LINK_@suffixSalt@)
# Add the flags that should be passed to the linker (and prevent # Add the flags that should be passed to the linker (and prevent
# `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again). # `ld-wrapper' from adding NIX_LDFLAGS_@suffixSalt@ again).
for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do for i in $NIX_LDFLAGS_BEFORE_@suffixSalt@; do
extraBefore+=("-Wl,$i") extraBefore+=("-Wl,$i")
done done
for i in $NIX_@infixSalt@_LDFLAGS; do for i in $NIX_LDFLAGS_@suffixSalt@; do
if [ "${i:0:3}" = -L/ ]; then if [ "${i:0:3}" = -L/ ]; then
extraAfter+=("$i") extraAfter+=("$i")
else else
extraAfter+=("-Wl,$i") extraAfter+=("-Wl,$i")
fi fi
done done
export NIX_@infixSalt@_LDFLAGS_SET=1 export NIX_LDFLAGS_SET_@suffixSalt@=1
fi fi
# As a very special hack, if the arguments are just `-v', then don't # As a very special hack, if the arguments are just `-v', then don't

View file

@ -53,12 +53,12 @@ let
"-isystem ${libcxx}/include/c++/v1" "-isystem ${libcxx}/include/c++/v1"
else ""; else "";
# The "infix salt" is a arbitrary string added in the middle of env vars # The "suffix salt" is a arbitrary string added in the end of env vars
# defined by cc-wrapper's hooks so that multiple cc-wrappers can be used # defined by cc-wrapper's hooks so that multiple cc-wrappers can be used
# without interfering. For the moment, it is defined as the target triple, # without interfering. For the moment, it is defined as the target triple,
# adjusted to be a valid bash identifier. This should be considered an # adjusted to be a valid bash identifier. This should be considered an
# unstable implementation detail, however. # unstable implementation detail, however.
infixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
expand-response-params = expand-response-params =
if buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null" if buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null"
@ -105,7 +105,7 @@ stdenv.mkDerivation {
shell = getBin shell + shell.shellPath or ""; shell = getBin shell + shell.shellPath or "";
gnugrep_bin = if nativeTools then "" else gnugrep; gnugrep_bin = if nativeTools then "" else gnugrep;
inherit targetPrefix infixSalt; inherit targetPrefix suffixSalt;
outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ]; outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ];
@ -122,7 +122,7 @@ stdenv.mkDerivation {
(mapc (mapc
(lambda (arg) (lambda (arg)
(when (file-directory-p (concat arg "/include")) (when (file-directory-p (concat arg "/include"))
(setenv "NIX_${infixSalt}_CFLAGS_COMPILE" (concat (getenv "NIX_${infixSalt}_CFLAGS_COMPILE") " -isystem " arg "/include")))) (setenv "NIX_CFLAGS_COMPILE_${suffixSalt}" (concat (getenv "NIX_CFLAGS_COMPILE_${suffixSalt}") " -isystem " arg "/include"))))
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)})) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
''; '';
}; };

View file

@ -18,12 +18,12 @@ fi
source @out@/nix-support/utils.bash source @out@/nix-support/utils.bash
# Flirting with a layer violation here. # Flirting with a layer violation here.
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
source @bintools@/nix-support/add-flags.sh source @bintools@/nix-support/add-flags.sh
fi fi
# Put this one second so libc ldflags take priority. # Put this one second so libc ldflags take priority.
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
@ -108,7 +108,7 @@ fi
# Clear march/mtune=native -- they bring impurity. # Clear march/mtune=native -- they bring impurity.
if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then
rest=() rest=()
# Old bash empty array hack # Old bash empty array hack
for p in ${params+"${params[@]}"}; do for p in ${params+"${params[@]}"}; do
@ -124,12 +124,12 @@ fi
if [ "$(basename $0)x" = "gnatmakex" ]; then if [ "$(basename $0)x" = "gnatmakex" ]; then
extraBefore=("--GNATBIND=@out@/bin/gnatbind" "--GNATLINK=@out@/bin/gnatlink") extraBefore=("--GNATBIND=@out@/bin/gnatbind" "--GNATLINK=@out@/bin/gnatlink")
extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE) extraAfter=($NIX_GNATFLAGS_COMPILE_@suffixSalt@)
fi fi
if [ "$(basename $0)x" = "gnatbindx" ]; then if [ "$(basename $0)x" = "gnatbindx" ]; then
extraBefore=() extraBefore=()
extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE) extraAfter=($NIX_GNATFLAGS_COMPILE_@suffixSalt@)
fi fi
if [ "$(basename $0)x" = "gnatlinkx" ]; then if [ "$(basename $0)x" = "gnatlinkx" ]; then

View file

@ -6,9 +6,9 @@
# tools. For example: # tools. For example:
# #
# # Flags for compiling (whether or not linking) C code for the... # # Flags for compiling (whether or not linking) C code for the...
# NIX_BUILD_CFLAGS_COMPILE # ...build platform # NIX_CFLAGS_COMPILE_FOR_BUILD # ...build platform
# NIX_CFLAGS_COMPILE # ...host platform # NIX_CFLAGS_COMPILE # ...host platform
# NIX_TARGET_CFLAGS_COMPILE # ...target platform # NIX_CFLAGS_COMPILE_FOR_TARGET # ...target platform
# #
# Notice that these platforms are the 3 *relative* to the package using # Notice that these platforms are the 3 *relative* to the package using
# cc-wrapper, not absolute like `x86_64-pc-linux-gnu`. # cc-wrapper, not absolute like `x86_64-pc-linux-gnu`.
@ -33,12 +33,12 @@
# The basic strategy is: # The basic strategy is:
# #
# - Everyone exclusively *adds information* to relative-platform-specific # - Everyone exclusively *adds information* to relative-platform-specific
# environment variables, like `NIX_TARGET_CFLAGS_COMPILE`, to communicate # environment variables, like `NIX_CFLAGS_COMPILE_FOR_TARGET`, to communicate
# with the wrapped binaries. # with the wrapped binaries.
# #
# - The wrapped binaries will exclusively *read* cc-wrapper-derivation-specific # - The wrapped binaries will exclusively *read* cc-wrapper-derivation-specific
# environment variables distinguished with with `infixSalt`, like # environment variables distinguished with with `suffixSalt`, like
# `NIX_@infixSalt@_CFLAGS_COMPILE`. # `NIX_CFLAGS_COMPILE_@suffixSalt@`.
# #
# - `add-flags`, beyond its old task of reading extra flags stuck inside the # - `add-flags`, beyond its old task of reading extra flags stuck inside the
# cc-wrapper derivation, will convert the relative-platform-specific # cc-wrapper derivation, will convert the relative-platform-specific
@ -65,15 +65,15 @@
# function is guaranteed to be exactly the same. # function is guaranteed to be exactly the same.
ccWrapper_addCVars () { ccWrapper_addCVars () {
# See ../setup-hooks/role.bash # See ../setup-hooks/role.bash
local role_post role_pre local role_post
getHostRoleEnvHook getHostRoleEnvHook
if [ -d "$1/include" ]; then if [ -d "$1/include" ]; then
export NIX_${role_pre}CFLAGS_COMPILE+=" -isystem $1/include" export NIX_CFLAGS_COMPILE${role_post}+=" -isystem $1/include"
fi fi
if [ -d "$1/Library/Frameworks" ]; then if [ -d "$1/Library/Frameworks" ]; then
export NIX_${role_pre}CFLAGS_COMPILE+=" -iframework $1/Library/Frameworks" export NIX_CFLAGS_COMPILE${role_post}+=" -iframework $1/Library/Frameworks"
fi fi
} }
@ -105,10 +105,10 @@ fi
# Export tool environment variables so various build systems use the right ones. # Export tool environment variables so various build systems use the right ones.
export NIX_${role_pre}CC=@out@ export NIX_CC${role_post}=@out@
export ${role_pre}CC=@named_cc@ export CC${role_post}=@named_cc@
export ${role_pre}CXX=@named_cxx@ export CXX${role_post}=@named_cxx@
export CC${role_post}=@named_cc@ export CC${role_post}=@named_cc@
export CXX${role_post}=@named_cxx@ export CXX${role_post}=@named_cxx@
@ -117,4 +117,4 @@ export CXX${role_post}=@named_cxx@
export NIX_HARDENING_ENABLE export NIX_HARDENING_ENABLE
# No local scope in sourced file # No local scope in sourced file
unset -v role_pre role_post unset -v role_post

View file

@ -3,21 +3,17 @@
# derivation) in which the derivation is used. # derivation) in which the derivation is used.
# #
# The role is intened to be use as part of other variables names like # The role is intened to be use as part of other variables names like
# - $NIX_${role_pre}_SOMETHING # - $NIX_SOMETHING${role_post}
# - $NIX_SOMETHING_${role_post}
function getRole() { function getRole() {
case $1 in case $1 in
-1) -1)
role_pre='BUILD_'
role_post='_FOR_BUILD' role_post='_FOR_BUILD'
;; ;;
0) 0)
role_pre=''
role_post='' role_post=''
;; ;;
1) 1)
role_pre='TARGET_'
role_post='_FOR_TARGET' role_post='_FOR_TARGET'
;; ;;
*) *)
@ -54,18 +50,18 @@ function getTargetRoleEnvHook() {
} }
# This variant is inteneded specifically for code-prodocing tool wrapper scripts # This variant is inteneded specifically for code-prodocing tool wrapper scripts
# `NIX_@wrapperName@_@infixSalt@_TARGET_*` tracks this (needs to be an exported # `NIX_@wrapperName@_TARGET_*_@suffixSalt@` tracks this (needs to be an exported
# env var so can't use fancier data structures). # env var so can't use fancier data structures).
function getTargetRoleWrapper() { function getTargetRoleWrapper() {
case $targetOffset in case $targetOffset in
-1) -1)
export NIX_@wrapperName@_@infixSalt@_TARGET_BUILD=1 export NIX_@wrapperName@_TARGET_BUILD_@suffixSalt@=1
;; ;;
0) 0)
export NIX_@wrapperName@_@infixSalt@_TARGET_HOST=1 export NIX_@wrapperName@_TARGET_HOST_@suffixSalt@=1
;; ;;
1) 1)
export NIX_@wrapperName@_@infixSalt@_TARGET_TARGET=1 export NIX_@wrapperName@_TARGET_TARGET_@suffixSalt@=1
;; ;;
*) *)
echo "@name@: used as improper sort of dependency" >2 echo "@name@: used as improper sort of dependency" >2

View file

@ -1,29 +1,29 @@
# Accumulate infixes for taking in the right input parameters with the `mangle*` # Accumulate suffixes for taking in the right input parameters with the `mangle*`
# functions below. See setup-hook for details. # functions below. See setup-hook for details.
accumulateRoles() { accumulateRoles() {
declare -ga role_infixes=() declare -ga role_suffixes=()
if [ "${NIX_@wrapperName@_@infixSalt@_TARGET_BUILD:-}" ]; then if [ "${NIX_@wrapperName@_TARGET_BUILD_@suffixSalt@:-}" ]; then
role_infixes+=(_BUILD_) role_suffixes+=('_FOR_BUILD')
fi fi
if [ "${NIX_@wrapperName@_@infixSalt@_TARGET_HOST:-}" ]; then if [ "${NIX_@wrapperName@_TARGET_HOST_@suffixSalt@:-}" ]; then
role_infixes+=(_) role_suffixes+=('')
fi fi
if [ "${NIX_@wrapperName@_@infixSalt@_TARGET_TARGET:-}" ]; then if [ "${NIX_@wrapperName@_TARGET_TARGET_@suffixSalt@:-}" ]; then
role_infixes+=(_TARGET_) role_suffixes+=('_FOR_TARGET')
fi fi
} }
mangleVarList() { mangleVarList() {
local var="$1" local var="$1"
shift shift
local -a role_infixes=("$@") local -a role_suffixes=("$@")
local outputVar="${var/+/_@infixSalt@_}" local outputVar="${var}_@suffixSalt@"
declare -gx ${outputVar}+='' declare -gx ${outputVar}+=''
# For each role we serve, we accumulate the input parameters into our own # For each role we serve, we accumulate the input parameters into our own
# cc-wrapper-derivation-specific environment variables. # cc-wrapper-derivation-specific environment variables.
for infix in "${role_infixes[@]}"; do for suffix in "${role_suffixes[@]}"; do
local inputVar="${var/+/${infix}}" local inputVar="${var}${suffix}"
if [ -v "$inputVar" ]; then if [ -v "$inputVar" ]; then
export ${outputVar}+="${!outputVar:+ }${!inputVar}" export ${outputVar}+="${!outputVar:+ }${!inputVar}"
fi fi
@ -33,12 +33,12 @@ mangleVarList() {
mangleVarBool() { mangleVarBool() {
local var="$1" local var="$1"
shift shift
local -a role_infixes=("$@") local -a role_suffixes=("$@")
local outputVar="${var/+/_@infixSalt@_}" local outputVar="${var}_@suffixSalt@"
declare -gxi ${outputVar}+=0 declare -gxi ${outputVar}+=0
for infix in "${role_infixes[@]}"; do for suffix in "${role_suffixes[@]}"; do
local inputVar="${var/+/${infix}}" local inputVar="${var}${suffix}"
if [ -v "$inputVar" ]; then if [ -v "$inputVar" ]; then
# "1" in the end makes `let` return success error code when # "1" in the end makes `let` return success error code when
# expression itself evaluates to zero. # expression itself evaluates to zero.

View file

@ -239,8 +239,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -264,8 +264,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -276,8 +276,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -292,8 +292,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -247,8 +247,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -234,8 +234,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -239,8 +239,8 @@ stdenv.mkDerivation ({
(import ../common/extra-target-flags.nix { (import ../common/extra-target-flags.nix {
inherit stdenv crossStageStatic libcCross threadsCross; inherit stdenv crossStageStatic libcCross threadsCross;
}) })
EXTRA_TARGET_FLAGS EXTRA_FLAGS_FOR_TARGET
EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_TARGET
; ;
passthru = { passthru = {

View file

@ -25,12 +25,12 @@ echo "\$LIBRARY_PATH is \`${LIBRARY_PATH-}'"
if test "$noSysDirs" = "1"; then if test "$noSysDirs" = "1"; then
declare \ declare \
EXTRA_BUILD_FLAGS EXTRA_FLAGS EXTRA_TARGET_FLAGS \ EXTRA_FLAGS_FOR_BUILD EXTRA_FLAGS EXTRA_FLAGS_FOR_TARGET \
EXTRA_BUILD_LDFLAGS EXTRA_TARGET_LDFLAGS EXTRA_LDFLAGS_FOR_BUILD EXTRA_LDFLAGS_FOR_TARGET
# Extract flags from Bintools Wrappers # Extract flags from Bintools Wrappers
for pre in 'BUILD_' ''; do for post in '_FOR_BUILD' ''; do
curBintools="NIX_${pre}BINTOOLS" curBintools="NIX_BINTOOLS${post}"
declare -a extraLDFlags=() declare -a extraLDFlags=()
if [[ -e "${!curBintools}/nix-support/orig-libc" ]]; then if [[ -e "${!curBintools}/nix-support/orig-libc" ]]; then
@ -48,14 +48,14 @@ if test "$noSysDirs" = "1"; then
extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir"
"${extraLDFlags[@]}") "${extraLDFlags[@]}")
for i in "${extraLDFlags[@]}"; do for i in "${extraLDFlags[@]}"; do
declare EXTRA_${pre}LDFLAGS+=" -Wl,$i" declare EXTRA_LDFLAGS${post}+=" -Wl,$i"
done done
done done
# Extract flags from CC Wrappers # Extract flags from CC Wrappers
for pre in 'BUILD_' ''; do for post in '_FOR_BUILD' ''; do
curCC="NIX_${pre}CC" curCC="NIX_CC${post}"
curFIXINC="NIX_${pre}FIXINC_DUMMY" curFIXINC="NIX_FIXINC_DUMMY${post}"
declare -a extraFlags=() declare -a extraFlags=()
if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then
@ -69,11 +69,11 @@ if test "$noSysDirs" = "1"; then
# Use *real* header files, otherwise a limits.h is generated that # Use *real* header files, otherwise a limits.h is generated that
# does not include Libc's limits.h (notably missing SSIZE_MAX, # does not include Libc's limits.h (notably missing SSIZE_MAX,
# which breaks the build). # which breaks the build).
declare NIX_${pre}FIXINC_DUMMY="$libc_devdir/include" declare NIX_FIXINC_DUMMY${post}="$libc_devdir/include"
else else
# Hack: support impure environments. # Hack: support impure environments.
extraFlags=("-isystem" "/usr/include") extraFlags=("-isystem" "/usr/include")
declare NIX_${pre}FIXINC_DUMMY=/usr/include declare NIX_FIXINC_DUMMY${post}=/usr/include
fi fi
extraFlags=("-I${!curFIXINC}" "${extraFlags[@]}") extraFlags=("-I${!curFIXINC}" "${extraFlags[@]}")
@ -89,13 +89,13 @@ if test "$noSysDirs" = "1"; then
extraFlags=("-O2" "${extraFlags[@]}") extraFlags=("-O2" "${extraFlags[@]}")
fi fi
declare EXTRA_${pre}FLAGS="${extraFlags[*]}" declare EXTRA_FLAGS${post}="${extraFlags[*]}"
done done
if test -z "${targetConfig-}"; then if test -z "${targetConfig-}"; then
# host = target, so the flags are the same # host = target, so the flags are the same
EXTRA_TARGET_FLAGS="$EXTRA_FLAGS" EXTRA_FLAGS_FOR_TARGET="$EXTRA_FLAGS"
EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" EXTRA_LDFLAGS_FOR_TARGET="$EXTRA_LDFLAGS"
fi fi
# CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
@ -103,31 +103,31 @@ if test "$noSysDirs" = "1"; then
# FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
# for the startfiles. # for the startfiles.
makeFlagsArray+=( makeFlagsArray+=(
"BUILD_SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" "BUILD_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY_FOR_BUILD"
"SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" "SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY_FOR_BUILD"
"NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY" "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY"
"LDFLAGS_FOR_BUILD=$EXTRA_BUILD_LDFLAGS" "LDFLAGS_FOR_BUILD=$EXTRA_LDFLAGS_FOR_BUILD"
#"LDFLAGS=$EXTRA_LDFLAGS" #"LDFLAGS=$EXTRA_LDFLAGS"
"LDFLAGS_FOR_TARGET=$EXTRA_TARGET_LDFLAGS" "LDFLAGS_FOR_TARGET=$EXTRA_LDFLAGS_FOR_TARGET"
"CFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" "CFLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD"
"CXXFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" "CXXFLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD"
"FLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" "FLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD"
# It seems there is a bug in GCC 5 # It seems there is a bug in GCC 5
#"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS"
#"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS"
"CFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" "CFLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET"
"CXXFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" "CXXFLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET"
"FLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" "FLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET"
) )
if test -z "${targetConfig-}"; then if test -z "${targetConfig-}"; then
makeFlagsArray+=( makeFlagsArray+=(
"BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS"
"BOOT_LDFLAGS=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" "BOOT_LDFLAGS=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET"
) )
fi fi

View file

@ -5,7 +5,7 @@ let
in in
{ {
EXTRA_TARGET_FLAGS = let EXTRA_FLAGS_FOR_TARGET = let
mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([ mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
"-idirafter ${lib.getDev dep}${dep.incdir or "/include"}" "-idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
] ++ stdenv.lib.optionals (! crossStageStatic) [ ] ++ stdenv.lib.optionals (! crossStageStatic) [
@ -15,7 +15,7 @@ in
++ lib.optionals (!crossStageStatic) (mkFlags threadsCross) ++ lib.optionals (!crossStageStatic) (mkFlags threadsCross)
; ;
EXTRA_TARGET_LDFLAGS = let EXTRA_LDFLAGS_FOR_TARGET = let
mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([ mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
"-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}" "-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}"
] ++ (if crossStageStatic then [ ] ++ (if crossStageStatic then [

View file

@ -1,4 +1,4 @@
# See pkgs/build-support/setup-hooks/role.bash # See pkgs/build-support/setup-hooks/role.bash
getHostRole getHostRole
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/@targetConfig@" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/@targetConfig@"

View file

@ -462,7 +462,7 @@ in rec {
export CC="gcc" export CC="gcc"
export CPP="gcc -E" export CPP="gcc -E"
export NIX_CXXSTDLIB_LINK="" export NIX_CXXSTDLIB_LINK=""
export NIX_TARGET_CXXSTDLIB_LINK="" export NIX_CXXSTDLIB_LINK_FOR_TARGET=""
export OPENSSL_PREFIX=$(realpath openssl) export OPENSSL_PREFIX=$(realpath openssl)
# this fixes error: impure path 'LibFFIHeaderDirectives' used in link # this fixes error: impure path 'LibFFIHeaderDirectives' used in link
export NIX_ENFORCE_PURITY=0 export NIX_ENFORCE_PURITY=0

View file

@ -2,5 +2,5 @@
getHostRole getHostRole
linkCxxAbi="@linkCxxAbi@" linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -2,5 +2,5 @@
getHostRole getHostRole
linkCxxAbi="@linkCxxAbi@" linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -2,5 +2,5 @@
getHostRole getHostRole
linkCxxAbi="@linkCxxAbi@" linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -2,5 +2,5 @@
getHostRole getHostRole
linkCxxAbi="@linkCxxAbi@" linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -2,5 +2,5 @@
getHostRole getHostRole
linkCxxAbi="@linkCxxAbi@" linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -2,5 +2,5 @@
getHostRole getHostRole
linkCxxAbi="@linkCxxAbi@" linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -7,7 +7,7 @@ symlinkJoin {
postBuild = '' postBuild = ''
wrapProgram $out/bin/idris \ wrapProgram $out/bin/idris \
--run 'export IDRIS_CC=''${IDRIS_CC:-${stdenv.cc}/bin/cc}' \ --run 'export IDRIS_CC=''${IDRIS_CC:-${stdenv.cc}/bin/cc}' \
--set NIX_CC_WRAPPER_${stdenv.cc.infixSalt}_TARGET_HOST 1 \ --set 'NIX_CC_WRAPPER_TARGET_HOST_${stdenv.cc.suffixSalt}' 1 \
--prefix NIX_CFLAGS_COMPILE " " "-I${lib.getDev gmp}/include" \ --prefix NIX_CFLAGS_COMPILE " " "-I${lib.getDev gmp}/include" \
--prefix NIX_CFLAGS_LINK " " "-L${lib.getLib gmp}/lib" --prefix NIX_CFLAGS_LINK " " "-L${lib.getLib gmp}/lib"
''; '';

View file

@ -13,5 +13,5 @@ addEnvHooks "$hostOffset" gettextDataDirsHook
if [ -n "@gettextNeedsLdflags@" -a -z "${dontAddExtraLibs-}" ]; then if [ -n "@gettextNeedsLdflags@" -a -z "${dontAddExtraLibs-}" ]; then
# See pkgs/build-support/setup-hooks/role.bash # See pkgs/build-support/setup-hooks/role.bash
getHostRole getHostRole
export NIX_${role_pre}LDFLAGS+=" -lintl" export NIX_LDFLAGS${role_post}+=" -lintl"
fi fi

View file

@ -4,5 +4,5 @@
# See pkgs/build-support/setup-hooks/role.bash # See pkgs/build-support/setup-hooks/role.bash
if [ -z "${dontAddExtraLibs-}" ]; then if [ -z "${dontAddExtraLibs-}" ]; then
getHostRole getHostRole
export NIX_${role_pre}LDFLAGS+=" -liconv" export NIX_LDFLAGS${role_post}+=" -liconv"
fi fi

View file

@ -63,8 +63,10 @@ stdenv.mkDerivation rec {
--subst-var-by libc_lib ${lib.getLib stdenv.cc.libc} --subst-var-by libc_lib ${lib.getLib stdenv.cc.libc}
substituteInPlace Modules/FindCxxTest.cmake \ substituteInPlace Modules/FindCxxTest.cmake \
--replace "$""{PYTHON_EXECUTABLE}" ${stdenv.shell} --replace "$""{PYTHON_EXECUTABLE}" ${stdenv.shell}
# BUILD_CC and BUILD_CXX are used to bootstrap cmake ''
configureFlags="--parallel=''${NIX_BUILD_CORES:-1} CC=$BUILD_CC CXX=$BUILD_CXX $configureFlags" # CC_FOR_BUILD and CXX_FOR_BUILD are used to bootstrap cmake
+ ''
configureFlags="--parallel=''${NIX_BUILD_CORES:-1} CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD $configureFlags"
''; '';
configureFlags = [ configureFlags = [

View file

@ -4,7 +4,7 @@ diff -ur texinfo-6.5/configure texinfo-6.5-patched/configure
@@ -23281,7 +23281,7 @@ @@ -23281,7 +23281,7 @@
# env -i gives this build host configure a clean environment; # env -i gives this build host configure a clean environment;
# consequently, we have to re-initialize $PATH. # consequently, we have to re-initialize $PATH.
env -i CC="$BUILD_CC" AR="$BUILD_AR" RANLIB="$BUILD_RANLIB" \ env -i CC="$CC_FOR_BUILD" AR="$AR_FOR_BUILD" RANLIB="$RANLIB_FOR_BUILD" \
- PATH="$PATH" \ - PATH="$PATH" \
+ PATH="$PATH" CFLAGS="$NATIVE_TOOLS_CFLAGS" LDFLAGS="$NATIVE_TOOLS_LDFLAGS" \ + PATH="$PATH" CFLAGS="$NATIVE_TOOLS_CFLAGS" LDFLAGS="$NATIVE_TOOLS_LDFLAGS" \
tools_only=1 \ tools_only=1 \

View file

@ -1,6 +1,6 @@
# See pkgs/build-support/setup-hooks/role.bash # See pkgs/build-support/setup-hooks/role.bash
getHostRole getHostRole
export NIX_${role_pre}LDFLAGS+=" -lnbcompat" export NIX_LDFLAGS${role_post}+=" -lnbcompat"
export NIX_${role_pre}CFLAGS_COMPILE+=" -DHAVE_NBTOOL_CONFIG_H" export NIX_CFLAGS_COMPILE${role_post}+=" -DHAVE_NBTOOL_CONFIG_H"
export NIX_${role_pre}CFLAGS_COMPILE+=" -include nbtool_config.h" export NIX_CFLAGS_COMPILE${role_post}+=" -include nbtool_config.h"

View file

@ -1,4 +1,4 @@
# See pkgs/build-support/setup-hooks/role.bash # See pkgs/build-support/setup-hooks/role.bash
getHostRole getHostRole
export NIX_${role_pre}LDFLAGS+=" -lfts" export NIX_LDFLAGS${role_post}+=" -lfts"

View file

@ -29,8 +29,8 @@ let
"cc-version:=9999" "cc-version:=9999"
"cc-fullversion:=999999" "cc-fullversion:=999999"
# `$(..)` expanded by make alone # `$(..)` expanded by make alone
"HOSTCC:=$(BUILD_CC)" "HOSTCC:=$(CC_FOR_BUILD)"
"HOSTCXX:=$(BUILD_CXX)" "HOSTCXX:=$(CXX_FOR_BUILD)"
]; ];
# Skip clean on darwin, case-sensitivity issues. # Skip clean on darwin, case-sensitivity issues.

View file

@ -98,7 +98,7 @@ let
# TODO: This really wants to be in stdenv/darwin but we don't have hostPlatform # TODO: This really wants to be in stdenv/darwin but we don't have hostPlatform
# there (yet?) so it goes here until then. # there (yet?) so it goes here until then.
preHook = preHook+ lib.optionalString buildPlatform.isDarwin '' preHook = preHook+ lib.optionalString buildPlatform.isDarwin ''
export NIX_BUILD_DONT_SET_RPATH=1 export NIX_DONT_SET_RPATH_FOR_BUILD=1
'' + lib.optionalString (hostPlatform.isDarwin || (hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.elf && hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.macho)) '' '' + lib.optionalString (hostPlatform.isDarwin || (hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.elf && hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.macho)) ''
export NIX_DONT_SET_RPATH=1 export NIX_DONT_SET_RPATH=1
export NIX_NO_SELF_RPATH=1 export NIX_NO_SELF_RPATH=1
@ -107,7 +107,7 @@ let
# think the best solution would just be to fixup linux RPATHs so we don't # think the best solution would just be to fixup linux RPATHs so we don't
# need to set `-rpath` anywhere. # need to set `-rpath` anywhere.
# + lib.optionalString targetPlatform.isDarwin '' # + lib.optionalString targetPlatform.isDarwin ''
# export NIX_TARGET_DONT_SET_RPATH=1 # export NIX_DONT_SET_RPATH_FOR_TARGET=1
# '' # ''
; ;