[Openmp-commits] [PATCH] D69927: [libomptarget] Export __kmp_internal_end_fini to fix [Thin]LTO build

Aaron Puchert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 6 17:41:24 PST 2019


aaronpuchert created this revision.
aaronpuchert added a reviewer: JonChesterfield.
Herald added subscribers: dexonsmith, inglorion, mehdi_amini.
Herald added a reviewer: jdoerfert.
Herald added a project: OpenMP.
aaronpuchert edited the summary of this revision.

With link-time optimization turned on, the function might be dropped
if it is not exported, because it's not used anywhere. This is what
happens for me with Clang 9.

If the function is dropped, -Wl,-fini=__kmp_internal_end_fini doesn't
do what we want: with ld.bfd and lld it drops the FINI attribute from
.dynamic and with gold we get FINI = 0x0, which leads to a crash on
cleanup. This can be reproduced by building with

  -DLLVM_ENABLE_PROJECTS="clang;openmp" \
  -DLLVM_ENABLE_LTO=Thin \
  -DLLVM_USE_LINKER=gold

and then running `readelf -d libomp.so`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69927

Files:
  openmp/runtime/src/exports_so.txt


Index: openmp/runtime/src/exports_so.txt
===================================================================
--- openmp/runtime/src/exports_so.txt
+++ openmp/runtime/src/exports_so.txt
@@ -54,6 +54,11 @@
         ___kmp_free;
         __kmp_thread_pool;
 
+        #
+        # Internal function used as termination function.
+        #
+        __kmp_internal_end_fini;
+
 	__kmp_reset_stats;
 
 #if USE_ITT_BUILD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69927.228169.patch
Type: text/x-patch
Size: 415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20191107/5ef40d75/attachment.bin>


More information about the Openmp-commits mailing list