Skip to content

fpm test fails to run an OpenMP "Hello, world!" program compiled with LLVM flang-new on macOS #1088

Open
@rouson

Description

@rouson

Description

On macOS 14.6.1 with an Apple M2 processor and LLVM Flang 20.0.0 (commit be64ca) built from source, fpm test --compiler flang-new --flag -fopenmp successfully builds a program in the test/ subdirectory. As demonstrated below, however, the program fails to launch even though I can execute multithreaded runs the samefpm-generated file as long as I launch the program myself at the command line rather than via fpm.

fpm new macos-openmp
cd macos-openmp 
vim test/check.f90
cat test/check.f90

program check
use omp_lib
implicit none

!$omp parallel 
print *, "Hello from thread ",omp_get_thread_num()
!$omp end parallel 

end program check

Running the above program with the command

fpm test --compiler flang-new --flag -fopenmp

yields the following trailing output:

[100%] Project compiled successfully.
dyld[59487]: Library not loaded: @rpath/libomp.dylib
  Referenced from: <6BBE5380-F853-3F07-B154-4337D2C20E5B> /Users/rouson/Repositories/macos-openmp/build/flang-new_1F0FD47CBB36F885/test/check
  Reason: no LC_RPATH's found
<ERROR> Execution for object " check " returned exit code  6
<ERROR> *cmd_run*:stopping due to failed executions
STOP 6

Expected Behaviour

I expected the above fpm command to produce the following output generated by launching the program directly at the command line:

export OMP_NUM_THREADS=2
./build/flang-new_1F0FD47CBB36F885/test/check
 Hello from thread  0
 Hello from thread  1

Version of fpm

0.10.1

Platform and Architecture

macOS

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions