<div dir="rtl"><div dir="ltr">Hi Nico,</div><div dir="ltr"><br></div><div dir="ltr">MSVC does not support the -f* flags, so I fixed the add_dead_strip function to be:</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">
<font face="courier new, monospace">function(add_dead_strip target_name)</font></div><div dir="ltr"><font face="courier new, monospace"> if(NOT CYGWIN AND NOT MINGW AND NOT MSVC)</font></div><div dir="ltr"><font face="courier new, monospace"> if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")</font></div>
<div><br></div><div>Yaron</div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div dir="ltr">2013/12/30 Nico Weber <span dir="ltr"><<a href="mailto:nicolasweber@gmx.de" target="_blank">nicolasweber@gmx.de</a>></span></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nico<br>
Date: Sun Dec 29 21:36:05 2013<br>
New Revision: 198198<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=198198&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=198198&view=rev</a><br>
Log:<br>
Port r198087 and r198089 (strip dead code by default) from make to cmake.<br>
<br>
Modified:<br>
llvm/trunk/cmake/modules/AddLLVM.cmake<br>
llvm/trunk/tools/bugpoint/CMakeLists.txt<br>
llvm/trunk/tools/llc/CMakeLists.txt<br>
llvm/trunk/tools/opt/CMakeLists.txt<br>
llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt<br>
<br>
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=198198&r1=198197&r2=198198&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=198198&r1=198197&r2=198198&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)<br>
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Sun Dec 29 21:36:05 2013<br>
@@ -76,10 +76,30 @@ function(add_llvm_symbol_exports target_<br>
add_dependencies(${target_name} ${target_name}_exports)<br>
endfunction(add_llvm_symbol_exports)<br>
<br>
+function(add_dead_strip target_name)<br>
+ if(NOT CYGWIN AND NOT MINGW)<br>
+ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")<br>
+ SET(CMAKE_CXX_FLAGS<br>
+ "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections"<br>
+ PARENT_SCOPE)<br>
+ endif()<br>
+ endif()<br>
+ if(NOT LLVM_NO_DEAD_STRIP)<br>
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")<br>
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY<br>
+ LINK_FLAGS " -Wl,-dead_strip")<br>
+ elseif(NOT WIN32)<br>
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY<br>
+ LINK_FLAGS " -Wl,--gc-sections")<br>
+ endif()<br>
+ endif()<br>
+endfunction(add_dead_strip)<br>
+<br>
macro(add_llvm_library name)<br>
llvm_process_sources( ALL_FILES ${ARGN} )<br>
add_library( ${name} ${ALL_FILES} )<br>
set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )<br>
+ add_dead_strip( ${name} )<br>
if( LLVM_COMMON_DEPENDS )<br>
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )<br>
endif( LLVM_COMMON_DEPENDS )<br>
@@ -137,6 +157,7 @@ ${name} ignored.")<br>
<br>
add_library( ${name} ${libkind} ${ALL_FILES} )<br>
set_target_properties( ${name} PROPERTIES PREFIX "" )<br>
+ add_dead_strip( ${name} )<br>
<br>
if (LLVM_EXPORTED_SYMBOL_FILE)<br>
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )<br>
@@ -173,6 +194,7 @@ macro(add_llvm_executable name)<br>
else()<br>
add_executable(${name} ${ALL_FILES})<br>
endif()<br>
+ add_dead_strip( ${name} )<br>
<br>
if (LLVM_EXPORTED_SYMBOL_FILE)<br>
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )<br>
<br>
Modified: llvm/trunk/tools/bugpoint/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/bugpoint/CMakeLists.txt (original)<br>
+++ llvm/trunk/tools/bugpoint/CMakeLists.txt Sun Dec 29 21:36:05 2013<br>
@@ -16,6 +16,9 @@ set(LLVM_LINK_COMPONENTS<br>
Vectorize<br>
)<br>
<br>
+# Support plugins.<br>
+set(LLVM_NO_DEAD_STRIP 1)<br>
+<br>
add_llvm_tool(bugpoint<br>
BugDriver.cpp<br>
CrashDebugger.cpp<br>
<br>
Modified: llvm/trunk/tools/llc/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llc/CMakeLists.txt (original)<br>
+++ llvm/trunk/tools/llc/CMakeLists.txt Sun Dec 29 21:36:05 2013<br>
@@ -11,6 +11,9 @@ set(LLVM_LINK_COMPONENTS<br>
Target<br>
)<br>
<br>
+# Support plugins.<br>
+set(LLVM_NO_DEAD_STRIP 1)<br>
+<br>
add_llvm_tool(llc<br>
llc.cpp<br>
)<br>
<br>
Modified: llvm/trunk/tools/opt/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/opt/CMakeLists.txt (original)<br>
+++ llvm/trunk/tools/opt/CMakeLists.txt Sun Dec 29 21:36:05 2013<br>
@@ -17,6 +17,9 @@ set(LLVM_LINK_COMPONENTS<br>
Vectorize<br>
)<br>
<br>
+# Support plugins.<br>
+set(LLVM_NO_DEAD_STRIP 1)<br>
+<br>
add_llvm_tool(opt<br>
AnalysisWrappers.cpp<br>
GraphPrinters.cpp<br>
<br>
Modified: llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt?rev=198198&r1=198197&r2=198198&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt (original)<br>
+++ llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt Sun Dec 29 21:36:05 2013<br>
@@ -51,6 +51,9 @@ if(MSVC)<br>
list(APPEND JITTestsSources JITTests.def)<br>
endif()<br>
<br>
+# The JIT tests need to dlopen things.<br>
+set(LLVM_NO_DEAD_STRIP 1)<br>
+<br>
add_llvm_unittest(JITTests<br>
${JITTestsSources}<br>
)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>