[Flang] ld error when compile f90 file

I’m new to flang so please correct me if I have any mistakes.

when I try to compile a samplist Fortran program by flang-new. I got the following errors in linker.

/usr/bin/ld: /lib/x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
/usr/bin/ld: /tmp/hello-228794.o: in function `_QQmain':
/home/wuxinlong/workspace/llvm-project/.flang-test/./hello.f90:2: undefined reference to `_FortranAioBeginExternalListOutput'
/usr/bin/ld: /home/wuxinlong/workspace/llvm-project/.flang-test/./hello.f90:2: undefined reference to `_FortranAioOutputAscii'
/usr/bin/ld: /home/wuxinlong/workspace/llvm-project/.flang-test/./hello.f90:2: undefined reference to `_FortranAioEndIoStatement'

It seems there are some library is missing. What should I do? Is the current flang compiler ready to generate executable files?

We are in the process of upstreaming lowering and codegen to llvm-project. Flang is not ready to generate executable yet.

tks, I im plan to trieing to support RISCV arch for flang. Does it have negative impacts on the current flang community? I mean, will it disrupt the current flang development/release schedule?

1 Like

@Xinlong-WU Thanks for posting!

This is failing for you because the linker invocation is incomplete. We do have a patch tthat implements this, but it has not been merged yet: ⚙ D122008 [flang][driver] Add support for generating executables.

I mean, will it disrupt the current flang development/release schedule?

I think that it would be beneficial for Flang to be supported on other platforms too. I mostly work on the driver - a new platform wouldn’t be a disruption there at all :slight_smile: I’ll let others comment on the other areas (parsing/sema/lowering/code-gen/run-time/OpenMP/OpenACC). Would you be able to set-up a buildbot too?

Thanks,
-Andrzej

Thanks for that, that helps a lot. I will try this patch first.

I will do it when I get more visible progress

FWIW, we’re allowing Windows on Arm triples, but I’ve been refraining from implementing any ABI-related stuff for it until upstreaming is done.

If you’re very eager, you can start prototyping on the fir-dev branch, which can actually generate executables. However, if you want to commit something, you’ll have to commit it both upstream and on fir-dev, which is a bit of a hassle (it’s just extra work both for you and the reviewers).

For starters, you’ll probably be interested in these 2 files: llvm-project/Target.cpp at main · llvm/llvm-project · GitHub and llvm-project/TargetRewrite.cpp at main · llvm/llvm-project · GitHub. These have both been upstreamed from fir-dev, so it’s very important to keep main and fir-dev in sync if you’re going to touch them.

3 Likes

Thank you for this. This is exciting.

support RISCV arch for flang

Is there anything specific that should be handled in the frontend for supporting RISCV? I am not familiar with arch support. If RISCV works for LLVM IR, then I expect it to work for flang for the most part. If there is no/minimal special handling required in the frontend then parsing, sema, lowering, codegen, OpenMP and OpenACC should not be affected much either. I don’t know about runtime.