Fix RHEL6 build (dotnet/coreclr#27863)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Wed, 13 Nov 2019 22:14:57 +0000 (14:14 -0800)
committerViktor Hofer <viktor.hofer@microsoft.com>
Wed, 13 Nov 2019 22:14:57 +0000 (23:14 +0100)
* Make stripping symbols overridable at install_clr invocation to avoid double-stripping symbols.

* Add SKIP_STRIP option to install_clr parameter list comment

Commit migrated from https://github.com/dotnet/coreclr/commit/2b9559b69dc0375e42966a96e874a6b81b6334d1

src/coreclr/functions.cmake
src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt
src/coreclr/src/dlls/clretwrc/CMakeLists.txt
src/coreclr/src/dlls/dbgshim/CMakeLists.txt
src/coreclr/src/dlls/mscordac/CMakeLists.txt
src/coreclr/src/dlls/mscordbi/CMakeLists.txt
src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt
src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt
src/coreclr/src/jit/standalone/CMakeLists.txt
src/coreclr/src/tools/crossgen/CMakeLists.txt

index ed2961d..5db138c 100644 (file)
@@ -250,7 +250,7 @@ function(target_precompile_header)
   endif(MSVC)
 endfunction()
 
-function(strip_symbols targetName outputFilename)
+function(strip_symbols targetName outputFilename skipStrip)
   if (CLR_CMAKE_PLATFORM_UNIX)
     if (STRIP_SYMBOLS)
       set(strip_source_file $<TARGET_FILE:${targetName}>)
@@ -258,26 +258,30 @@ function(strip_symbols targetName outputFilename)
       if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
         set(strip_destination_file ${strip_source_file}.dwarf)
 
-        add_custom_command(
-          TARGET ${targetName}
-          POST_BUILD
-          VERBATIM
-          COMMAND ${DSYMUTIL} --flat --minimize ${strip_source_file}
-          COMMAND ${STRIP} -S ${strip_source_file}
-          COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
-        )
+        if(NOT ${skipStrip})
+            add_custom_command(
+            TARGET ${targetName}
+            POST_BUILD
+            VERBATIM
+            COMMAND ${DSYMUTIL} --flat --minimize ${strip_source_file}
+            COMMAND ${STRIP} -S ${strip_source_file}
+            COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
+            )
+        endif()
       else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
         set(strip_destination_file ${strip_source_file}.dbg)
 
-        add_custom_command(
-          TARGET ${targetName}
-          POST_BUILD
-          VERBATIM
-          COMMAND ${OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
-          COMMAND ${OBJCOPY} --strip-debug ${strip_source_file}
-          COMMAND ${OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
-          COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
-        )
+        if(NOT ${skipStrip})
+            add_custom_command(
+            TARGET ${targetName}
+            POST_BUILD
+            VERBATIM
+            COMMAND ${OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
+            COMMAND ${OBJCOPY} --strip-debug ${strip_source_file}
+            COMMAND ${OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
+            COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
+            )
+        endif()
       endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
 
       set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
@@ -285,9 +289,9 @@ function(strip_symbols targetName outputFilename)
   endif(CLR_CMAKE_PLATFORM_UNIX)
 endfunction()
 
-# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination])
+# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination] [SKIP_STRIP])
 function(install_clr)
-  set(options "")
+  set(options SKIP_STRIP)
   set(oneValueArgs DESTINATION)
   set(multiValueArgs TARGETS)
   cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}")
@@ -303,7 +307,10 @@ function(install_clr)
   foreach(targetName ${INSTALL_CLR_TARGETS})
     list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX)
     if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1)
-        strip_symbols(${targetName} strip_destination_file)
+        if("${INSTALL_CLR_SKIP_STRIP}" STREQUAL "")
+            set(INSTALL_CLR_SKIP_STRIP FALSE)
+        endif()
+        strip_symbols(${targetName} strip_destination_file ${INSTALL_CLR_SKIP_STRIP})
 
         # We don't need to install the export libraries for our DLLs
         # since they won't be directly linked against.
index 71e1533..7478bd8 100644 (file)
@@ -93,5 +93,5 @@ verify_dependencies(
 
 # add the install targets
 install_clr(TARGETS System.Globalization.Native)
-install_clr(TARGETS System.Globalization.Native DESTINATION sharedFramework)
+install_clr(TARGETS System.Globalization.Native DESTINATION sharedFramework SKIP_STRIP)
 install(TARGETS System.Globalization.Native_Static DESTINATION .)
index 8598baf..e1e49a7 100644 (file)
@@ -21,6 +21,6 @@ add_library_clr(clretwrc SHARED
 
 # add the install targets
 install_clr(TARGETS clretwrc)
-install_clr(TARGETS clretwrc DESTINATION sharedFramework)
+install_clr(TARGETS clretwrc DESTINATION sharedFramework SKIP_STRIP)
 
 add_dependencies(clretwrc eventing_headers)
index d355f01..3e9b088 100644 (file)
@@ -82,4 +82,4 @@ target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})
 
 # add the install targets
 install_clr(TARGETS dbgshim)
-install_clr(TARGETS dbgshim DESTINATION sharedFramework)
+install_clr(TARGETS dbgshim DESTINATION sharedFramework SKIP_STRIP)
index 91af96d..cbb194e 100644 (file)
@@ -185,7 +185,7 @@ target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})
 
 # add the install targets
 install_clr(TARGETS mscordaccore)
