Using cpp on fortran files: invalid flag warnings

I’m trying to write derivations for NCL and NCARG (GitHub - NCAR/ncl: The NCAR Command Language (NCL) is a scripting language for the analysis and visualization of climate and weather data.) on Darwin, but during the buildPhase, stdout gets flooded with errors that look like this:

f951: Warning: command line option ‘-iframework /nix/store/dg6dxwddylnccrfqpb1ag71i63a3vibm-apple-framework-ImageIO/Library/Frameworks’ is valid for C/C++/ObjC/ObjC++ but not for Fortran

I’m not positive where in the build process these are actually being generated, but my best guess so far is that it is because the build toolchain is making extensive use of the the C preprocessor, which nix has wrapped to include either NIX_TARGET_CFLAGS_COMPILE and/or NIX_CFLAGS_COMPILE (or maybe these are being included in the wrapper for gfortran?)

Wondering if anybody had any ideas how to quash these warnings (normally I wouldn’t trip about a warning, but I end up with build logs that have >50k lines of this stuff).

default.nix (note that it’s a WIP and I don’t think it’ll complete the build process successfully yet):

{ stdenv, fetchFromGitHub, cairo, gdal, gfortran, hdf4
, libjpeg, makedepend, netcdffortran, xquartz, xorg, zlib }:

let xlibs = with xorg; [ libX11 libXaw libXext libXmu libXt];
in stdenv.mkDerivation rec {
  pname = "NCL";
  version = "6.6.2";

  src = fetchFromGitHub {
    owner = "NCAR";
    repo = "ncl";
    rev = version;
    sha256 = "0ybn4f3mvqxq9k1p9bflbhq4i4yppdnssbq4rz3wigj6k17dcw4i";
  };

  buildInputs =
    [ cairo gdal gfortran hdf4 libjpeg makedepend netcdffortran xquartz zlib ] ++ xlibs;

  prePatch = ''
    echo "
    #ifdef FirstSite

    #endif /* FirstSite */

    #ifdef SecondSite

    #define YmakeRoot $out

    #define NetCDF4lib

    #define LibSearch   -Wl,-rpath

    #define BuildNCL 0

    #define CCompiler   ${gfortran}/bin/gcc
    #define FCompiler   ${gfortran}/bin/gfortran
    #define CxxCompiler ${gfortran}/bin/g++
    #define CppCommand  '${gfortran}/bin/cpp -traditional'
    #define LdCommand   ${gfortran}/bin/ld

    #endif /* SecondSite */" > config/Site.local
  '';

  patches = [ ./0001-On-no-branch-ymake-cpp.patch ];

  configurePhase = ''
    echo "Configuring for $(uname)"
    echo -e "n\n" | ./Configure
  '';

  buildPhase = "make Everything";

  phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" ];
}

I’m wondering about this too. I’m still getting this problem.

Perhaps the intersection of “fortran”, “mac”, and “nix” is the null set.