[llvm-bugs] [Bug 52115] New: libomp.so: Missing linking against libm.so when compiled by Clang on Linux systems
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 8 08:13:32 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52115
Bug ID: 52115
Summary: libomp.so: Missing linking against libm.so when
compiled by Clang on Linux systems
Product: OpenMP
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Runtime Library
Assignee: unassignedbugs at nondot.org
Reporter: arfrever.fta at gmail.com
CC: llvm-bugs at lists.llvm.org
Gentoo report: https://bugs.gentoo.org/816831
As reported there, libomp.so compiled by Clang (instead of GCC) uses at least
fmaxl, which is defined in libm.so, but build system does not pass -lm to
consider linking against libm.so.
> $ nm -D /usr/lib64/libomp.so | grep fmaxl
> U fmaxl
> $ readelf -d /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]
https://github.com/llvm/llvm-project/blob/37109974af4b33189a599735afa67ed57c27b8ab/openmp/runtime/cmake/LibompHandleFlags.cmake#L138-L144
contains:
> if(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly|FreeBSD")
> libomp_append(libflags_local "-Wl,--no-as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
> libomp_append(libflags_local "-lm")
> libomp_append(libflags_local "-Wl,--as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
> elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
> libomp_append(libflags_local -lm)
> endif()
I do not know why this code uses --no-as-needed to forcefully link against
libm.so on DragonFly and FreeBSD, but I am not asking to use --no-as-needed on
Linux.
Probable solutions:
Linux-specific solution:
libomp_append(libflags_local "-Wl,--as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
- elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|NetBSD")
libomp_append(libflags_local -lm)
More generic solution:
libomp_append(libflags_local "-Wl,--as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
- elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+ else()
libomp_append(libflags_local -lm)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211008/f8307a59/attachment.html>
More information about the llvm-bugs
mailing list