Skip to content

Linker missing _FortranACopyInAssign #100403

Closed
@tukss

Description

@tukss

Compiling this simple reproducer code (the real example called DGEMM) produces an undefined reference to _FortranACopyInAssign. I'm using flang-new from the current main branch.

program atest
  implicit none

  real(8) :: a(2)

  call ar(a)

contains

  subroutine br(x)
    implicit none
    real(8) :: x(*)
  end subroutine br
  
  subroutine ar(d)
    implicit none
    real(8) :: d(:)
    call br(d)
    
  end subroutine ar
end program atest

This is the error message:

% flang-new atest.f08 -o atest -v                                                                                                                        (1)
flang-new version 20.0.0git (https://github.com/llvm/llvm-project.git 37123e9915407d266074aaf81c5de9399b672e53)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/14
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/14
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 12.5
 "/home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/bin/flang-new" -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -resource-dir /home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/lib/clang/20 -mframe-pointer=all -o /tmp/atest-ba7628.o -x f95-cpp-input atest.f08
 "/home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/bin/ld" --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o atest /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/14/crtbeginS.o -L/home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/bin/../lib/x86_64-unknown-linux-gnu -L/usr/lib/gcc/x86_64-redhat-linux/14 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/atest-ba7628.o -L/home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/lib -lFortranRuntime -lFortranDecimal -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/14/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crtn.o
/home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/bin/ld: /tmp/atest-ba7628.o: in function `_QFPar':
FIRModule:(.text+0x115): undefined reference to `_FortranACopyInAssign'
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)

I think the reason is that the -L/usr/lib option is passed to ld before -L/home/user/local/._llvm/l5duc52wf5stt5l5n6whwfzlfnd2ggl2/lib so the linker is picking up the libFortranRuntime from my system (having LLMV 18.1.6 installed) instead of the one installed by LLVM from git in my home directory. Should the order of the -L options be changed here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions