[Openmp-commits] [PATCH] D84871: [OpenMP] Use weak attribute in interface only for static library

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Jul 29 09:57:45 PDT 2020


protze.joachim created this revision.
protze.joachim added reviewers: hans, omalyshe, jlpeyton.
protze.joachim added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
protze.joachim requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

This is to address the issue reported at:
https://bugs.llvm.org/show_bug.cgi?id=46863

>From my understanding, the issue is that these omp_ symbols want to be both external and weak. Since weak is meaningless for a shared library interface function, this patch disables the attribute, when the OpenMP library is built as shared library.

The situation of ompt_start_tool is different. This is not an interface function, but a function implemented by an OMPT tool. This function needs to be weak if possible to allow overwriting ompt_start_tool with a function implementation built into the application.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84871

Files:
  openmp/runtime/src/kmp_os.h
  openmp/runtime/src/ompt-specific.cpp


Index: openmp/runtime/src/ompt-specific.cpp
===================================================================
--- openmp/runtime/src/ompt-specific.cpp
+++ openmp/runtime/src/ompt-specific.cpp
@@ -27,7 +27,7 @@
 #define THREAD_LOCAL __thread
 #endif
 
-#define OMPT_WEAK_ATTRIBUTE KMP_WEAK_ATTRIBUTE
+#define OMPT_WEAK_ATTRIBUTE KMP_WEAK_ATTRIBUTE_INTERNAL
 
 //******************************************************************************
 // macros
Index: openmp/runtime/src/kmp_os.h
===================================================================
--- openmp/runtime/src/kmp_os.h
+++ openmp/runtime/src/kmp_os.h
@@ -338,12 +338,18 @@
 #define KMP_ALIAS(alias_of) __attribute__((alias(alias_of)))
 #endif
 
-#if KMP_HAVE_WEAK_ATTRIBUTE
+#if KMP_HAVE_WEAK_ATTRIBUTE && !KMP_DYNAMIC_LIB
 #define KMP_WEAK_ATTRIBUTE __attribute__((weak))
 #else
 #define KMP_WEAK_ATTRIBUTE /* Nothing */
 #endif
 
+#if KMP_HAVE_WEAK_ATTRIBUTE
+#define KMP_WEAK_ATTRIBUTE_INTERNAL __attribute__((weak))
+#else
+#define KMP_WEAK_ATTRIBUTE_INTERNAL /* Nothing */
+#endif
+
 // Define KMP_VERSION_SYMBOL and KMP_EXPAND_NAME
 #ifndef KMP_STR
 #define KMP_STR(x) _KMP_STR(x)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84871.281643.patch
Type: text/x-patch
Size: 1156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200729/50a696d7/attachment.bin>


More information about the Openmp-commits mailing list