diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 0969caf1fb98e8..ed5d2cac5a46ab 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -759,6 +759,9 @@ if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI) add_linker_flag(-Wl,-dead_strip CHECKED RELEASE RELWITHDEBINFO) elseif(NOT LD_SOLARIS) add_linker_flag(-Wl,--gc-sections CHECKED RELEASE RELWITHDEBINFO) + if (NOT LD_GNU AND NOT CLR_CMAKE_TARGET_ARCH_WASM) + add_linker_flag(-Wl,--icf=all RELEASE RELWITHDEBINFO) + endif() endif() # Specify the minimum supported version of macOS diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 842ced25c7daad..905f039becd434 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -305,6 +305,7 @@ The .NET Foundation licenses this file to you under the MIT license. +