cc-wrapper: Use stderr for NIX_DEBUG output

Otherwise configure scripts might break when looking for the path to ld
This commit is contained in:
Tristan Helmich 2016-03-10 15:47:55 +01:00
parent 514a478e61
commit 7e2e0dfe7a

View File

@ -14,43 +14,43 @@ if [[ ! $hardeningDisable == "all" ]]; then
if [[ ! "${hardeningDisable[@]}" =~ "$flag" ]]; then if [[ ! "${hardeningDisable[@]}" =~ "$flag" ]]; then
case $flag in case $flag in
fortify) fortify)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling fortify; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling fortify >&2; fi
hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2') hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2')
;; ;;
stackprotector) stackprotector)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling stackprotector; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling stackprotector >&2; fi
hardeningCFlags+=('-fstack-protector-strong' '--param ssp-buffer-size=4') hardeningCFlags+=('-fstack-protector-strong' '--param ssp-buffer-size=4')
;; ;;
pie) pie)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling CFlags -fPIE; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling CFlags -fPIE >&2; fi
hardeningCFlags+=('-fPIE') hardeningCFlags+=('-fPIE')
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling LDFlags -pie; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling LDFlags -pie >&2; fi
hardeningLDFlags+=('-pie') hardeningLDFlags+=('-pie')
fi fi
;; ;;
pic) pic)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling pic; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling pic >&2; fi
hardeningCFlags+=('-fPIC') hardeningCFlags+=('-fPIC')
;; ;;
strictoverflow) strictoverflow)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling strictoverflow; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling strictoverflow >&2; fi
hardeningCFlags+=('-fno-strict-overflow') hardeningCFlags+=('-fno-strict-overflow')
;; ;;
format) format)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling format; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling format >&2; fi
hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security') hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security')
;; ;;
relro) relro)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling relro; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling relro >&2; fi
hardeningLDFlags+=('-z relro') hardeningLDFlags+=('-z relro')
;; ;;
bindnow) bindnow)
if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling bindnow; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling bindnow >&2; fi
hardeningLDFlags+=('-z now') hardeningLDFlags+=('-z now')
;; ;;
*) *)
echo "Hardening flag unknown: $flag" echo "Hardening flag unknown: $flag" >&2
;; ;;
esac esac
fi fi