Merge #243595: cc-wrapper: -fwrapv instead of -fno-strict-overflow in clang

..into staging
This commit is contained in:
Vladimír Čunát 2023-07-26 11:55:59 +02:00
commit 88dec0c7a9
No known key found for this signature in database
GPG key ID: E747DF1F9575A3AA
2 changed files with 14 additions and 2 deletions

View file

@ -81,8 +81,18 @@ for flag in "${!hardeningEnableMap[@]}"; do
hardeningCFlags+=('-fPIC')
;;
strictoverflow)
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling strictoverflow >&2; fi
hardeningCFlags+=('-fno-strict-overflow')
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling strictoverflow >&2; fi
if (( @isClang@ )); then
# In Clang, -fno-strict-overflow only serves to set -fwrapv and is
# reported as an unused CLI argument if -fwrapv or -fno-wrapv is set
# explicitly, so we side step that by doing the conversion here.
#
# See: https://github.com/llvm/llvm-project/blob/llvmorg-16.0.6/clang/lib/Driver/ToolChains/Clang.cpp#L6315
#
hardeningCFlags+=('-fwrapv')
else
hardeningCFlags+=('-fno-strict-overflow')
fi
;;
format)
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling format >&2; fi

View file

@ -609,6 +609,8 @@ stdenv.mkDerivation {
env = {
inherit isClang;
# for substitution in utils.bash
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
shell = getBin shell + shell.shellPath or "";