From 80202e3ec8b380e05b8666f37bbc43bde108cf8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Petryka?=
<35800402+MichalPetryka@users.noreply.github.com>
Date: Tue, 23 Jun 2026 20:15:07 +0200
Subject: [PATCH 1/5] Try enabling ICF on Linux
Opening to see CI results and size diffs
---
eng/native/configurecompiler.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake
index ee9d2b574c543d..58f770a40fa358 100644
--- a/eng/native/configurecompiler.cmake
+++ b/eng/native/configurecompiler.cmake
@@ -759,6 +759,7 @@ 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)
+ add_linker_flag(-Wl,--icf=all RELEASE RELWITHDEBINFO)
endif()
# Specify the minimum supported version of macOS
From d6cf672dbc1f5373e3485bf4a70ead7a1ff4e7cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Petryka?=
<35800402+MichalPetryka@users.noreply.github.com>
Date: Wed, 24 Jun 2026 10:16:48 +0200
Subject: [PATCH 2/5] Update eng/native/configurecompiler.cmake
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
---
eng/native/configurecompiler.cmake | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake
index 58f770a40fa358..fdbb619f127f4a 100644
--- a/eng/native/configurecompiler.cmake
+++ b/eng/native/configurecompiler.cmake
@@ -759,7 +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)
- add_linker_flag(-Wl,--icf=all RELEASE RELWITHDEBINFO)
+ if (NOT LD_GNU)
+ add_linker_flag(-Wl,--icf=all RELEASE RELWITHDEBINFO)
+ endif()
endif()
# Specify the minimum supported version of macOS
From 46f3dcb2410f588ffd65465c6c0c387dcaf96d04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Petryka?=
<35800402+MichalPetryka@users.noreply.github.com>
Date: Wed, 24 Jun 2026 10:24:06 +0200
Subject: [PATCH 3/5] Also enable for NativeAOT
---
.../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
index 1e4afaab8cc578..c30f077a8afabf 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
@@ -289,8 +289,9 @@ The .NET Foundation licenses this file to you under the MIT license.
-
-
+ " />
+
- " />
+
+