kkwli wrote:

Yep the situation is something like using `flang-new` to link the C and Fortran 
objects.
```
$ cat main.c
void fsub();
int main() { fsub(); }

$ cat sub.f90
subroutine fsub()
end subroutine

$ flang-new -c sub.f90 -fno-underscoring

$ clang -c main.c

$ flang-new main.o sub.o
ld.lld: error: duplicate symbol: main
>>> defined at main.c
>>>            main.o:(main)
>>> defined at Fortran_main.c:18 
>>> (llvm-project/flang/runtime/FortranMain/Fortran_main.c:18)
>>>            Fortran_main.c.o:(.text+0x0) in archive 
>>> /scratch/kli/wrk/f/build-flang/lib/libFortran_main.a
flang-new: error: linker command failed with exit code 1 (use -v to see 
invocation)

$ flang-new main.o sub.o -fno-fortran-main

$ echo $?
0
```
It is good that this situation is caught by most linkers (unfortunately, AIX 
linker does not complain and picks up one of the `main`s!) Requiring 
`-fno-fortran-main` for this situation is different from what gfortran behaves. 
It may make porting code to flang less convenient. In my opinion, it is 
probably helpful to document this subtle difference somewhere.

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

Reply via email to