DavidTruby wrote:

I don’t personally think that the flang driver should ever attempt to link a 
C++ library of any kind. FWIW while there’s no stdlib option to consider in 
their case, g++ will never auto link the gfortran runtimes and gfortran will 
never auto link libstdc++

Mixed C++/Fortran programs are always going to be complicated for exactly this 
reason: as a user I wouldn’t expect a C++ compiler driver to automatically link 
a Fortran runtime or vice versa, and would find it quite surprising if that 
happened. In my opinion the current behaviour (which matches g++/gfortran) to 
require build systems to handle the complexity of adding the right linkage 
flags is the correct one. This would leave us rejecting stdlib= as an 
unrecognised option on flang as is the case in current main.

> I don't think we can rely on every build system doing that, so I would still 
> advocate that -stdlib=libc++ is not just ignored, but actually adds the C++ 
> standard library linker flags (see 
> https://github.com/llvm/llvm-project/pull/110598#issuecomment-2388005207) to 
> support such language-combination scenarios

If we were to do things this way, what should flang do if no -stdlib flag is 
provided? Should it link the default C++ stdlib as clang++ does, or break with 
clang++ and not link any C++ stdlib if nothing is provided? Both would be 
surprising behaviour in my opinion, and both would also risk breaking the 
existing cmake support.

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