Skip to content

Linker error when using an archive created with ar #54787

Open
@PeixinQiao

Description

@PeixinQiao

There seems to be one problem with the current driver:

$ cat case.f90 
program m
end
$ flang-new case.f90 -c
$ ar -r a.a case.o
$ flang-new a.a -o a.out
/usr/bin/ld: /.../build/bin/../lib/libFortran_main.a(Fortran_main.c.o): in function `main':
/.../f18-llvm-project/flang/runtime/Fortran_main.c:11: undefined reference to `_QQmain'
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
$ ld --version
GNU ld version 2.31
$ ld.lld ... a.a -lFortran_main ... ! works ok
$ ld ... -lFortran_main a.a ... ! works ok
$ ld ... a.a -lFortran_main ...
ld: /.../build/bin/../lib/libFortran_main.a(Fortran_main.c.o): in function `main':
/.../f18-llvm-project/flang/runtime/Fortran_main.c:11: undefined reference to `_QQmain'

flang-new put _QQmain in binary file compiled by program and put main in libFortran_main.a . gfortran put both MAIN_ and main in binary file compiled by program , so it does not have this issue.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:drivergood first issuehttps://github.com/llvm/llvm-project/contributehelp wantedIndicates that a maintainer wants help. Not [good first issue].

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions