diff options
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r-- | pkgs/build-support/cc-wrapper/add-hardening.sh | 22 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/cc-wrapper.sh | 6 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 7 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/gnat-wrapper.sh | 6 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh | 6 | ||||
-rwxr-xr-x | pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh | 4 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/ld-wrapper.sh | 6 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/utils.sh | 2 |
8 files changed, 40 insertions, 19 deletions
diff --git a/pkgs/build-support/cc-wrapper/add-hardening.sh b/pkgs/build-support/cc-wrapper/add-hardening.sh index 34358e04194a..b0e39e455ffc 100644 --- a/pkgs/build-support/cc-wrapper/add-hardening.sh +++ b/pkgs/build-support/cc-wrapper/add-hardening.sh @@ -16,14 +16,14 @@ do hardeningDisableMap[$flag]=1 done -if [[ -n "${NIX_DEBUG:-}" ]]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then printf 'HARDENING: disabled flags:' >&2 (( "${#hardeningDisableMap[@]}" )) && printf ' %q' "${!hardeningDisableMap[@]}" >&2 echo >&2 fi if [[ -z "${hardeningDisableMap[all]:-}" ]]; then - if [[ -n "${NIX_DEBUG:-}" ]]; then + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo 'HARDENING: Is active (not completely disabled with "all" flag)' >&2; fi for flag in "${hardeningFlags[@]}" @@ -31,40 +31,40 @@ if [[ -z "${hardeningDisableMap[all]:-}" ]]; then if [[ -z "${hardeningDisableMap[$flag]:-}" ]]; then case $flag in fortify) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling fortify >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling fortify >&2; fi hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2') ;; stackprotector) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling stackprotector >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling stackprotector >&2; fi hardeningCFlags+=('-fstack-protector-strong' '--param' 'ssp-buffer-size=4') ;; pie) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling CFlags -fPIE >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling CFlags -fPIE >&2; fi hardeningCFlags+=('-fPIE') if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling LDFlags -pie >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi hardeningCFlags+=('-pie') hardeningLDFlags+=('-pie') fi ;; pic) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling pic >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling pic >&2; fi hardeningCFlags+=('-fPIC') ;; strictoverflow) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling strictoverflow >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling strictoverflow >&2; fi hardeningCFlags+=('-fno-strict-overflow') ;; format) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling format >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling format >&2; fi hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security') ;; relro) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling relro >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling relro >&2; fi hardeningLDFlags+=('-z' 'relro') ;; bindnow) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling bindnow >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling bindnow >&2; fi hardeningLDFlags+=('-z' 'now') ;; *) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index aacaf196f313..e6f5a5a9f7d8 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + path_backup="$PATH" # That @-vars are substituted separately from bash evaluation makes @@ -161,7 +165,7 @@ if [ "$*" = -v ]; then fi # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then # Old bash workaround, see ld-wrapper for explanation. echo "extra flags before to @prog@:" >&2 printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 866be9cded9e..489fb02dcb5d 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -5,15 +5,15 @@ # script that sets up the right environment variables so that the # compiler and the linker just "work". -{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" -, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell +{ name ? "", stdenvNoCC, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" +, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenvNoCC.shell , zlib ? null, extraPackages ? [], extraBuildCommands ? "" , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , buildPackages ? {} , useMacosReexportHack ? false }: -with stdenv.lib; +with stdenvNoCC.lib; assert nativeTools -> nativePrefix != ""; assert !nativeTools -> @@ -25,6 +25,7 @@ assert (noLibc || nativeLibc) == (libc == null); assert cc.langVhdl or false -> zlib != null; let + stdenv = stdenvNoCC; inherit (stdenv) hostPlatform targetPlatform; # Prefix for binaries. Customarily ends with a dash separator. diff --git a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh index f0c922a3d5b4..b15f1e461e5f 100644 --- a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + # N.B. Gnat is not used during bootstrapping, so we don't need to # worry about the old bash empty array `set -u` workarounds. @@ -109,7 +113,7 @@ fi #fi # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "extra flags before to @prog@:" >&2 printf " %q\n" "${extraBefore[@]}" >&2 echo "original flags to @prog@:" >&2 diff --git a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh index 2de748b5f31e..88e644dc54dc 100644 --- a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + # N.B. Gnat is not used during bootstrapping, so we don't need to # worry about the old bash empty array `set -u` workarounds. @@ -24,7 +28,7 @@ extraBefore=() #export NIX_@infixSalt@_LDFLAGS_SET=1 # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "extra flags before to @prog@:" >&2 printf " %q\n" "${extraBefore[@]}" >&2 echo "original flags to @prog@:" >&2 diff --git a/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh index 72c999ff8bc8..5d81e34a047f 100755 --- a/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + declare -a args=("$@") # I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'( # Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3 diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index a9cc1e3f9e6f..355ea8818981 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + path_backup="$PATH" # phase separation makes this look useless @@ -156,7 +160,7 @@ fi # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then # Old bash workaround, see above. echo "extra flags before to @prog@:" >&2 printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 diff --git a/pkgs/build-support/cc-wrapper/utils.sh b/pkgs/build-support/cc-wrapper/utils.sh index c84a094e26b0..c43c2e12d74a 100644 --- a/pkgs/build-support/cc-wrapper/utils.sh +++ b/pkgs/build-support/cc-wrapper/utils.sh @@ -1,5 +1,5 @@ skip () { - if [ -n "${NIX_DEBUG:-}" ]; then + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "skipping impure path $1" >&2 fi } |