From a908b4ec2199c9bbf9a710f9cbe6bf48cb1b9755 Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Tue, 25 Jun 2024 16:18:02 +0300
Subject: [PATCH 1/7] Print linking instructions for NativeLib=static
---
.../Microsoft.NETCore.Native.Publish.targets | 68 +++++++++++++++++++
.../Microsoft.NETCore.Native.targets | 6 +-
2 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index d8783480def1f7..44ce44640acf21 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -128,4 +128,72 @@
Condition="'$(_symbolIsFile)' == 'false' and Exists('$(_symbolSourcePath)')" />
+
+
+
+ <_TransformedList Include="$([System.Text.RegularExpressions.Regex]::Replace(
+ $([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"${IlcFrameworkPath}"')),
+ '^$(IlcSdkPath)', '"${IlcSdkPath}"'))" Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'" />
+
+
+
+ <_LinkerArgs>@(_TransformedList -> ' %(Identity)', ' %5C%0D%0A')
+
+
+
+
+
+
+ <_LinkerArgs>@(_TransformedList -> ' %(Identity)', ' %5E%0D%0A')
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
index dead34d2bfbf84..20880e11632654 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
@@ -332,9 +332,9 @@ The .NET Foundation licenses this file to you under the MIT license.
DependsOnTargets="$(LinkNativeDependsOn)">
-
-
-
+
+
+
From 9c1fa9820ce1df2e154381a345c709fe6ddc88af Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Tue, 25 Jun 2024 17:36:11 +0300
Subject: [PATCH 2/7] Use %var% syntax on windows
---
.../Microsoft.NETCore.Native.Publish.targets | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index 44ce44640acf21..38b14742ae328d 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -131,7 +131,7 @@
-
+
<_TransformedList Include="$([System.Text.RegularExpressions.Regex]::Replace(
$([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"${IlcFrameworkPath}"')),
'^$(IlcSdkPath)', '"${IlcSdkPath}"'))" Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'" />
@@ -162,6 +162,12 @@ $(_LinkerArgs)
+
+ <_TransformedList Include="$([System.Text.RegularExpressions.Regex]::Replace(
+ $([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"%IlcFrameworkPath%"')),
+ '^$(IlcSdkPath)', '"%IlcSdkPath%"'))" Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'" />
+
+
<_LinkerArgs>@(_TransformedList -> ' %(Identity)', ' %5E%0D%0A')
From 5d14ca9e3a6dc924a48e8767741d200fca65bbf3 Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Tue, 25 Jun 2024 17:37:25 +0300
Subject: [PATCH 3/7] Format
---
.../Microsoft.NETCore.Native.Publish.targets | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index 38b14742ae328d..6a4d7f652217f8 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -132,9 +132,10 @@
Condition="'$(NativeLib)' == 'Static' and '$(SkipLinkingInstructions)' != 'true'">
- <_TransformedList Include="$([System.Text.RegularExpressions.Regex]::Replace(
+ <_TransformedList Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'"
+ Include="$([System.Text.RegularExpressions.Regex]::Replace(
$([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"${IlcFrameworkPath}"')),
- '^$(IlcSdkPath)', '"${IlcSdkPath}"'))" Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'" />
+ '^$(IlcSdkPath)', '"${IlcSdkPath}"'))" />
@@ -163,9 +164,10 @@ $(_LinkerArgs)
- <_TransformedList Include="$([System.Text.RegularExpressions.Regex]::Replace(
+ <_TransformedList Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'"
+ Include="$([System.Text.RegularExpressions.Regex]::Replace(
$([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"%IlcFrameworkPath%"')),
- '^$(IlcSdkPath)', '"%IlcSdkPath%"'))" Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'" />
+ '^$(IlcSdkPath)', '"%IlcSdkPath%"'))" />
From 4aab2a35f7a0ced34a6e0ce8603d6e520c1c3319 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 25 Jun 2024 19:41:17 +0300
Subject: [PATCH 4/7] Fix windows quoting issues
---
.../Microsoft.NETCore.Native.Publish.targets | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index 6a4d7f652217f8..1f004c574b28d3 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -166,8 +166,8 @@ $(_LinkerArgs)
<_TransformedList Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'"
Include="$([System.Text.RegularExpressions.Regex]::Replace(
- $([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"%IlcFrameworkPath%"')),
- '^$(IlcSdkPath)', '"%IlcSdkPath%"'))" />
+ $([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape(`%(CustomLinkerArg.Identity)`))', '^"$(IlcFrameworkNativePath.Replace(`\`, `\\`))', '"%IlcFrameworkPath%')),
+ '^"$(IlcSdkPath.Replace(`\`, `\\`))', '"%IlcSdkPath%'))" />
@@ -178,15 +178,15 @@ $(_LinkerArgs)
Follow these steps to link your code with the statically compiled AOT binaries:
-```cmd
-# Set some ILCompiler paths for convenience
-set IlcSdkPath="$(IlcSdkPath)"
-set IlcFrameworkPath="$(IlcFrameworkNativePath)"
+```batch
+:: Set some ILCompiler paths for convenience
+set IlcSdkPath=$(IlcSdkPath)
+set IlcFrameworkPath=$(IlcFrameworkNativePath)
-# Compile your native code, e.g.
+:: Compile your native code, e.g.
cl.exe -c glue.c /Foglue.o
-# Link your glue with AOT static libs
+:: Link your glue with AOT static libs
cl.exe glue.o /Fe:"myexe.exe" %5E
"$(PublishDir)\$(TargetName)$(NativeBinaryExt)" %5E
$(_LinkerArgs)
From c1d5ce4d022f74ee886a537ab886c7bdab5299ca Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Wed, 26 Jun 2024 16:57:50 +0300
Subject: [PATCH 5/7] Generate flatten list
---
.../Microsoft.NETCore.Native.Publish.targets | 75 +++----------------
.../Microsoft.NETCore.Native.Unix.targets | 2 +-
2 files changed, 11 insertions(+), 66 deletions(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index 1f004c574b28d3..e7fd81dc3743df 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -131,76 +131,21 @@
-
- <_TransformedList Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'"
- Include="$([System.Text.RegularExpressions.Regex]::Replace(
- $([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape("%(CustomLinkerArg.Identity)"))', '^$(IlcFrameworkNativePath)', '"${IlcFrameworkPath}"')),
- '^$(IlcSdkPath)', '"${IlcSdkPath}"'))" />
-
-
-
- <_LinkerArgs>@(_TransformedList -> ' %(Identity)', ' %5C%0D%0A')
-
-
-
-
-
-
- <_TransformedList Condition="'%(CustomLinkerArg.ExcludeFromStaticInstructions)' != 'true'"
- Include="$([System.Text.RegularExpressions.Regex]::Replace(
- $([System.Text.RegularExpressions.Regex]::Replace('$([MSBuild]::Escape(`%(CustomLinkerArg.Identity)`))', '^"$(IlcFrameworkNativePath.Replace(`\`, `\\`))', '"%IlcFrameworkPath%')),
- '^"$(IlcSdkPath.Replace(`\`, `\\`))', '"%IlcSdkPath%'))" />
+
+
+
+
-
- <_LinkerArgs>@(_TransformedList -> ' %(Identity)', ' %5E%0D%0A')
-
-
-
-
+
-
-
-
+
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
index d3dc85e04f82e4..1195ae7b5b9686 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
@@ -250,7 +250,7 @@ The .NET Foundation licenses this file to you under the MIT license.
-
+
From b84ccd3e3831b1aad2ae40d5e951ff0f260c66ba Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Wed, 26 Jun 2024 16:59:01 +0300
Subject: [PATCH 6/7] Prefix linker opt with -Wl
---
.../nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
index 20880e11632654..7df9b569c88725 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
@@ -337,7 +337,7 @@ The .NET Foundation licenses this file to you under the MIT license.
-
+
From 57ce66f07a39fc65a4777e94659ecd8996de9958 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Mon, 1 Jul 2024 10:45:11 +0300
Subject: [PATCH 7/7] Update
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
---
.../nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
index bf589c94f58bfc..8e111b681d0fca 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
@@ -81,7 +81,7 @@ The .NET Foundation licenses this file to you under the MIT license.
$(NativeIntermediateOutputPath)$(TargetName)$(NativeObjectExt)
$(NativeOutputPath)$(TargetName)$(NativeBinaryExt)
- true
+ true
$(NativeIntermediateOutputPath)$(TargetName)$(ExportsFileExt)
$(NativeObject)