[PATCH] D47719: Disable ENABLE_EXPORTS for NetBSD static linking

Yang Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 4 07:45:57 PDT 2018


tomsun.0.7 created this revision.
tomsun.0.7 added reviewers: krytarowski, joerg.
Herald added subscribers: llvm-commits, mgorny.

When trying to build static clang with flag -DLLVM_BUILD_STATIC
for cmake, ENABLE_EXPORTS=1 will introduce -Wl,--export-dynamic
flag while linking.

With this flag, NetBSD will recognize the generated clang as
dynamically linked binary with dependency to /lib/ld64.so.1,
which does not exist. The following is the information for clang
binary:

file clang-7
============

clang-7: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib/ld64.so.1, for NetBSD
8.99.17, not stripped

ldd clang-7
===========

clang-7:

nothing else
------------

To prevent this, this modification chooses to directly prevent
the setting of ENABLE_EXPORTS flag, but we are not sure whether
this is a proper solution.


Repository:
  rL LLVM

https://reviews.llvm.org/D47719

Files:
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -774,6 +774,9 @@
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
+  if (LLVM_BUILD_STATIC AND ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+    return()
+  endif()
   if (LLVM_EXPORTED_SYMBOL_FILE)
     # The symbol file should contain the symbols we want the executable to
     # export


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47719.149758.patch
Type: text/x-patch
Size: 486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180604/5fbad2c1/attachment.bin>


More information about the llvm-commits mailing list