Skip to content

Commit

Permalink
Remove skip-strip internal implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Mar 20, 2020
1 parent 2264fa0 commit f193079
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 68 deletions.
1 change: 0 additions & 1 deletion eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ while :; do
;;

stripsymbols|-stripsymbols)
__CMakeArgs="-DSTRIP_SYMBOLS=true $__CMakeArgs"
;;

verbose|-verbose)
Expand Down
99 changes: 42 additions & 57 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,62 +250,52 @@ function(target_precompile_header)
endif(MSVC)
endfunction()

function(strip_symbols targetName outputFilename skipStrip)
function(strip_symbols targetName outputFilename)
if (CLR_CMAKE_HOST_UNIX)
if (STRIP_SYMBOLS)
set(strip_source_file $<TARGET_FILE:${targetName}>)

if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(strip_destination_file ${strip_source_file}.dwarf)

if(NOT ${skipStrip})
# Ensure that dsymutil and strip are present
find_program(DSYMUTIL dsymutil)
if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND")
message(FATAL_ERROR "dsymutil not found")
endif()

find_program(STRIP strip)
if (STRIP STREQUAL "STRIP-NOTFOUND")
message(FATAL_ERROR "strip not found")
endif()

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)

if(NOT ${skipStrip})
add_custom_command(
TARGET ${targetName}
POST_BUILD
VERBATIM
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
COMMAND ${CMAKE_OBJCOPY} --strip-debug ${strip_source_file}
COMMAND ${CMAKE_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(strip_source_file $<TARGET_FILE:${targetName}>)

if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(strip_destination_file ${strip_source_file}.dwarf)

set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
endif (STRIP_SYMBOLS)
# Ensure that dsymutil and strip are present
find_program(DSYMUTIL dsymutil)
if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND")
message(FATAL_ERROR "dsymutil not found")
endif()

find_program(STRIP strip)
if (STRIP STREQUAL "STRIP-NOTFOUND")
message(FATAL_ERROR "strip not found")
endif()

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}
)
else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(strip_destination_file ${strip_source_file}.dbg)

add_custom_command(
TARGET ${targetName}
POST_BUILD
VERBATIM
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
COMMAND ${CMAKE_OBJCOPY} --strip-debug ${strip_source_file}
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
)
endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)

set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
endif(CLR_CMAKE_HOST_UNIX)
endfunction()

function(install_symbols targetName destination_path)
install_symbols_with_skip(${targetName} ${destination_path} NO)
endfunction()

function(install_symbols_with_skip targetName destination_path skipStrip)
strip_symbols(${targetName} strip_destination_file ${skipStrip})
strip_symbols(${targetName} strip_destination_file)

if(CLR_CMAKE_TARGET_WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${destination_path}/PDB)
Expand All @@ -314,9 +304,8 @@ function(install_symbols_with_skip targetName destination_path skipStrip)
endif()
endfunction()

# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination] [SKIP_STRIP])
# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination])
function(install_clr)
set(options SKIP_STRIP)
set(oneValueArgs DESTINATION)
set(multiValueArgs TARGETS)
cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}")
Expand All @@ -332,11 +321,7 @@ 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)
if("${INSTALL_CLR_SKIP_STRIP}" STREQUAL "")
set(INSTALL_CLR_SKIP_STRIP FALSE)
endif()

install_symbols_with_skip(${targetName} ${INSTALL_CLR_DESTINATION} ${INSTALL_CLR_SKIP_STRIP})
install_symbols(${targetName} ${INSTALL_CLR_DESTINATION})

# We don't need to install the export libraries for our DLLs
# since they won't be directly linked against.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/debug/createdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ target_link_libraries(createdump
add_dependencies(createdump mscordaccore)

install_clr(TARGETS createdump)
install_clr(TARGETS createdump DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS createdump DESTINATION sharedFramework)
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/clretwrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ add_library_clr(clretwrc SHARED

# add the install targets
install_clr(TARGETS clretwrc)
install_clr(TARGETS clretwrc DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS clretwrc DESTINATION sharedFramework)

add_dependencies(clretwrc eventing_headers)
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})

# add the install targets
install_clr(TARGETS dbgshim)
install_clr(TARGETS dbgshim DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS dbgshim DESTINATION sharedFramework)
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})

# add the install targets
install_clr(TARGETS mscordaccore)
install_clr(TARGETS mscordaccore DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS mscordaccore DESTINATION sharedFramework)

if(CLR_CMAKE_HOST_WIN32)
set(LONG_NAME_HOST_ARCH ${CLR_CMAKE_HOST_ARCH})
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ endif(CLR_CMAKE_HOST_WIN32)

# add the install targets
install_clr(TARGETS mscordbi)
install_clr(TARGETS mscordbi DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS mscordbi DESTINATION sharedFramework)
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ endif(CLR_CMAKE_TARGET_WIN32)

# add the install targets
install_clr(TARGETS coreclr)
install_clr(TARGETS coreclr DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS coreclr DESTINATION sharedFramework)

# Enable profile guided optimization
add_pgo(coreclr)
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/mscorrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(CLR_CMAKE_HOST_WIN32)
)

install_clr(TARGETS mscorrc)
install_clr(TARGETS mscorrc DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS mscorrc DESTINATION sharedFramework)
else()
build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE)

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif(FEATURE_READYTORUN)
add_jit(clrjit)

# add the install targets
install_clr(TARGETS clrjit DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS clrjit DESTINATION sharedFramework)

# Enable profile guided optimization
add_pgo(clrjit)
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ set_target_properties(coreclrtraceptprovider PROPERTIES LINKER_LANGUAGE CXX)
_install(TARGETS eventprovider DESTINATION lib)
# Install the static coreclrtraceptprovider library
install_clr(TARGETS coreclrtraceptprovider)
install_clr(TARGETS coreclrtraceptprovider DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS coreclrtraceptprovider DESTINATION sharedFramework)
2 changes: 1 addition & 1 deletion src/coreclr/src/tools/crossgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ add_subdirectory(../../vm/crossgen ../../vm/crossgen)

# add the install targets
install_clr(TARGETS crossgen)
install_clr(TARGETS crossgen DESTINATION sharedFramework SKIP_STRIP)
install_clr(TARGETS crossgen DESTINATION sharedFramework)

0 comments on commit f193079

Please sign in to comment.