[PATCH] D86839: [CMake] Remove -Wl,-allow-shlib-undefined which was added in rL221530

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 29 12:20:48 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: mehdi_amini, rriddle.
Herald added subscribers: llvm-commits, danielkiss, fedor.sergeev, mgorny.
Herald added a project: LLVM.
MaskRay requested review of this revision.
Herald added a subscriber: stephenneuendorffer.

In GNU ld, gold and LLD, --no-allow-shlib-undefined is the default when
linking an executable. The option disallows unresolved symbols in shared objects.
(gold and LLD catch fewer cases than GNU ld. See D57385 <https://reviews.llvm.org/D57385> for details)
See D57569 <https://reviews.llvm.org/D57569> why it is bad idea to use --allow-shlib-undefined for executables [a].

GNU ld traditionally copied DT_NEEDED entries transitively. This was
deemed not good, so GNU ld 2.22 defaulted to --no-copy-dt-needed-entries.
gold and LLD always behave like --no-copy-dt-needed-entries.
rL221530 <https://reviews.llvm.org/rL221530> added -Wl,-allow-shlib-undefined to make some old releases of GNU ld's
--no-copy-dt-needed-entries to actually work.

Due to [a] and [b], this patch drops -Wl,-allow-shlib-undefined.

[b]: In a -DBUILD_SHARED_LIBS=on build, --as-needed + --allow-shlib-undefined

  can unexpectedly suppress some .dynsym entries.  The issue can cause
  mlir-cpu-runner to fail at runtime. See
  https://sourceware.org/bugzilla/show_bug.cgi?id=26551 for a reduced example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86839

Files:
  llvm/CMakeLists.txt


Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -962,16 +962,6 @@
           add_definitions("-D_FILE_OFFSET_BITS=64")
 endif()
 
-# Work around a broken bfd ld behavior. When linking a binary with a
-# foo.so library, it will try to find any library that foo.so uses and
-# check its symbols. This is wasteful (the check was done when foo.so
-# was created) and can fail since it is not the dynamic linker and
-# doesn't know how to handle search paths correctly.
-if (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "SunOS|AIX|OS390")
-  set(CMAKE_EXE_LINKER_FLAGS
-      "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
-endif()
-
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86839.288798.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200829/1f10c06a/attachment.bin>


More information about the llvm-commits mailing list