r221844 - CMake: Set HOST_LINK_VERSION on Darwin (PR21268)
Hans Wennborg
hans at hanshq.net
Wed Nov 12 16:35:23 PST 2014
Author: hans
Date: Wed Nov 12 18:35:23 2014
New Revision: 221844
URL: http://llvm.org/viewvc/llvm-project?rev=221844&view=rev
Log:
CMake: Set HOST_LINK_VERSION on Darwin (PR21268)
The Autoconf build already does this, but it was never ported to
CMake. The host linker version affects the flags that Clang pass
to the linker, notably whether it passes -demangle or not.
http://reviews.llvm.org/D6239
Added:
cfe/trunk/test/Driver/darwin-ld-demangle.c
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/include/clang/Config/config.h.in
Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=221844&r1=221843&r2=221844&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Nov 12 18:35:23 2014
@@ -253,6 +253,26 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
endif()
endif ()
+# Determine HOST_LINK_VERSION on Darwin.
+set(HOST_LINK_VERSION)
+if (APPLE)
+ set(LD_V_OUTPUT)
+ execute_process(
+ COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1"
+ RESULT_VARIABLE HAD_ERROR
+ OUTPUT_VARIABLE LD_V_OUTPUT
+ )
+ if (NOT HAD_ERROR)
+ if ("${LD_V_OUTPUT}" MATCHES ".*ld64.*")
+ string(REGEX REPLACE ".*ld64-([0-9.]*).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+ else()
+ string(REGEX REPLACE "[^0-9]*([0-9.]*).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+ endif()
+ else()
+ message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
+ endif()
+endif()
+
configure_file(
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
${CLANG_BINARY_DIR}/include/clang/Config/config.h)
Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=221844&r1=221843&r2=221844&view=diff
==============================================================================
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Wed Nov 12 18:35:23 2014
@@ -26,4 +26,7 @@
/* The LLVM product name and version */
#define BACKEND_PACKAGE_STRING "${BACKEND_PACKAGE_STRING}"
+/* Linker version detected at compile time. */
+#cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
+
#endif
Modified: cfe/trunk/include/clang/Config/config.h.in
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.in?rev=221844&r1=221843&r2=221844&view=diff
==============================================================================
--- cfe/trunk/include/clang/Config/config.h.in (original)
+++ cfe/trunk/include/clang/Config/config.h.in Wed Nov 12 18:35:23 2014
@@ -14,9 +14,6 @@
/* Directories clang will search for headers */
#undef C_INCLUDE_DIRS
-/* Linker version detected at compile time. */
-#undef HOST_LINK_VERSION
-
/* Default <path> to all compiler invocations for --sysroot=<path>. */
#undef DEFAULT_SYSROOT
@@ -31,4 +28,7 @@
/* The LLVM product name and version */
#define BACKEND_PACKAGE_STRING PACKAGE_STRING
+/* Linker version detected at compile time. */
+#undef HOST_LINK_VERSION
+
#endif
Added: cfe/trunk/test/Driver/darwin-ld-demangle.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld-demangle.c?rev=221844&view=auto
==============================================================================
--- cfe/trunk/test/Driver/darwin-ld-demangle.c (added)
+++ cfe/trunk/test/Driver/darwin-ld-demangle.c Wed Nov 12 18:35:23 2014
@@ -0,0 +1,8 @@
+// REQUIRES: system-darwin
+
+// On Darwin, -demangle is passed to the linker of HOST_LINK_VERSION
+// is high enough. It is assumed to be high enough on systems where
+// this test gets run.
+
+// RUN: %clang -### %s 2>&1 | FileCheck %s
+// CHECK: -demangle
More information about the cfe-commits
mailing list