CMake Fortran test fails
Created by: teamblubee
@trilinos/
Expectations
Current Behavior
I am trying to use the Ninja generator to compile Trilinos using the newly open source Fortran compiler; Flang: https://github.com/flang-compiler/flang
The cmake test fails
Probing the environment ...
-- USE_XSDK_DEFAULTS='FALSE'
-- BUILD_SHARED_LIBS='FALSE'
-- CMAKE_BUILD_TYPE='RELEASE'
-- CMAKE_C_COMPILER_ID='Clang'
-- CMAKE_C_COMPILER_VERSION='5.0.1'
-- CMAKE_CXX_COMPILER_ID='Clang'
-- CMAKE_CXX_COMPILER_VERSION='5.0.1'
-- The Fortran compiler identification is Flang 99.99.1
-- Check for working Fortran compiler: /usr/local/bin/flang
-- Check for working Fortran compiler: /usr/local/bin/flang -- broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestFortranCompiler.cmake:45 (message):
The Fortran compiler
"/usr/local/bin/flang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /wrkdirs/usr/ports/math/trilinos/work/.build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/local/bin/ninja" "cmTC_2dfa4"
[1/4] Building Fortran preprocessed CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f
FAILED: CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f.ddi
/usr/local/bin/flang -cpp -E testFortranCompiler.f -o CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f && /usr/local/bin/cmake -E cmake_ninja_depends --tdi=CMakeFiles/cmTC_2dfa4.dir/FortranDependInfo.json --pp=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f --dep=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f.d --obj=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f.o --ddi=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f.ddi
# 1 "testFortranCompiler.f"
# 2 "testFortranCompiler.f"
PROGRAM TESTFortran
PRINT *, 'Hello'
END
CMake Error: -E cmake_ninja_depends failed to open CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake:1830 (ENABLE_LANGUAGE)
cmake/tribits/core/package_arch/TribitsProjectImpl.cmake:188 (TRIBITS_SETUP_ENV)
cmake/tribits/core/package_arch/TribitsProject.cmake:93 (TRIBITS_PROJECT_IMPL)
CMakeLists.txt:90 (TRIBITS_PROJECT)
but if I manually run the program and test it works creating test program with the same contents of the above cmake command
PROGRAM TESTFortran
PRINT *, 'Hello'
END
save that as test.f flang test.f
flang -v test.f
clang version 6.0.1
Target: x86_64-portbld-freebsd12.0
Thread model: posix
InstalledDir: /usr/local/flang/bin
"/usr/local/flang/bin/flang1" test.f -opt 0 -terse 1 -inform warn -nohpf -nostatic -inform warn -x 19 0x400000 -quad -x 68 0x1 -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -tp px -x 57 0xfb0000 -x 58 0x78031040 -x 47 0x08 -x 48 4608 -x 49 0x100 -def unix -def __unix -def __unix__ -def __FreeBSD__ -def __NO_MATH_INLINES -def __LP64__ -def __LONG_MAX__=9223372036854775807L -def __SIZE_TYPE__=unsigned long int -def __PTRDIFF_TYPE__=long int -def __x86_64 -def __x86_64__ -def __amd_64__amd64__ -def __k8 -def __k8__ -def __THROW= -def __extension__= -def __PGLLVM__ -nofreeform -idir /usr/local/include -idir /usr/local/flang/include -idir /usr/local/llvm60/include -idir /usr/local/llvm60/lib/clang/6.0.1/include -vect 48 -x 54 1 -x 70 0x40000000 -y 163 0xc0000000 -x 189 0x10 -stbfile test-2a5590.stb -modexport test-2a5590.cmod -modindex test-2a5590.cmdx -output test-2a5590.ilm
"/usr/local/flang/bin/flang2" test-2a5590.ilm -y 129 2 -ieee 0 -fn test.f -opt 0 -terse 1 -inform warn -inform warn -x 68 0x1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -x 164 0x800000 -quad -x 59 4 -tp px -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -astype 0 -x 183 4 -x 121 0x800 -x 54 0x10 -x 70 0x40000000 -x 249 50 -x 124 1 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -x 183 0x10 -stbfile test-2a5590.stb -asm /tmp/test-2a5590.ll
"/usr/local/flang/bin/clang-6.0" -cc1 -triple x86_64-portbld-freebsd12.0 -emit-obj -mrelax-all -disable-free -main-file-name test.f -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/local/flang/lib/clang/6.0.1 -Wno-unused-command-line-argument -fdebug-compilation-dir /wrkdirs/usr/ports/math/trilinos/work/.build -ferror-limit 19 -fmessage-length 294 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-02b4b5.o -x ir /tmp/test-2a5590.ll
clang -cc1 version 6.0.1 based upon LLVM 6.0.1 default target x86_64-portbld-freebsd12.0
"/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/local/lib -L/usr/local/flang/lib -L/usr/local/llvm60/lib -L/usr/lib -lflangmain -lm -lflang -lflangrti -lomptarget -lompstub -lomp -lpgmath -lm -lexecinfo /tmp/test-02b4b5.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
running
./a.out
Hello
Possible Solution
properly detect flang compiler?
Your Environment
./configure -GNinja; I already have the Kitware ninja fork that supports fortran.
Additional Information
//Enable support for the TPL ExodusII in all supported Trilinos
// packages. This can be set to 'ON', 'OFF', or left empty ''.
Determining if the Fortran compiler works failed with the following output:
Change Dir: /wrkdirs/usr/ports/math/trilinos/work/.build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/local/bin/ninja" "cmTC_6274f"
[1/4] Building Fortran preprocessed CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f
FAILED: CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f.ddi
/usr/local/bin/flang -cpp -E testFortranCompiler.f -o CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f && /usr/local/bin/cmake -E cmake_ninja_depends --tdi=CMakeFiles/cmTC_6274f.dir/FortranDependInfo.json --pp=CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f --dep=CMakeFiles/cmTC_62
74f.dir/testFortranCompiler.f-pp.f.d --obj=CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f.o --ddi=CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f.ddi
# 1 "testFortranCompiler.f"
# 2 "testFortranCompiler.f"
PROGRAM TESTFortran
PRINT *, 'Hello'
END
CMake Error: -E cmake_ninja_depends failed to open CMakeFiles/cmTC_6274f.dir/testFortranCompiler.f-pp.f
ninja: build stopped: subcommand failed.
Determining if the Fortran compiler works failed with the following output:
Change Dir: /wrkdirs/usr/ports/math/trilinos/work/.build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/local/bin/ninja" "cmTC_2dfa4"
[1/4] Building Fortran preprocessed CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f
FAILED: CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f.ddi
/usr/local/bin/flang -cpp -E testFortranCompiler.f -o CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f && /usr/local/bin/cmake -E cmake_ninja_depends --tdi=CMakeFiles/cmTC_2dfa4.dir/FortranDependInfo.json --pp=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f --dep=CMakeFiles/cmTC_2d
fa4.dir/testFortranCompiler.f-pp.f.d --obj=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f.o --ddi=CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f.ddi
# 1 "testFortranCompiler.f"
# 2 "testFortranCompiler.f"
PROGRAM TESTFortran
PRINT *, 'Hello'
END
CMake Error: -E cmake_ninja_depends failed to open CMakeFiles/cmTC_2dfa4.dir/testFortranCompiler.f-pp.f
ninja: build stopped: subcommand failed.