Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 816831 - sys-libs/libomp needs to link against libm when built with clang
Summary: sys-libs/libomp needs to link against libm when built with clang
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Bernard Cafarelli
URL: https://bugs.llvm.org/show_bug.cgi?id...
Whiteboard:
Keywords:
: 665474 794481 851597 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-07 16:02 UTC by Jannik Glückert
Modified: 2022-07-26 07:32 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (libomp-13.build.log,97.70 KB, text/plain)
2021-10-07 16:02 UTC, Jannik Glückert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Glückert 2021-10-07 16:02:45 UTC
Created attachment 743790 [details]
build.log

libomp uses the fmaxl function from libm, but does not link against it unless if on BSD - gcc provides many of these functions as builtins (see https://stackoverflow.com/questions/45485060/why-does-clang-require-lm-unlike-gcc ), clang doesn't.

the Cmake config should probably just link against libm if building with clang?

This happens with 12, 13, and potentially older versions too.

Output from nm -D image/usr/lib64/libomp.so | grep fmaxl
  U fmaxl

Output from readelf -d image/usr/lib64/libomp.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]

Attached is the build.log

cheers to Arfrever for quickly finding the cause.
Comment 1 Arfrever Frehtes Taifersar Arahesis 2021-10-08 15:14:23 UTC
https://bugs.llvm.org/show_bug.cgi?id=52115
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-10-29 12:26:08 UTC
*** Bug 665474 has been marked as a duplicate of this bug. ***
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-10-29 12:26:22 UTC
See https://bugs.gentoo.org/665474#c0 too.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-24 16:14:53 UTC
*** Bug 794481 has been marked as a duplicate of this bug. ***
Comment 5 Alec Ari 2021-12-09 04:36:28 UTC
Sam James, thank you for marking that bug I commented on as a duplicate. I see what the real problem is now. You're right, -lm shouldn't be needed for the eclass. As for now, what do you suggest until this is properly fixed? Does this bug actually break anything aside from causing tc-has-openmp() to fail?
Comment 6 Alec Ari 2021-12-12 07:06:04 UTC
I passed `-lm` to LDFLAGS specific for sys-libs/libomp and this fixed it.

`readelf` and `nm` confirms.
Comment 7 Ionen Wolkens gentoo-dev 2022-06-14 14:42:07 UTC
*** Bug 851597 has been marked as a duplicate of this bug. ***
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-06-14 14:49:04 UTC
This will be fixed in LLVM 15, but we may backport it sooner: https://github.com/llvm/llvm-project/commit/2d0c9b64a07c6c430ccfe11ea4c767d788d20461.

Thanks to telans and maskray.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-26 07:32:37 UTC
This is in at least 14.0.6 in Gentoo.