cc-wrapper: fortran: enable stackprotector on M1

Was failing due to https://github.com/iains/gcc-darwin-arm64/issues/54,
fix picked up in https://github.com/NixOS/nixpkgs/pull/186477.
This commit is contained in:
Theodore Ni 2022-08-19 00:08:11 -07:00
parent 5b76f42372
commit 1f6366d38c
No known key found for this signature in database
GPG Key ID: 48B67583BDDD4474
2 changed files with 2 additions and 9 deletions

View File

@ -251,19 +251,12 @@ stdenv.mkDerivation {
wrap ${targetPrefix}gdc $wrapper $ccPath/${targetPrefix}gdc wrap ${targetPrefix}gdc $wrapper $ccPath/${targetPrefix}gdc
'' ''
+ optionalString cc.langFortran or false ('' + optionalString cc.langFortran or false ''
wrap ${targetPrefix}gfortran $wrapper $ccPath/${targetPrefix}gfortran wrap ${targetPrefix}gfortran $wrapper $ccPath/${targetPrefix}gfortran
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77 ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}f77 ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}f77
export named_fc=${targetPrefix}gfortran export named_fc=${targetPrefix}gfortran
'' ''
# Darwin aarch64 fortran compilations seem to fail otherwise, see:
# https://github.com/NixOS/nixpkgs/issues/140041
+ (if (stdenvNoCC.isDarwin && stdenvNoCC.isAarch64) then ''
export fortran_hardening="pic strictoverflow relro bindnow"
'' else ''
export fortran_hardening="pic strictoverflow relro bindnow stackprotector"
''))
+ optionalString cc.langJava or false '' + optionalString cc.langJava or false ''
wrap ${targetPrefix}gcj $wrapper $ccPath/${targetPrefix}gcj wrap ${targetPrefix}gcj $wrapper $ccPath/${targetPrefix}gcj

View File

@ -5,7 +5,7 @@ export FC${role_post}=@named_fc@
# If unset, assume the default hardening flags. # If unset, assume the default hardening flags.
# These are different for fortran. # These are different for fortran.
: ${NIX_HARDENING_ENABLE="@fortran_hardening@"} : ${NIX_HARDENING_ENABLE="stackprotector pic strictoverflow relro bindnow"}
export NIX_HARDENING_ENABLE export NIX_HARDENING_ENABLE
unset -v role_post unset -v role_post