Skip to content

Commit

Permalink
cc-wrapper: set FC when langFortran is on
Browse files Browse the repository at this point in the history
We need to set FC so that CMake and other tools can find the fortran
compiler. Also we need to limit the hardening flags since fortify and
format don’t work with fortran.

Fixes #88449
  • Loading branch information
matthewbauer committed Jul 6, 2020
1 parent 4855aa6 commit f42aa7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkgs/build-support/cc-wrapper/default.nix
Expand Up @@ -214,6 +214,7 @@ stdenv.mkDerivation {
wrap ${targetPrefix}gfortran $wrapper $ccPath/${targetPrefix}gfortran
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}f77
export named_fc=${targetPrefix}gfortran
''

+ optionalString cc.langJava or false ''
Expand All @@ -232,8 +233,8 @@ stdenv.mkDerivation {

setupHooks = [
../setup-hooks/role.bash
./setup-hook.sh
];
] ++ stdenv.lib.optional (cc.langC or true) ./setup-hook.sh
++ stdenv.lib.optional (cc.langFortran or false) ./fortran-hook.sh;

postFixup =
''
Expand Down
11 changes: 11 additions & 0 deletions pkgs/build-support/cc-wrapper/fortran-hook.sh
@@ -0,0 +1,11 @@
getTargetRole
getTargetRoleWrapper

export FC${role_post}=@named_fc@

# If unset, assume the default hardening flags.
# These are different for fortran.
: ${NIX_HARDENING_ENABLE="stackprotector pic strictoverflow relro bindnow"}
export NIX_HARDENING_ENABLE

unset -v role_post

0 comments on commit f42aa7e

Please sign in to comment.