[Openmp-commits] [openmp] c6e6231 - [OpenMP][libomp] Fix version scripts after undefined version script changes

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 8 10:38:19 PST 2022


Author: Joseph Huber
Date: 2022-12-08T13:37:03-05:00
New Revision: c6e6231e2f467528e727bf9287c42975e778b8ed

URL: https://github.com/llvm/llvm-project/commit/c6e6231e2f467528e727bf9287c42975e778b8ed
DIFF: https://github.com/llvm/llvm-project/commit/c6e6231e2f467528e727bf9287c42975e778b8ed.diff

LOG: [OpenMP][libomp] Fix version scripts after undefined version script changes

Summary:
Building with `lld` now errors on undefined symbols by default now. This
was causing `libomp` to think that the compiler didn't support version
scripts when checking linker features. This patch adds a new script that
exports all symbols to be used for testing. We also remove the old
workarounds for undefined versions now that it's no longer necessary.

Added: 
    openmp/runtime/src/exports_test_so.txt

Modified: 
    openmp/runtime/cmake/LibompHandleFlags.cmake
    openmp/runtime/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/cmake/LibompHandleFlags.cmake b/openmp/runtime/cmake/LibompHandleFlags.cmake
index a6adbe3f2f540..56d02205ba2e0 100644
--- a/openmp/runtime/cmake/LibompHandleFlags.cmake
+++ b/openmp/runtime/cmake/LibompHandleFlags.cmake
@@ -101,7 +101,6 @@ function(libomp_get_ldflags ldflags)
     IF_DEFINED CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG)
   libomp_append(ldflags_local -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
   libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
-  libomp_append(ldflags_local "-Wl,--undefined-version" LIBOMP_HAVE_UNDEFINED_VERSION_FLAG)  # FIXME issue #58858
   libomp_append(ldflags_local -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
   libomp_append(ldflags_local -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
   libomp_append(ldflags_local -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)

diff  --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake
index 1e02d5a8b5cf1..1c688522a00a3 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -131,8 +131,7 @@ if(WIN32)
 elseif(NOT APPLE)
   libomp_check_linker_flag(-Wl,-x LIBOMP_HAVE_X_FLAG)
   libomp_check_linker_flag(-Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
-  libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
-  libomp_check_linker_flag("-Wl,--undefined-version" LIBOMP_HAVE_UNDEFINED_VERSION_FLAG)  # FIXME issue #58858
+  libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
   libomp_check_linker_flag(-static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
   libomp_check_linker_flag(-Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
 endif()

diff  --git a/openmp/runtime/src/exports_test_so.txt b/openmp/runtime/src/exports_test_so.txt
new file mode 100644
index 0000000000000..912d160e7c068
--- /dev/null
+++ b/openmp/runtime/src/exports_test_so.txt
@@ -0,0 +1,60 @@
+# exports_test_so.txt #
+
+#
+#//===----------------------------------------------------------------------===//
+#//
+#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+#// See https://llvm.org/LICENSE.txt for license information.
+#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#//
+#//===----------------------------------------------------------------------===//
+#
+
+# This is used only to test if the linker supports version scripts. If the full
+# version script it used we may error on undefined symbols and erroneously fail.
+
+VERSION {
+
+    global: # Exported symbols.
+
+        *;         # All symbols as exported for testing.
+
+    local: # Non-exported symbols.
+
+        *;         # All other symbols are not exported.
+
+}; # VERSION
+
+# sets up GCC OMP_ version dependency chain
+OMP_1.0 {
+};
+OMP_2.0 {
+} OMP_1.0;
+OMP_3.0 {
+} OMP_2.0;
+OMP_3.1 {
+} OMP_3.0;
+OMP_4.0 {
+} OMP_3.1;
+OMP_4.5 {
+} OMP_4.0;
+OMP_5.0 {
+} OMP_4.5;
+
+# sets up GCC GOMP_ version dependency chain
+GOMP_1.0 {
+};
+GOMP_2.0 {
+} GOMP_1.0;
+GOMP_3.0 {
+} GOMP_2.0;
+GOMP_4.0 {
+} GOMP_3.0;
+GOMP_4.5 {
+} GOMP_4.0;
+GOMP_5.0 {
+} GOMP_4.5;
+GOMP_5.0.1 {
+} GOMP_5.0;
+
+# end of file #


        


More information about the Openmp-commits mailing list