From e1d54da2ba654c99a124a58e09d4864a2dc526b5 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 29 Dec 2020 14:06:22 +0100 Subject: [PATCH] Fix macOS arm64 signature corruption at install Using `install(TARGET...)` for copying built binaries into the artifacts/bin/ results in cmake calling install_name_tool on the binary to set its id, which invalidates the code signature on macOS arm64. We were using `install(TARGET...)` only in the installer, libraries and coreclr use `install(PROGRAMS...)`. This change fixes the problem by replacing the `install(TARGET...)` by `install(PROGRAMS...)`. Even though the `install(TARGET...)` is the intended way to install executables produced by the build in cmake, it is meant for installing the binaries to their final location (like /usr/local/bin etc). But we don't use install in this way, we use it to copy the result into our `artifacts/bin/...` subfolder where the path doesn't match the final binary location in any way. So the extra massaging that cmake does for `install(TARGET...` is useless for our purposes anyways. --- .../ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt | 2 +- .../ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt | 2 +- .../ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt | 2 +- src/installer/corehost/cli/fxr/standalone/CMakeLists.txt | 2 +- .../corehost/cli/hostpolicy/standalone/CMakeLists.txt | 2 +- src/installer/corehost/cli/nethost/CMakeLists.txt | 4 ++-- src/installer/corehost/cli/test/mockcoreclr/CMakeLists.txt | 2 +- src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt | 2 +- src/installer/corehost/cli/test/mockhostpolicy/CMakeLists.txt | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt index b1b5c569673262..27ab46758f821a 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt @@ -63,4 +63,4 @@ else() _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (TARGETS superpmi-shim-collector DESTINATION .) +_install (PROGRAMS $ DESTINATION .) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt index 0e65456fc5c26a..57a42a5ba031bb 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt @@ -65,4 +65,4 @@ else() _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (TARGETS superpmi-shim-counter DESTINATION .) +_install (PROGRAMS $ DESTINATION .) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt index 72fdf073a6d375..58afa789de1a17 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt @@ -64,4 +64,4 @@ else() _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (TARGETS superpmi-shim-simple DESTINATION .) +_install (PROGRAMS $ DESTINATION .) diff --git a/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt index 78f43925f15d21..f079bfc33b8dfe 100644 --- a/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt @@ -37,5 +37,5 @@ if(CLR_CMAKE_HOST_UNIX) set_property(TARGET hostfxr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) endif(CLR_CMAKE_HOST_UNIX) -install_with_stripped_symbols(hostfxr TARGETS corehost) +install_with_stripped_symbols(hostfxr PROGRAMS corehost) target_link_libraries(hostfxr libhostcommon) diff --git a/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt index a0cbbe87f691d5..c5444eed4981c7 100644 --- a/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt @@ -32,5 +32,5 @@ if(CLR_CMAKE_HOST_UNIX) set_property(TARGET hostpolicy APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) endif(CLR_CMAKE_HOST_UNIX) -install_with_stripped_symbols(hostpolicy TARGETS corehost) +install_with_stripped_symbols(hostpolicy PROGRAMS corehost) target_link_libraries(hostpolicy libhostcommon) diff --git a/src/installer/corehost/cli/nethost/CMakeLists.txt b/src/installer/corehost/cli/nethost/CMakeLists.txt index a9f44e7205278d..b8ebdf88e109cc 100644 --- a/src/installer/corehost/cli/nethost/CMakeLists.txt +++ b/src/installer/corehost/cli/nethost/CMakeLists.txt @@ -36,11 +36,11 @@ endif(WIN32) install(FILES ../coreclr_delegates.h DESTINATION corehost) install(FILES ../hostfxr.h DESTINATION corehost) install(FILES nethost.h DESTINATION corehost) -install_with_stripped_symbols(nethost TARGETS corehost) +install_with_stripped_symbols(nethost PROGRAMS corehost) # Only Windows creates a symbols file for static libs. if (WIN32) install_with_stripped_symbols(libnethost TARGETS corehost) else() install(TARGETS libnethost DESTINATION corehost) -endif(WIN32) \ No newline at end of file +endif(WIN32) diff --git a/src/installer/corehost/cli/test/mockcoreclr/CMakeLists.txt b/src/installer/corehost/cli/test/mockcoreclr/CMakeLists.txt index f7e202fbc1dff5..f64711a0f484b9 100644 --- a/src/installer/corehost/cli/test/mockcoreclr/CMakeLists.txt +++ b/src/installer/corehost/cli/test/mockcoreclr/CMakeLists.txt @@ -16,4 +16,4 @@ endif() include(../testlib.cmake) -install_with_stripped_symbols(mockcoreclr TARGETS corehost_test) +install_with_stripped_symbols(mockcoreclr PROGRAMS corehost_test) diff --git a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt index 8b5a55fe9b1772..90f72938709ffa 100644 --- a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt +++ b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt @@ -11,4 +11,4 @@ set(SOURCES include(../testlib.cmake) -install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test) +install_with_stripped_symbols(mockhostfxr_2_2 PROGRAMS corehost_test) diff --git a/src/installer/corehost/cli/test/mockhostpolicy/CMakeLists.txt b/src/installer/corehost/cli/test/mockhostpolicy/CMakeLists.txt index 146cf010e3fa6f..e524e485a6d586 100644 --- a/src/installer/corehost/cli/test/mockhostpolicy/CMakeLists.txt +++ b/src/installer/corehost/cli/test/mockhostpolicy/CMakeLists.txt @@ -11,4 +11,4 @@ set(SOURCES include(../testlib.cmake) -install_with_stripped_symbols(mockhostpolicy TARGETS corehost_test) \ No newline at end of file +install_with_stripped_symbols(mockhostpolicy PROGRAMS corehost_test)