[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)
Michael Klemm via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 01:26:57 PST 2023
mjklemm wrote:
> I see. So Fortran and C interoperability of F2003/F2008 is not supported yet in Flang?
It's rather untested and I'm working hard to get it fixed, so that we have well-defined behavior that is similar to other Fortran compilers like ifx and gfortran.
> Those ~100ish regression test cases we have were passing before this PR though. Unfortunately, those test cases are not made public available yet. I think I can copy the source code of one test case here, but it needs to be run manually. Please let me know if that is desired to help debug the reason of the regression.
Please share as many of these reproducers as you can, so that I can debug the regression and fix it.
```
ld.lld: error: duplicate symbol: main
>>> defined at ./bind_c09i.c
>>> bind_c09i.o:(.The_Code)
>>> defined at Fortran_main.c
>>> Fortran_main.c.o:(.text.main+0x0) in archive ./libFortran_main.a
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
```
This error message is a strong indication of potentially two things:
- Both Fortran and C/C++ provide the `main` entry point (Fortran via `Fortran_main.a` and C/C++ via a `main` function). Since this led to some weird behavior in the past, this situation now leads to an error message.
- On C/C++ provides the `main` function. In this case, please pass `-fno-fortran-main` when using `flang-new` link command line. This will remove the `main` symbol coming from `Fortran_main.a`, because it's not needed.
https://github.com/llvm/llvm-project/pull/73124
More information about the cfe-commits
mailing list