[flang-commits] [flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)
Michael Klemm via flang-commits
flang-commits at lists.llvm.org
Fri Dec 1 09:37:16 PST 2023
mjklemm wrote:
Here's the reproducer on my system:
```
[2023-12-01 18:36:31 CET] iris ~/tm*/fo*/ftn_main_dupes [0:0] (main *=)> gfortran -o ftn.o -c ftn.f90 && gcc -o prg.o -c prg.c && gfortran -o ./bla ftn.o prg.o
/usr/bin/ld: prg.o: in function `main':
prg.c:(.text+0x0): multiple definition of `main'; ftn.o:ftn.f90:(.text+0x8f): first defined here
collect2: error: ld returned 1 exit status
[2023-12-01 18:36:34 CET] [1] iris ~/tm*/fo*/ftn_main_dupes [0:0] (main *=)> cat prg.c
#include <stdio.h>
int main(int argc, char * argv[]) {
printf("Hello from C [%s]\n", __FUNCTION__);
return 0;
}
[2023-12-01 18:36:37 CET] iris ~/tm*/fo*/ftn_main_dupes [0:0] (main *=)> cat ftn.f90
program ftn
print '(A)', 'Hello from Fortran'
end program ftn
[2023-12-01 18:36:40 CET] iris ~/tm*/fo*/ftn_main_dupes [0:0] (main *=)> gfortran --version
GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
https://github.com/llvm/llvm-project/pull/73124
More information about the flang-commits
mailing list