Re: [libcxx] r282483 - [cmake] Add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Joerg Sonnenberger via cfe-commits
On Tue, Sep 27, 2016 at 12:15:35PM -, Michal Gorny via cfe-commits wrote:
> Author: mgorny
> Date: Tue Sep 27 07:15:35 2016
> New Revision: 282483
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=282483=rev
> Log:
> [cmake] Add linker option "-Wl,-z,defs" in standalone build
> 
> Add the "-Wl,-z,defs" linker option that is used to prevent
> underlinking. It is already used by LLVM itself but does not get
> propagated into stand-alone build of libc++. This patch ensures
> that the option is passed in independently of whether libc++ is built
> in-tree or out-of-tree.

Can we turn this into a positive list on platforms where it is known to
work? While I generally find it useful, linker and (GCC) spec stupidity
can easily break it.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r282483 - [cmake] Add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Sep 27 07:15:35 2016
New Revision: 282483

URL: http://llvm.org/viewvc/llvm-project?rev=282483=rev
Log:
[cmake] Add linker option "-Wl,-z,defs" in standalone build

Add the "-Wl,-z,defs" linker option that is used to prevent
underlinking. It is already used by LLVM itself but does not get
propagated into stand-alone build of libc++. This patch ensures
that the option is passed in independently of whether libc++ is built
in-tree or out-of-tree.

Patch by Lei Zhang.

Differential Revision: https://reviews.llvm.org/D24119

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=282483=282482=282483=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Sep 27 07:15:35 2016
@@ -319,6 +319,18 @@ remove_flags(-stdlib=libc++ -stdlib=libs
 # 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})


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits