Skip to content

Odd flang OpenMP Linking Behavior #113487

@mathomp4

Description

@mathomp4

All,

Last month, I built flang-new and I was able to build OpenMP code:

> flang-new --version
flang-new version 20.0.0git ([email protected]:GEOS-ESM/build-llvm-flang.git a62667f983fc27f97ed4658cc2beb288b00450c9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /ford1/share/gmao_SIteam/llvm-flang/2024-09-06/bin
> flang-new -fopenmp test.F90
> OMP_NUM_THREADS=2 ./a.out
 Hello from process:  0
 Hello from process:  1

However, I built flang-new as of yesterday and:

> flang-new --version
flang version 20.0.0git ([email protected]:GEOS-ESM/build-llvm-flang.git 697744d14fec6505d07f95249388ac2452ee5151)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /ford1/share/gmao_SIteam/llvm-flang/2024-10-22/bin
> flang-new -fopenmp test.F90
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
/usr/bin/ld: cannot find /usr/lib64/libatomic.so.1.2.0
flang-20: error: linker command failed with exit code 1 (use -v to see invocation)

Now, I do have libatomic.so.1.2.0 and it was around when I built flang-new with GCC 12.1.0 but it's the GCC 12 one:

> ls -1 /ford1/local/gcc/gcc-12.1.0/lib64/libatomic.*
/ford1/local/gcc/gcc-12.1.0/lib64/libatomic.a
/ford1/local/gcc/gcc-12.1.0/lib64/libatomic.la*
/ford1/local/gcc/gcc-12.1.0/lib64/libatomic.so@
/ford1/local/gcc/gcc-12.1.0/lib64/libatomic.so.1@
/ford1/local/gcc/gcc-12.1.0/lib64/libatomic.so.1.2.0*

and I have that in my LD_LIBRARY_PATH:

> echo $LD_LIBRARY_PATH
/ford1/share/gmao_SIteam/llvm-flang/2024-10-22/lib:/ford1/local/gcc/gcc-12.1.0/lib64:/home/mathomp4/lib

but it is not in /usr/lib64:

> ls -1 /usr/lib64/libatomic*
/usr/lib64/libatomic_ops_gpl.so.1@
/usr/lib64/libatomic_ops_gpl.so.1.1.2*
/usr/lib64/libatomic_ops.so.1@
/usr/lib64/libatomic_ops.so.1.1.1*

So if I build pointing to that:

> flang-new -fopenmp test.F90 -L/ford1/local/gcc/gcc-12.1.0/lib64 -latomic
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
> OMP_NUM_THREADS=2 ./a.out
 Hello from process:  0
 Hello from process:  1

My question is: why does flang-new seem to think libatomic is in /usr/lib64? The build couldn't have seen it there since it didn't exist there during the build. And it's not like ldd wants it there:

> ldd /ford1/share/gmao_SIteam/llvm-flang/2024-10-22/bin/flang-new
	linux-vdso.so.1 (0x00007fff7bb0c000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x0000151cb7967000)
	libquadmath.so.0 => /ford1/local/gcc/gcc-12.1.0/lib64/libquadmath.so.0 (0x0000151cb7722000)
	librt.so.1 => /lib64/librt.so.1 (0x0000151cb751a000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000151cb7316000)
	libz.so.1 => /lib64/libz.so.1 (0x0000151cb70fe000)
	libzstd.so.1 => /lib64/libzstd.so.1 (0x0000151cb6e5a000)
	libstdc++.so.6 => /ford1/local/gcc/gcc-12.1.0/lib64/libstdc++.so.6 (0x0000151cb6a44000)
	libm.so.6 => /lib64/libm.so.6 (0x0000151cb66c2000)
	libgcc_s.so.1 => /ford1/local/gcc/gcc-12.1.0/lib64/libgcc_s.so.1 (0x0000151cb64a4000)
	libc.so.6 => /lib64/libc.so.6 (0x0000151cb60ce000)
	/lib64/ld-linux-x86-64.so.2 (0x0000151cb7b87000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    flangFlang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions