[libcxx-commits] [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

Michał Górny via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 7 06:45:29 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4601ac04c738: [cmake] Add linker option "-Wl,-z,defs" in standalone build (authored by mgorny).
Herald added subscribers: libcxx-commits, ldionne, christof.
Herald added a project: libc++.

Changed prior to commit:
  https://reviews.llvm.org/D24119?vs=72632&id=223558#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D24119/new/

https://reviews.llvm.org/D24119

Files:
  libcxx/CMakeLists.txt


Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -319,6 +319,18 @@
 # so they don't get transformed into -Wno and -errors respectivly.
 remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
 
+# FIXME: this is cribbed from HandleLLVMOptions.cmake.
+if(LIBCXX_STANDALONE_BUILD)
+  # 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 OR CYGWIN OR
+          ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
+          ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+     NOT LLVM_USE_SANITIZER)
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+  endif()
+endif()
+
 # Required flags ==============================================================
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24119.223558.patch
Type: text/x-patch
Size: 1055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191007/76e48645/attachment-0001.bin>


More information about the libcxx-commits mailing list