csdms / bmi-fortran

Basic Model Interface for Fortran
https://bmi.readthedocs.io
MIT License
6 stars 10 forks source link

conda Fortran compiler fails on Windows in GitHub Actions #51

Open mdpiper opened 9 months ago

mdpiper commented 9 months ago

It may not really be the conda compiler, but CMake is reporting it failing with the following:

Run cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="$env:CONDA_PREFIX" -DCMAKE_BUILD_TYPE=Release
-- The Fortran compiler identification is Flang 99.99.1
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: C:/Users/runneradmin/micromamba/envs/testing/Library/bin/flang.exe
-- Check for working Fortran compiler: C:/Users/runneradmin/micromamba/envs/testing/Library/bin/flang.exe - broken
CMake Error at C:/Users/runneradmin/micromamba/envs/testing/Library/share/cmake-3.27/Modules/CMakeTestFortranCompiler.cmake:59 (message):
-- Configuring incomplete, errors occurred!
  The Fortran compiler

    "C:/Users/runneradmin/micromamba/envs/testing/Library/bin/flang.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'D:/a/bmi-fortran/bmi-fortran/build/CMakeFiles/CMakeScratch/TryCompile-5dt14k'

    Run Build Command(s): C:/Users/runneradmin/micromamba/envs/testing/Library/bin/cmake.exe -E env VERBOSE=1 nmake -f Makefile /nologo cmTC_a633f\fast
        "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\nmake.exe"  -f CMakeFiles\cmTC_a633f.dir\build.make /nologo -L                  CMakeFiles\cmTC_a633f.dir\build
    Building Fortran object CMakeFiles/cmTC_a633f.dir/testFortranCompiler.f.obj
        C:\Users\runneradmin\micromamba\envs\testing\Library\bin\flang.exe     -o CMakeFiles\cmTC_a633f.dir\testFortranCompiler.f.obj -c D:\a\bmi-fortran\bmi-fortran\build\CMakeFiles\CMakeScratch\TryCompile-5dt14k\testFortranCompiler.f
    Linking Fortran executable cmTC_a633f.exe
        C:\Users\runneradmin\micromamba\envs\testing\Library\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_a633f.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt="" --manifests -- link /nologo @CMakeFiles\cmTC_a633f.dir\objects1.rsp @C:\Users\RUNNER~1\AppData\Local\Temp\nm4918.tmp
    Visual Studio Incremental Link with embedded manifests
    Create CMakeFiles\cmTC_a633f.dir/manifest.rc
    Create empty: CMakeFiles\cmTC_a633f.dir/embed.manifest
    RC Pass 1:
    C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe /fo CMakeFiles\cmTC_a633f.dir/manifest.res CMakeFiles\cmTC_a633f.dir/manifest.rc
    LINK Pass 1:
    link /nologo @CMakeFiles\cmTC_a633f.dir\objects1.rsp /out:cmTC_a633f.exe /implib:cmTC_a633f.lib /pdb:D:\a\bmi-fortran\bmi-fortran\build\CMakeFiles\CMakeScratch\TryCompile-5dt14k\cmTC_a633f.pdb /version:0.0 /debug /INCREMENTAL /subsystem:console /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_a633f.dir/intermediate.manifest CMakeFiles\cmTC_a633f.dir/manifest.res
    LINK Pass 1: command "link /nologo @CMakeFiles\cmTC_a633f.dir\objects1.rsp /out:cmTC_a633f.exe /implib:cmTC_a633f.lib /pdb:D:\a\bmi-fortran\bmi-fortran\build\CMakeFiles\CMakeScratch\TryCompile-5dt14k\cmTC_a633f.pdb /version:0.0 /debug /INCREMENTAL /subsystem:console /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_a633f.dir/intermediate.manifest CMakeFiles\cmTC_a633f.dir/manifest.res" failed (exit code 1) with the following output:
    link: extra operand '/out:cmTC_a633f.exe'
    Try 'link --help' for more information.
    NMAKE : fatal error U1077: 'C:\Users\runneradmin\micromamba\envs\testing\Library\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_a633f.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt="" --manifests -- link /nologo @CMakeFiles\cmTC_a633f.dir\objects1.rsp @C:\Users\RUNNER~1\AppData\Local\Temp\nm4918.tmp' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\nmake.exe"  -f CMakeFiles\cmTC_a633f.dir\build.make /nologo -L                  CMakeFiles\cmTC_a633f.dir\build' : return code '0x2'
    Stop.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

NMAKE : fatal error U1052: file 'Makefile' not found
Stop.
Error: Process completed with exit code 1.
mdpiper commented 9 months ago

Works fine on GitHub Actions with Linux and macOS. It also works fine when I build locally on my Microsoft Surface.

mdpiper commented 9 months ago

There is a version of gfortran installed on Windows on Actions by chocolatey. It works:

Run cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="$env:CONDA_PREFIX" -DCMAKE_BUILD_TYPE=Release
-- The Fortran compiler identification is GNU 12.2.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/ProgramData/chocolatey/bin/gfortran.exe - skipped
-- Configuring done (7.1s)
-- Generating done (0.0s)
-- Build files have been written to: D:/a/bmi-fortran/bmi-fortran/build
[ 25%] Building Fortran object CMakeFiles/bmif_static.dir/bmi.f90.obj
[ 50%] Linking Fortran static library libbmif.a
[ 50%] Built target bmif_static
[ 75%] Building Fortran object CMakeFiles/bmif_shared.dir/bmi.f90.obj
[100%] Linking Fortran shared library libbmif_win.dll
[100%] Built target bmif_shared
Install the project...
-- Install configuration: "Release"
-- Installing: C:/Users/runneradmin/micromamba/envs/testing/lib/libbmif.a
-- Installing: C:/Users/runneradmin/micromamba/envs/testing/lib/libbmif_win.dll.a
-- Installing: C:/Users/runneradmin/micromamba/envs/testing/bin/libbmif_win.dll
-- Installing: C:/Users/runneradmin/micromamba/envs/testing/include/bmif_2_0.mod