Skip to content

Commit 986fba0

Browse files
MichalPetrykaam11jkotas
authored
Enable ICF on Linux (#129762)
It saves on average 2% in size. --------- Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 5beace6 commit 986fba0

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

eng/native/configurecompiler.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI)
759759
add_linker_flag(-Wl,-dead_strip CHECKED RELEASE RELWITHDEBINFO)
760760
elseif(NOT LD_SOLARIS)
761761
add_linker_flag(-Wl,--gc-sections CHECKED RELEASE RELWITHDEBINFO)
762+
if (NOT LD_GNU AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
763+
add_linker_flag(-Wl,--icf=all RELEASE RELWITHDEBINFO)
764+
endif()
762765
endif()
763766

764767
# Specify the minimum supported version of macOS

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ The .NET Foundation licenses this file to you under the MIT license.
305305
<LinkerArg Include="@(ExtraLinkerArg->'-Wl,%(Identity)')" />
306306
<LinkerArg Include="@(NativeFramework->'-framework %(Identity)')" Condition="'$(_IsApplePlatform)' == 'true'" />
307307
<LinkerArg Include="-Wl,--eh-frame-hdr" Condition="'$(_IsApplePlatform)' != 'true'" />
308+
<LinkerArg Include="-Wl,--icf=all" Condition="'$(_IsApplePlatform)' != 'true' and '$(LinkerFlavor)' != 'bfd'" />
308309

309310
<!-- Google requires all the native libraries to be aligned to 16 bytes (for 16k memory page size)
310311
This is required only for 64-bit binaries.

0 commit comments

Comments
 (0)