Help compiling with LLVM Clang
Added by Matt Thompson 8 months ago
All,
I'm trying to build a library stack which includes CDO using LLVM Clang/Flang (main as of yesterday).
After a few hitches, I got to CDO (2.5.1 in this case, but I think 2.5.2 might have the same error since the file in question is identical) and:
mpic++ -DHAVE_CONFIG_H -I. -I../libcdi/src -I../src/mpim_grid -I../src/lib/yac/clapack/INCLUDE -DYAC_FOR_CDO -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/ -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/zlib -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/szlib -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/jpeg -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/hdf5 -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/hdf -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/netcdf -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/udunits2 -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/gsl -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/antlr2 -I/usr/include/tirpc -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include -I/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.14.0/x86_64-pc-linux-gnu/flang_2025-07-28-mpich_4.3.1/Linux/include/udunits2 -DCDI_SIZE_TYPE=size_t -std=c++20 -stdlib=libc++ -pthread -MT cdo-Output.o -MD -MP -MF .deps/cdo-Output.Tpo -c -o cdo-Output.o `test -f 'Output.cc' || echo './'`Output.cc
In file included from NCL_wind.cc:16:
In file included from ./libncl.h:4:
In file included from ./cf_interface.h:15:
./cfortran.h:193:2: warning: "Please specify the fortran compiler using -D flags. Try to guess the compiler used" [-W#warnings]
193 | #warning "Please specify the fortran compiler using -D flags. Try to guess the compiler used"
| ^
./cfortran.h:265:2: error: "cfortran.h: Can't find your environment among: - GNU gcc (gfortran) on Linux. - MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...) - IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000 - VAX VMS CC 3.1 and FORTRAN 5.4. - Alpha VMS DEC C 1.3 and DEC FORTRAN 6.0. - Alpha OSF DEC C and DEC Fortran for OSF/1 AXP Version 1.2 - Apollo DomainOS 10.2 (sys5.3) with f77 10.7 and cc 6.7. - CRAY - NEC SX-4 SUPER-UX - CONVEX - Sun - PowerStation Fortran with Visual C++ - HP9000s300/s700/s800 Latest test with: HP-UX A.08.07 A 9000/730 - LynxOS: cc or gcc with f2c. - VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77. - f77 with vcc works; but missing link magic for f77 I/O. - NO fort. None of gcc, cc or vcc generate required names. - f2c/g77: Use #define f2cFortran, or cc -Df2cFortran - gfortran: Use #define gFortran, or cc -DgFortran (also necessary for g77 with -fno-f2c option) - NAG f90: Use #define NAGf90Fortran, or cc -DNAGf90Fortran - Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortran - Absoft Pro Fortran: Use #define AbsoftProFortran - Portland Group Fortran: Use #define pgiFortran - Intel Fortran: Use #define INTEL_COMPILER"
265 | #error "cfortran.h: Can't find your environment among:\
| ^
1 warning and 1 error generated.
make[3]: *** [Makefile:4153: cdo-NCL_wind.o] Error 1
make[3]: *** Waiting for unfinished jobs....
That is, it looks like it doesn't recognize Flang as a Fortran compiler. Now, as the output says:
./cfortran.h:193:2: warning: "Please specify the fortran compiler using -D flags. Try to guess the compiler used" [-W#warnings] 193 | #warning "Please specify the fortran compiler using -D flags. Try to guess the compiler used"
So before I go blindly trying various things, does anyone out there have a thought on the right flags to pass in?
NOTE: To get this far, I did have to set CXXFLAGS=-std=c++20 -stdlib=libc++ so maybe that broke something? That was the only way I could tell CDO that clang had C++20 support.
Replies (1)
RE: Help compiling with LLVM Clang - Added by Uwe Schulzweida 8 months ago
You can disable the Fortran interface during configuration with the option --disable-fortran. The Fortran code is very very small and an insignificant part of CDO.
You may also be able to add the option “-Df2cFortran” to the CFLAGS to fix the cfortran.h error.