-install_clr(TARGETS mscordaccore DESTINATION sharedFramework)
+install_clr(TARGETS mscordaccore DESTINATION sharedFramework SKIP_STRIP)
 if(WIN32)
     set(LONG_NAME_HOST_ARCH ${CLR_CMAKE_HOST_ARCH})
     set(LONG_NAME_TARGET_ARCH ${CLR_CMAKE_TARGET_ARCH})
index b586319..ad94607 100644 (file)
@@ -119,4 +119,4 @@ endif(WIN32)
 
 # add the install targets
 install_clr(TARGETS mscordbi)
-install_clr(TARGETS mscordbi DESTINATION sharedFramework)
+install_clr(TARGETS mscordbi DESTINATION sharedFramework SKIP_STRIP)
index 04e48a4..7a064a8 100644 (file)
@@ -203,7 +203,7 @@ endif(WIN32)
 
 # add the install targets
 install_clr(TARGETS coreclr)
-install_clr(TARGETS coreclr DESTINATION sharedFramework)
+install_clr(TARGETS coreclr DESTINATION sharedFramework SKIP_STRIP)
 
 # Enable profile guided optimization
 add_pgo(coreclr)
index d3c2ea8..b23311d 100644 (file)
@@ -7,7 +7,7 @@ if(WIN32)
   )
 
   install_clr(TARGETS mscorrc.debug)
-  install_clr(TARGETS mscorrc.debug DESTINATION sharedFramework)
+  install_clr(TARGETS mscorrc.debug DESTINATION sharedFramework SKIP_STRIP)
 
 else()
   build_resources(${CMAKE_CURRENT_SOURCE_DIR}/../include.rc mscorrc_debug TARGET_CPP_FILE)
index d8ddc6a..82562e0 100644 (file)
@@ -5,4 +5,4 @@ add_library_clr(mscorrc SHARED
 )
 
 install_clr(TARGETS mscorrc)
-install_clr(TARGETS mscorrc DESTINATION sharedFramework)
+install_clr(TARGETS mscorrc DESTINATION sharedFramework SKIP_STRIP)
index 0c4e80c..c8f8574 100644 (file)
@@ -33,7 +33,7 @@ target_link_libraries(clrjit
 
 # add the install targets
 install_clr(TARGETS clrjit)
-install_clr(TARGETS clrjit DESTINATION sharedFramework)
+install_clr(TARGETS clrjit DESTINATION sharedFramework SKIP_STRIP)
 
 # Enable profile guided optimization
 add_pgo(clrjit)
index eb10882..b40c124 100644 (file)
@@ -71,4 +71,4 @@ add_subdirectory(../../vm/crossgen ../../vm/crossgen)
 
 # add the install targets
 install_clr(TARGETS crossgen)
-install_clr(TARGETS crossgen DESTINATION sharedFramework)
+install_clr(TARGETS crossgen DESTINATION sharedFramework SKIP_STRIP)