[OpenMP][CMake] Ensure linking against libm for Linux
authorJames Beddek <telans@posteo.de>
Sun, 6 Mar 2022 04:20:28 +0000 (20:20 -0800)
committerFangrui Song <i@maskray.me>
Sun, 6 Mar 2022 04:20:28 +0000 (20:20 -0800)
Do the same as is done for NetBSD. Some compiler-rt/lib/builtins files call
libm functions (e.g. fmaxl, fabs). Linking libomp with --rtlib=compiler-rt
references these functions.
Downstream report: https://bugs.gentoo.org/816831

Fixes: https://github.com/llvm/llvm-project/issues/51457

openmp/runtime/cmake/LibompHandleFlags.cmake

index 9e19e59..d725ece 100644 (file)
@@ -139,7 +139,7 @@ function(libomp_get_libflags libflags)
     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")
+  elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|NetBSD")
     libomp_append(libflags_local -lm)
   endif()
   set(libflags_local ${libflags_local} ${LIBOMP_LIBFLAGS})