Flang-20 Not compiling with FPM for an OpenMP program

Hi Flang Team,

I am trying the new flang-20 compiler for a program using FPM with Openmp. The program compiled in flang-new (flang-18). I am using following command

fpm build --flag -O3 --flag -fstack-arrays --flag -fopenmp -compiler flang

This command worked well with flang-18, but in flang-20 I am getting following error

flang-20: error: unknown argument: ‘-module’
flang-20: warning: build/flang_57BEECF0903D8484: ‘linker’ input unused [-Wunused-command-line-argument]
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]

What could be my CMD error, and what is the possible solution.

Regards

Apurva

can you post the snipped of code or a minimal reproducible so that others can potentially reproduce your error and help you fix it?

I just created a Compilers/Flang category, and tagged this post.

Hi @apoorv01 sorry that I didn’t get back to you, it has been a busy set of days. I just tried your code and it indeed fails! Exactly the same error.

I also tried using

[dependencies]
openmp = "*"

And I get:

jorge@Big-Chungus:~/FLANG_20_EXP$ FPM_FC=flang fpm build
<ERROR> *cmd_build* Model error: openmp not supported on compiler flang yet
STOP 1

Very interesting!

Let me try to do something else…

Edit: made a reproducible GitHub - JorgeG94/flang-20-fpm-omp-bug: A simple reproducible of a bug in the FPM

Yes, flang-new is still not widely supported in fpm.
I have opened a PR to introduce flang-new syntax in the openmp metapackage.
Contributions welcome!

However, please note that:

federico@Federicos-MBP tmp % flang-new --version
Homebrew flang-new version 19.1.7
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/flang/19.1.7/libexec
Configuration file: /opt/homebrew/Cellar/flang/19.1.7/libexec/flang.cfg
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg
federico@Federicos-MBP tmp % cat to.f90 && flang-new -fopenmp to.f90
program openmp_test
  use omp_lib, only: omp_get_thread_num
  implicit none

!$omp parallel
    print *, 'Hello from tread ',omp_get_thread_num()
!$omp end parallel

! Successful return
stop 0

end program openmp_test

ld: library 'omp' not found
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
federico@Federicos-MBP tmp % 

I am no flang-new user but it looks like (at least on macOS with homebrew) there are some missing libraries that the compiler can’t link against.

Please also note that fpm maps flang to “classic flang”. I am no expert in this family of compilers, but I believe the community will soon have to decide and settle on how to differentiate between “classic flang” and “flang-new” which seems it may become the mainstream “flang”.

Hi @FedericoPerini and @jorgeg

I had tried to compiled my program based on binary provided in the link in this post

Actually out of curiosity, I was checking solving speed of flang as compared to gfortran for my case.

The program that could be compiled using gfortran and flang-new, couldn’t be compiled using the latest flang.

I will stick to gfortran, test flang when it is more stable.

Best Regards

Apurva

Last I recall looking at this, fpm currently only recognizes the new LLVM flang if it is named flang-new, and treats other flang executables as though they are classic flang.

EDIT: @FedericoPerini already pointed this out. Sorry.