2004-03-30 14:46:52 +02:00
|
|
|
#! @shell@ -e
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
|
|
|
|
. "$NIX_GCC_WRAPPER_START_HOOK"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -z "$NIX_GLIBC_FLAGS_SET"; then
|
2004-03-09 18:08:41 +01:00
|
|
|
. @out@/nix-support/add-flags
|
2004-03-08 17:02:46 +01:00
|
|
|
fi
|
|
|
|
|
2004-03-12 12:12:18 +01:00
|
|
|
. @out@/nix-support/utils
|
|
|
|
|
2004-03-08 19:29:08 +01:00
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
# Figure out if linker flags should be passed. GCC prints annoying
|
|
|
|
# warnings when they are not needed.
|
|
|
|
dontLink=0
|
2004-03-09 18:08:41 +01:00
|
|
|
if test "$*" = "-v" -o -z "$*"; then
|
2004-03-08 17:02:46 +01:00
|
|
|
dontLink=1
|
2004-03-12 12:12:18 +01:00
|
|
|
else
|
2004-03-08 17:02:46 +01:00
|
|
|
for i in "$@"; do
|
|
|
|
if test "$i" = "-c"; then
|
|
|
|
dontLink=1
|
|
|
|
elif test "$i" = "-S"; then
|
|
|
|
dontLink=1
|
|
|
|
elif test "$i" = "-E"; then
|
|
|
|
dontLink=1
|
|
|
|
elif test "$i" = "-E"; then
|
|
|
|
dontLink=1
|
|
|
|
elif test "$i" = "-M"; then
|
|
|
|
dontLink=1
|
|
|
|
elif test "$i" = "-MM"; then
|
|
|
|
dontLink=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2004-03-08 19:29:08 +01:00
|
|
|
|
|
|
|
# Optionally filter out paths not refering to the store.
|
|
|
|
params=("$@")
|
2004-03-12 12:12:18 +01:00
|
|
|
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
|
2004-03-08 19:29:08 +01:00
|
|
|
rest=()
|
|
|
|
n=0
|
|
|
|
while test $n -lt ${#params[*]}; do
|
|
|
|
p=${params[n]}
|
|
|
|
p2=${params[$((n+1))]}
|
2004-03-11 18:26:14 +01:00
|
|
|
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
|
2004-03-08 19:29:08 +01:00
|
|
|
skip $p
|
2004-03-11 18:26:14 +01:00
|
|
|
elif test "$p" = "-L" && badPath "$p2"; then
|
2004-03-08 19:29:08 +01:00
|
|
|
n=$((n + 1)); skip $p2
|
2004-03-11 18:26:14 +01:00
|
|
|
elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
|
2004-03-08 19:29:08 +01:00
|
|
|
skip $p
|
2004-03-11 18:26:14 +01:00
|
|
|
elif test "$p" = "-I" && badPath "$p2"; then
|
2004-03-08 19:29:08 +01:00
|
|
|
n=$((n + 1)); skip $p2
|
2004-03-11 18:26:14 +01:00
|
|
|
elif test "$p" = "-isystem" && badPath "$p2"; then
|
2004-03-08 19:29:08 +01:00
|
|
|
n=$((n + 1)); skip $p2
|
|
|
|
else
|
|
|
|
rest=("${rest[@]}" "$p")
|
|
|
|
fi
|
|
|
|
n=$((n + 1))
|
|
|
|
done
|
|
|
|
params=("${rest[@]}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
# Add the flags for the C compiler proper.
|
2004-11-22 17:36:27 +01:00
|
|
|
extraAfter=($NIX_CFLAGS_COMPILE)
|
|
|
|
extraBefore=()
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
if test "$dontLink" != "1"; then
|
|
|
|
|
|
|
|
# Add the flags that should only be passed to the compiler when
|
|
|
|
# linking.
|
2004-11-22 17:36:27 +01:00
|
|
|
extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
# Add the flags that should be passed to the linker (and prevent
|
|
|
|
# `ld-wrapper' from adding NIX_LDFLAGS again).
|
2004-11-22 17:36:27 +01:00
|
|
|
for i in $NIX_LDFLAGS_BEFORE; do
|
|
|
|
extraBefore=(${extraBefore[@]} "-Wl,$i")
|
|
|
|
done
|
2004-03-08 17:02:46 +01:00
|
|
|
for i in $NIX_LDFLAGS; do
|
2005-06-17 11:23:15 +02:00
|
|
|
if test "${i:0:3}" = "-L/"; then
|
|
|
|
extraAfter=(${extraAfter[@]} "$i")
|
|
|
|
else
|
|
|
|
extraAfter=(${extraAfter[@]} "-Wl,$i")
|
|
|
|
fi
|
2004-03-08 17:02:46 +01:00
|
|
|
done
|
|
|
|
export NIX_LDFLAGS_SET=1
|
|
|
|
|
|
|
|
if test "$NIX_STRIP_DEBUG" = "1"; then
|
|
|
|
# Add executable-stripping flags.
|
2004-11-22 17:36:27 +01:00
|
|
|
extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
|
2004-03-08 17:02:46 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Optionally print debug info.
|
|
|
|
if test "$NIX_DEBUG" = "1"; then
|
2005-02-22 15:32:56 +01:00
|
|
|
echo "original flags to @gccProg@:" >&2
|
2004-03-08 19:29:08 +01:00
|
|
|
for i in "${params[@]}"; do
|
2004-03-08 17:02:46 +01:00
|
|
|
echo " $i" >&2
|
|
|
|
done
|
2005-02-22 15:32:56 +01:00
|
|
|
echo "extraBefore flags to @gccProg@:" >&2
|
2004-11-22 17:36:27 +01:00
|
|
|
for i in ${extraBefore[@]}; do
|
|
|
|
echo " $i" >&2
|
|
|
|
done
|
2005-02-22 15:32:56 +01:00
|
|
|
echo "extraAfter flags to @gccProg@:" >&2
|
2004-11-22 17:36:27 +01:00
|
|
|
for i in ${extraAfter[@]}; do
|
2004-03-08 17:02:46 +01:00
|
|
|
echo " $i" >&2
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
|
|
|
|
. "$NIX_GCC_WRAPPER_EXEC_HOOK"
|
|
|
|
fi
|
|
|
|
|
2005-06-17 11:23:15 +02:00
|
|
|
res=0
|
|
|
|
@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 2> $NIX_BUILD_TOP/.gcc.errors || res=$?
|
|
|
|
grep -v 'file path prefix' < $NIX_BUILD_TOP/.gcc.errors >&2 || true
|
|
|
|
exit $res
|