Flang-new compilation issue with complex(kind=8)

Flang-new fail on complex division on version 19.1.4 (installed using Homebrew on OSX):

program test
integer, parameter :: n=2
complex(kind=8), dimension(n,n) :: V
V(1,1)=cmplx(4.0,2.0)
V(2,2)=cmplx(5.0,3.0)
V(1,2)=0.0
V(2,1)=0.5
PER=cmplx(1.2,1.2)
V(:,:)=V(:,:)/PER
end program test

I got a compilation issue:

alainhebert@Alains-MacBook-Air-2 test_complex % flang-new *.f90
Undefined symbols for architecture arm64:
β€œ___divdc3”, referenced from:
__QQmain in test-8db182.o
ld: symbol(s) not found for architecture arm64
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)

Thank in advance for any help.

1 Like

Try adding β€œ-lgcc” , perhaps?

I am using clang with flang. I tries without success:

flang-new -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib -lclang *.f90

divdc3 still missing.

However, the solution should be close to your proposal. Please continue bringing ideas.

What happens if you define PER as COMPLEX? At the moment you appear to be assigning a complex number to a real variable.

Same behaviour:

program test
integer, parameter :: n=2
complex(kind=8), dimension(n,n) :: V
complex(kind=8) :: PER
V(1,1)=cmplx(4.0,2.0)
V(2,2)=cmplx(5.0,3.0)
V(1,2)=0.0
V(2,1)=0.5
PER=cmplx(1.2,1.2)
V(:,:)=V(:,:)/PER
end program test

alainhebert@Alains-MacBook-Air-2 test_complex % flang-new test.f90

Undefined symbols for architecture arm64:

β€œ___divdc3”, referenced from:

__QQmain in test-fc2bb3.o

ld: symbol(s) not found for architecture arm64

flang-new: error: linker command failed with exit code 1 (use -v to see invocation)

Possibly related? (The page also mentions flang near the bottom of the page)

I am confuse because the GitHub post refers to OpenMP. I am not yet using OpenMP. I first want to run my code in scalar mode and test various bindings before going to parallel. Is there a simple way to correct my makefiles to avoid the issue or do I have to wait for a new Homebrew release?

I have no experience with Flang-new yet (just searching the net for divdc3 showed the above page), so no idea about the reason (sorry…). But I guess it may be useful to ask LLVM Discourse also (if not yet)

Check the contents of /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib. Maybe -lclang is not enough and you need -lclang_rt or something similar.

no libclang_rt.dylib. I am afraid that Apple clang is not clang. Someone knows?