# Flang-20 Not compiling with FPM for an OpenMP program

**URL:** <https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348>\
**Category:** Flang\
**Created:** [March 15, 2025, 6:39am UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348 "2025-03-15T06:39:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![apoorv01](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@apoorv01](https://fortran-lang.discourse.group/u/apoorv01)\
**Post date:** [March 15, 2025, 6:39am UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/1 "2025-03-15T06:39:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [March 15, 2025, 11:15am UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/2 "2025-03-15T11:15:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [March 15, 2025, 9:53pm UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/3 "2025-03-15T21:53:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [March 21, 2025, 10:58am UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/4 "2025-03-21T10:58:06Z")

</div>

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

```auto
[dependencies]
openmp = "*"

```

And I get:

```auto
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](https://github.com/JorgeG94/flang-20-fpm-omp-bug)

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [March 21, 2025, 11:51am UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/5 "2025-03-21T11:51:31Z")

</div>

Yes, flang-new is still not widely supported in fpm.  
I have opened a [PR](https://github.com/fortran-lang/fpm/pull/1113) to introduce flang-new syntax in the openmp metapackage.  
Contributions welcome!

However, please note that:

```auto
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”.

---

<div class="post-metadata">

**Author:** ![apoorv01](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@apoorv01](https://fortran-lang.discourse.group/u/apoorv01)\
**Post date:** [March 21, 2025, 1:17pm UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/6 "2025-03-21T13:17:19Z")

</div>

Hi @FedericoPerini and @jorgeg

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

> [@First official release of Flang!](https://fortran-lang.discourse.group/t/first-official-release-of-flang/9333):
>
> Announcing the first official release of Flang! Congratulations to everyone who has contributed to this LLVM Fortran project, which began in late 2020. The blog post below provides a historical recap of the project. Also, big thanks to Peter Klausler who wrote the first component to Flang, the parser! Peter continues to be one of the main contributors to the project (in fact, he is now the #24 all-time contributor to the LLVM project). There is still work to be done, but it is great to reach…

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

---

<div class="post-metadata">

**Author:** ![everythingfunctional](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/everythingfunctional/32/176_2.png) [@everythingfunctional](https://fortran-lang.discourse.group/u/everythingfunctional)\
**Post date:** [March 26, 2025, 1:22am UTC](https://fortran-lang.discourse.group/t/flang-20-not-compiling-with-fpm-for-an-openmp-program/9348/7 "2025-03-26T01:22:28Z")

</div>

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.
