From 1ad1edbb32ce01ba8b47d8e8dad357b0edd6a4dc Mon Sep 17 00:00:00 2001 From: David McFarland Date: Sun, 30 Oct 2016 10:41:41 -0300 Subject: [PATCH] cc-wrapper: expand response files Fixes #11762 --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 2 +- pkgs/build-support/cc-wrapper/ld-wrapper.sh | 2 +- pkgs/build-support/cc-wrapper/utils.sh | 24 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 894ea95b5fa0..6287f83ed379 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -23,7 +23,7 @@ getVersion=0 nonFlagArgs=0 [[ "@prog@" = *++ ]] && isCpp=1 || isCpp=0 -params=("$@") +expandResponseParams "$@" n=0 while [ $n -lt ${#params[*]} ]; do p=${params[n]} diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index 28d73f046e68..391b5744d02a 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -16,7 +16,7 @@ source @out@/nix-support/utils.sh # Optionally filter out paths not refering to the store. -params=("$@") +expandResponseParams "$@" if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \ -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \) ]; then rest=() diff --git a/pkgs/build-support/cc-wrapper/utils.sh b/pkgs/build-support/cc-wrapper/utils.sh index 3ab512d85c4e..481d642f9674 100644 --- a/pkgs/build-support/cc-wrapper/utils.sh +++ b/pkgs/build-support/cc-wrapper/utils.sh @@ -22,3 +22,27 @@ badPath() { "${p:0:4}" != "/tmp" -a \ "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" } + +expandResponseParams() { + local inparams=("$@") + local n=0 + local p + params=() + while [ $n -lt ${#inparams[*]} ]; do + p=${inparams[n]} + case $p in + @*) + if [ -e "${p:1}" ]; then + args=$(<"${p:1}") + eval 'for arg in '$args'; do params+=("$arg"); done' + else + params+=("$p") + fi + ;; + *) + params+=("$p") + ;; + esac + n=$((n + 1)) + done +}