summaryrefslogtreecommitdiffstats
path: root/llvm/cmake/modules
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-01-20 21:23:15 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-01-20 21:23:15 +0000
commitcb274c0c4724c65b8c9cef32e431cf6152b0410e (patch)
tree74aaa9ea7063b99e67579eed78f38db7f5e870a4 /llvm/cmake/modules
parentb3d03df3acacd6ce69064ec8d028a40e86ee977c (diff)
downloadbcm5719-llvm-cb274c0c4724c65b8c9cef32e431cf6152b0410e.tar.gz
bcm5719-llvm-cb274c0c4724c65b8c9cef32e431cf6152b0410e.zip
Use -Wl,defs when linking.
ELF linkers by default allow shared libraries to contain undefined references and it is up to the dynamic linker to look for them. On COFF and MachO, that is not the case. This creates a situation where a .so might build on an ELF system, but the build of the corresponding .dylib or .dll will fail. This patch changes the cmake build to use -Wl,-z,defs when linking and updates the dependencies so that -DBUILD_SHARED_LIBS=ON build still works. llvm-svn: 226611
Diffstat (limited to 'llvm/cmake/modules')
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 2ee0dd5b1b7..e60018e6a0d 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -104,6 +104,13 @@ if(APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
+# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
+# build might work on ELF but fail on MachO/COFF.
+if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32))
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+endif()
+
+
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
OpenPOWER on IntegriCloud