gcc-wrapper: Style fix

This commit is contained in:
Eelco Dolstra 2014-10-10 14:25:23 +02:00
parent ffbdcbfe29
commit 02122ccfd0
7 changed files with 94 additions and 94 deletions

View File

@ -1,27 +1,27 @@
# `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld.
export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE"
if test -e @out@/nix-support/libc-cflags; then
if [ -e @out@/nix-support/libc-cflags ]; then
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
fi
if test -e @out@/nix-support/gcc-cflags; then
if [ -e @out@/nix-support/gcc-cflags ]; then
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE"
fi
if test -e @out@/nix-support/gnat-cflags; then
if [ -e @out@/nix-support/gnat-cflags ]; then
export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE"
fi
if test -e @out@/nix-support/libc-ldflags; then
if [ -e @out@/nix-support/libc-ldflags ]; then
export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)"
fi
if test -e @out@/nix-support/gcc-ldflags; then
if [ -e @out@/nix-support/gcc-ldflags ]; then
export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)"
fi
if test -e @out@/nix-support/libc-ldflags-before; then
if [ -e @out@/nix-support/libc-ldflags-before ]; then
export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE"
fi

View File

@ -1,10 +1,10 @@
#! @shell@ -e
if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
if [ -n "$NIX_GCC_WRAPPER_START_HOOK" ]; then
source "$NIX_GCC_WRAPPER_START_HOOK"
fi
if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
if [ -z "$NIX_GCC_WRAPPER_FLAGS_SET" ]; then
source @out@/nix-support/add-flags.sh
fi
@ -18,26 +18,26 @@ getVersion=0
nonFlagArgs=0
for i in "$@"; do
if test "$i" = "-c"; then
if [ "$i" = -c ]; then
dontLink=1
elif test "$i" = "-S"; then
elif [ "$i" = -S ]; then
dontLink=1
elif test "$i" = "-E"; then
elif [ "$i" = -E ]; then
dontLink=1
elif test "$i" = "-E"; then
elif [ "$i" = -E ]; then
dontLink=1
elif test "$i" = "-M"; then
elif [ "$i" = -M ]; then
dontLink=1
elif test "$i" = "-MM"; then
elif [ "$i" = -MM ]; then
dontLink=1
elif test "$i" = "-x"; then
elif [ "$i" = -x ]; then
# At least for the cases c-header or c++-header we should set dontLink.
# I expect no one use -x other than making precompiled headers.
dontLink=1
elif test "${i:0:1}" != "-"; then
elif [ "${i:0:1}" != - ]; then
nonFlagArgs=1
elif test "$i" = "-m32"; then
if test -e @out@/nix-support/dynamic-linker-m32; then
elif [ "$i" = -m32 ]; then
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
fi
fi
@ -48,28 +48,28 @@ done
# "-c" flag). So if no non-flag arguments are given, don't pass any
# linker flags. This catches cases like "gcc" (should just print
# "gcc: no input files") and "gcc -v" (should print the version).
if test "$nonFlagArgs" = "0"; then
if [ "$nonFlagArgs" = 0 ]; then
dontLink=1
fi
# Optionally filter out paths not refering to the store.
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then
rest=()
n=0
while test $n -lt ${#params[*]}; do
while [ $n -lt ${#params[*]} ]; do
p=${params[n]}
p2=${params[$((n+1))]}
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
skip $p
elif test "$p" = "-L" && badPath "$p2"; then
elif [ "$p" = -L ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then
skip $p
elif test "$p" = "-I" && badPath "$p2"; then
elif [ "$p" = -I ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-isystem" && badPath "$p2"; then
elif [ "$p" = -isystem ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
else
rest=("${rest[@]}" "$p")
@ -86,14 +86,14 @@ extraBefore=()
# When enforcing purity, pretend gcc can't find the current date and
# time
if test "$NIX_ENFORCE_PURITY" = "1"; then
if [ "$NIX_ENFORCE_PURITY" = 1 ]; then
extraAfter+=('-D__DATE__="Jan 01 1970"'
'-D__TIME__="00:00:01"'
-Wno-builtin-macro-redefined)
fi
if test "$dontLink" != "1"; then
if [ "$dontLink" != 1 ]; then
# Add the flags that should only be passed to the compiler when
# linking.
@ -105,11 +105,11 @@ if test "$dontLink" != "1"; then
extraBefore=(${extraBefore[@]} "-Wl,$i")
done
for i in $NIX_LDFLAGS; do
if test "${i:0:3}" = "-L/"; then
extraAfter+=("$i")
else
extraAfter+=("-Wl,$i")
fi
if [ "${i:0:3}" = -L/ ]; then
extraAfter+=("$i")
else
extraAfter+=("-Wl,$i")
fi
done
export NIX_LDFLAGS_SET=1
fi
@ -118,13 +118,13 @@ fi
# add anything. This is to prevent `gcc -v' (which normally prints
# out the version number and returns exit code 0) from printing out
# `No input files specified' and returning exit code 1.
if test "$*" = "-v"; then
if [ "$*" = -v ]; then
extraAfter=()
extraBefore=()
fi
fi
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
if [ -n "$NIX_DEBUG" ]; then
echo "original flags to @prog@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
@ -139,7 +139,7 @@ if test "$NIX_DEBUG" = "1"; then
done
fi
if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
if [ -n "$NIX_GCC_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_GCC_WRAPPER_EXEC_HOOK"
fi

View File

@ -1,10 +1,10 @@
#! @shell@ -e
if test -n "$NIX_GNAT_WRAPPER_START_HOOK"; then
if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then
source "$NIX_GNAT_WRAPPER_START_HOOK"
fi
if test -z "$NIX_GNAT_WRAPPER_FLAGS_SET"; then
if [ -z "$NIX_GNAT_WRAPPER_FLAGS_SET" ]; then
source @out@/nix-support/add-flags.sh
fi
@ -18,14 +18,14 @@ getVersion=0
nonFlagArgs=0
for i in "$@"; do
if test "$i" = "-c"; then
if [ "$i" = -c ]; then
dontLink=1
elif test "$i" = "-M"; then
elif [ "$i" = -M ]; then
dontLink=1
elif test "${i:0:1}" != "-"; then
elif [ "${i:0:1}" != - ]; then
nonFlagArgs=1
elif test "$i" = "-m32"; then
if test -e @out@/nix-support/dynamic-linker-m32; then
elif [ "$i" = -m32 ]; then
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
fi
fi
@ -36,26 +36,26 @@ done
# "-c" flag). So if no non-flag arguments are given, don't pass any
# linker flags. This catches cases like "gcc" (should just print
# "gcc: no input files") and "gcc -v" (should print the version).
if test "$nonFlagArgs" = "0"; then
if [ "$nonFlagArgs" = 0 ]; then
dontLink=1
fi
# Optionally filter out paths not refering to the store.
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then
rest=()
n=0
while test $n -lt ${#params[*]}; do
while [ $n -lt ${#params[*]} ]; do
p=${params[n]}
p2=${params[$((n+1))]}
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
skip $p
elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then
skip $p
elif test "${p:0:4}" = "-aI/" && badPath "${p:3}"; then
elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then
skip $p
elif test "${p:0:4}" = "-aO/" && badPath "${p:3}"; then
elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then
skip $p
else
rest=("${rest[@]}" "$p")
@ -81,7 +81,7 @@ fi
#done
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
if [ -n "$NIX_DEBUG" ]; then
echo "original flags to @prog@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
@ -96,7 +96,7 @@ if test "$NIX_DEBUG" = "1"; then
done
fi
if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then
if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
fi

View File

@ -11,7 +11,7 @@ extraBefore=()
#done
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
if [ -n "$NIX_DEBUG" ]; then
echo "original flags to @prog@:" >&2
for i in "$@"; do
echo " $i" >&2
@ -26,7 +26,7 @@ if test "$NIX_DEBUG" = "1"; then
done
fi
if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then
if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
fi

View File

@ -1,10 +1,10 @@
#! @shell@ -e
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then
source "$NIX_LD_WRAPPER_START_HOOK"
fi
if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
if [ -z "$NIX_GCC_WRAPPER_FLAGS_SET" ]; then
source @out@/nix-support/add-flags.sh
fi
@ -13,26 +13,26 @@ source @out@/nix-support/utils.sh
# Optionally filter out paths not refering to the store.
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
-a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \
-a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \) ]; then
rest=()
n=0
while test $n -lt ${#params[*]}; do
while [ $n -lt ${#params[*]} ]; do
p=${params[n]}
p2=${params[$((n+1))]}
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
skip $p
elif test "$p" = "-L" && badPath "$p2"; then
elif [ "$p" = -L ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-rpath" && badPath "$p2"; then
elif [ "$p" = -rpath ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
elif [ "$p" = -dynamic-linker ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "${p:0:1}" = "/" && badPath "$p"; then
elif [ "${p:0:1}" = / ] && badPath "$p"; then
# We cannot skip this; barf.
echo "impure path \`$p' used in link" >&2
exit 1
elif test "${p:0:9}" = "--sysroot"; then
elif [ "${p:0:9}" = --sysroot ]; then
# Our ld is not built with sysroot support (Can we fix that?)
:
else
@ -47,7 +47,7 @@ fi
extra=()
extraBefore=()
if test -z "$NIX_LDFLAGS_SET"; then
if [ -z "$NIX_LDFLAGS_SET" ]; then
extra+=($NIX_LDFLAGS)
extraBefore+=($NIX_LDFLAGS_BEFORE)
fi
@ -56,12 +56,12 @@ extra+=($NIX_LDFLAGS_AFTER)
# Add all used dynamic libraries to the rpath.
if test "$NIX_DONT_SET_RPATH" != "1"; then
if [ "$NIX_DONT_SET_RPATH" != 1 ]; then
libPath=""
addToLibPath() {
local path="$1"
if test "${path:0:1}" != "/"; then return 0; fi
if [ "${path:0:1}" != / ]; then return 0; fi
case "$path" in
*..*|*./*|*/.*|*//*)
local path2
@ -75,12 +75,12 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
esac
libPath="$libPath $path "
}
addToRPath() {
# If the path is not in the store, don't add it to the rpath.
# This typically happens for libraries in /tmp that are later
# copied to $out/lib. If not, we're screwed.
if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
if [ "${1:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then return 0; fi
case $rpath in
*\ $1\ *) return 0 ;;
esac
@ -97,21 +97,21 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
# First, find all -L... switches.
allParams=("${params[@]}" ${extra[@]})
n=0
while test $n -lt ${#allParams[*]}; do
while [ $n -lt ${#allParams[*]} ]; do
p=${allParams[n]}
p2=${allParams[$((n+1))]}
if test "${p:0:3}" = "-L/"; then
if [ "${p:0:3}" = -L/ ]; then
addToLibPath ${p:2}
elif test "$p" = "-L"; then
elif [ "$p" = -L ]; then
addToLibPath ${p2}
n=$((n + 1))
elif test "$p" = "-l"; then
elif [ "$p" = -l ]; then
addToLibs ${p2}
n=$((n + 1))
elif test "${p:0:2}" = "-l"; then
elif [ "${p:0:2}" = -l ]; then
addToLibs ${p:2}
elif test "$p" = "-dynamic-linker"; then
# Ignore the dynamic linker argument, or it
elif [ "$p" = -dynamic-linker ]; then
# Ignore the dynamic linker argument, or it
# will get into the next 'elif'. We don't want
# the dynamic linker path rpath to go always first.
n=$((n + 1))
@ -129,16 +129,16 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
# so, add the directory to the rpath.
# It's important to add the rpath in the order of -L..., so
# the link time chosen objects will be those of runtime linking.
for i in $libPath; do
for j in $libs; do
if test -f "$i/lib$j.so"; then
if [ -f "$i/lib$j.so" ]; then
addToRPath $i
break
fi
done
done
# Finally, add `-rpath' switches.
for i in $rpath; do
@ -148,7 +148,7 @@ fi
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
if [ -n "$NIX_DEBUG" ]; then
echo "original flags to @prog@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
@ -159,7 +159,7 @@ if test "$NIX_DEBUG" = "1"; then
done
fi
if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_LD_WRAPPER_EXEC_HOOK"
fi

View File

@ -1,15 +1,15 @@
export NIX_GCC=@out@
addCVars () {
if test -d $1/include; then
if [ -d $1/include ]; then
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include"
fi
if test -d $1/lib64; then
if [ -d $1/lib64 -a ! -L $1/lib64 ]; then
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64"
fi
if test -d $1/lib; then
if [ -d $1/lib ]; then
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib"
fi
}
@ -18,18 +18,18 @@ envHooks+=(addCVars)
# Note: these come *after* $out in the PATH (see setup.sh).
if test -n "@gcc@"; then
if [ -n "@gcc@" ]; then
addToSearchPath PATH @gcc@/bin
fi
if test -n "@binutils@"; then
if [ -n "@binutils@" ]; then
addToSearchPath PATH @binutils@/bin
fi
if test -n "@libc@"; then
if [ -n "@libc@" ]; then
addToSearchPath PATH @libc@/bin
fi
if test -n "@coreutils@"; then
if [ -n "@coreutils@" ]; then
addToSearchPath PATH @coreutils@/bin
fi

View File

@ -1,5 +1,5 @@
skip () {
if test "$NIX_DEBUG" = "1"; then
if [ -n "$NIX_DEBUG" ]; then
echo "skipping impure path $1" >&2
fi
}
@ -9,11 +9,11 @@ skip () {
# `/nix/store/.../lib/foo.so' isn't.
badPath() {
local p=$1
# Relative paths are okay (since they're presumably relative to
# the temporary build directory).
if test "${p:0:1}" != "/"; then return 1; fi
if [ "${p:0:1}" != / ]; then return 1; fi
# Otherwise, the path should refer to the store or some temporary
# directory (including the build directory).
test \