Skip to content

[OpenMP] Create versioned libgomp softlinks #112973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2024
Merged

Conversation

ye-luo
Copy link
Contributor

@ye-luo ye-luo commented Oct 18, 2024

Add libgomp.1.dylib for MacOS and libgomp.so.1 for Linux

Linkers on Mac and Linux pick up versioned libgomp dynamic library files. The existing softlinks (libgomp.dylib for MacOS and libgomp.so for Linux) are insufficient. This helps alleviate the issue of mixing libgomp and libomp at runtime.

libgomp.1.dylib for MacOS or libgomp.so.1 for Linux
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Oct 18, 2024
@shiltian
Copy link
Contributor

Then change looks fine, but I'm still not clear about the motivation.

@ye-luo
Copy link
Contributor Author

ye-luo commented Oct 18, 2024

llvm openmp creates an alias libgomp.so to libomp.so. It is intended to use libomp as a drop-in replacement of libgomp.
However, I found that apps and libraries compiled with GCC and openmp links against libgomp.so.1 not libgomp.so. As a result, libgomp.so --> libomp.so is not enough to serve my needs. To make the aliases working as intended, I added the additional needed aliases.

Big picture, linking both libgomp and libomp may work but it is bad. See https://cpufun.substack.com/p/is-mixing-openmp-runtimes-safe I hit additional issues with affinity control. After fixing the alias, my app only picks up libomp at runtime even if it links a library openblas which was compiled with GCC and linked against libgomp.

@ye-luo
Copy link
Contributor Author

ye-luo commented Oct 21, 2024

Ping @shiltian

@shiltian
Copy link
Contributor

shiltian commented Oct 25, 2024

If I understand your comment correctly, libgomp.so --> libomp.so, libomp.so.1 --> libomp.so. Eventually you still get the same libomp, no? Not sure if you were trying to say that there is libgomp.so.1 --> libgomp.so (GCC) such that an app eventually picks up libgomp.so.

@ye-luo
Copy link
Contributor Author

ye-luo commented Oct 25, 2024

If I understand your comment correctly, libgomp.so --> libomp.so, libomp.so.1 --> libomp.so. Eventually you still get the same libomp, no? Not sure if you were trying to say that there is libgomp.so.1 --> libgomp.so (GCC) such that an app eventually picks up libgomp.so.

Sorry for the confusing. I corrected my type in the above comment. libgomp.so --> libomp.so, libgomp.so.1 --> libomp.so. The intention is to only pick up libomp at runtime.

@ye-luo ye-luo merged commit eccdb24 into llvm:main Oct 25, 2024
8 checks passed
@ye-luo ye-luo deleted the gomp-softlink branch October 25, 2024 18:20
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 25, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-libc-amdgpu-runtime running on omp-vega20-1 while building openmp at step 11 "Add check check-libc-amdgcn-amd-amdhsa".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/7574

Here is the relevant piece of the build log for the reference
Step 11 (Add check check-libc-amdgcn-amd-amdhsa) failure: 1200 seconds without output running [b'ninja', b'-j 32', b'check-libc-amdgcn-amd-amdhsa'], attempting to kill
...
[2559/2681] Linking CXX executable libc/test/src/locale/libc.test.src.locale.locale_test.__hermetic__.__build__
[2560/2681] Linking CXX executable libc/test/src/time/libc.test.src.time.clock_test.__hermetic__.__build__
[2561/2681] Linking CXX executable libc/test/src/string/libc.test.src.string.strxfrm_test.__hermetic__.__build__
[2562/2681] Linking CXX executable libc/test/src/string/libc.test.src.string.strncat_test.__hermetic__.__build__
[2563/2681] Linking CXX executable libc/test/src/inttypes/libc.test.src.inttypes.strtoimax_test.__hermetic__.__build__
[2564/2681] Linking CXX executable libc/test/src/inttypes/libc.test.src.inttypes.strtoumax_test.__hermetic__.__build__
[2565/2681] Linking CXX executable libc/test/src/string/libc.test.src.string.memmove_test.__hermetic__.__build__
[2566/2681] Linking CXX executable libc/test/src/time/libc.test.src.time.clock_gettime_test.__hermetic__.__build__
[2567/2681] Linking CXX executable libc/test/src/stdio/libc.test.src.stdio.asprintf_test.__hermetic__.__build__
[2568/2681] Linking CXX executable libc/test/src/stdio/libc.test.src.stdio.vasprintf_test.__hermetic__.__build__
command timed out: 1200 seconds without output running [b'ninja', b'-j 32', b'check-libc-amdgcn-amd-amdhsa'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1469.198629

NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
Add libgomp.1.dylib for MacOS and libgomp.so.1 for Linux

Linkers on Mac and Linux pick up versioned libgomp dynamic library
files. The existing softlinks (libgomp.dylib for MacOS and libgomp.so
for Linux) are insufficient. This helps alleviate the issue of mixing
libgomp and libomp at runtime.
@ye-luo ye-luo added this to the LLVM 19.X Release milestone Nov 12, 2024
@ye-luo
Copy link
Contributor Author

ye-luo commented Nov 12, 2024

/cherry-pick eccdb24

@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2024

/pull-request #115944

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
Development

Successfully merging this pull request may close these issues.

4 participants