DavidTruby wrote:

I missed replying on this review somehow, sorry to come back 2 weeks later...

> Why are CXXFLAGS used when invoking a Fortran compiler? That's not correct, 
> is it?

I don't think CXXFLAGS will be being added to the flang invocation in this 
case. What I believe is happening is that cmake prefers to use the compiler 
driver for the relevant language to link the final binaries, so in this case is 
invoking `flang` as the _linker_ and passing it the LDFLAGS. 
This is why if you want to pass _actual_ linker options to the actual linker, 
you need to prefix them with `-Wl` in LDFLAGS so that the compiler driver 
forwards them on. E.g. `-Wl,--gc-sections` or whatever.

The CXXFLAGS are only passed to CXX and the FCFLAGS only passed to FC, and the 
LDFLAGS will be passed to whichever cmake chooses to use as the linker at the 
end _as well as_ CXXFLAGS or FCFLAGS depending which was picked. So probably 
you shouldn't be adding `-stdlib=libc++` to LDFLAGS only to CXXFLAGS. 

A quick test shows me that CMake picks the CXX compiler in mixed-language CXX 
and Fortran programs though, so I'm not sure why @pawosm-arm is seeing an 
error. It looks like CMake even does the right thing and manually adds 
-lFortranRuntime etc to the `clang++` link line when linking multi-language 
projects with both C++ and Fortran where CMAKE_Fortran_COMPILER=flang-new.

tl;dr this looks like a cmake misconfiguration issue to me?

https://github.com/llvm/llvm-project/pull/110598
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to