From 08214fd71eae5e0f3f985f00060cfe76f2b80591 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Fri, 28 Mar 2025 11:23:04 -0400 Subject: [PATCH 1/3] Fix Unable to load shared library 'jitinterface_x64' build error on linux/mac When crossgen is first built, it writes the executable and shared lib artifacts to `artifacts/bin/coreclr/..//crossgen2`. On subsequent builds, the native libs are cleaned and never copied back even though they are included as items in crossgen.props. This can cause the build to fail later on down the line when we attempt to use the in build crossgen on different assemblies as it won't find the native libs it depends on. To work around the issue, this change adds a target that runs after publish and copies the content items to $(PublishDir). It's not clear if this is a bug in the SDK or something we're not doing correctly. More investigation is suggested. Fixes https://github.com/dotnet/runtime/issues/111731 --- src/coreclr/tools/aot/crossgen2/crossgen2.props | 6 +++--- src/coreclr/tools/aot/crossgen2/crossgen2.targets | 14 ++++++++++++++ .../tools/aot/crossgen2/crossgen2_inbuild.csproj | 2 +- .../tools/aot/crossgen2/crossgen2_publish.csproj | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/coreclr/tools/aot/crossgen2/crossgen2.targets diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2.props b/src/coreclr/tools/aot/crossgen2/crossgen2.props index 2ec464eaa54bd5..b7ec5f35d34726 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2.props +++ b/src/coreclr/tools/aot/crossgen2/crossgen2.props @@ -52,7 +52,7 @@ - $(TargetArchitectureForSharedLibraries) amd64 Microsoft.DiaSymReader.Native.$(DiaSymReaderTargetArch).dll - $(PkgMicrosoft_DiaSymReader_Native)\runtimes\win\native\$(DiaSymReaderTargetArchFileName) + $([MSBuild]::NormalizePath('$(PkgMicrosoft_DiaSymReader_Native)', 'runtimes', 'win', 'native', '$(DiaSymReaderTargetArchFileName)')) - $(CoreCLRArtifactsPath)crossgen2/$(DiaSymReaderTargetArchFileName) + $([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'crossgen2', '$(DiaSymReaderTargetArchFileName)')) diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2.targets b/src/coreclr/tools/aot/crossgen2/crossgen2.targets new file mode 100644 index 00000000000000..afbe313a2073f4 --- /dev/null +++ b/src/coreclr/tools/aot/crossgen2/crossgen2.targets @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj b/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj index f7752670e406fc..73c8e6ec453399 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj +++ b/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj @@ -21,5 +21,5 @@ - + diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj b/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj index c7041857e08577..1a157bc5a3f2ee 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj +++ b/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj @@ -11,4 +11,5 @@ + From 0bdeb1bb0bc9cd59334f983dad6a5f3dda3f16a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 28 Mar 2025 18:11:41 +0100 Subject: [PATCH 2/3] Revert "Fix Unable to load shared library 'jitinterface_x64' build error on linux/mac" This reverts commit 08214fd71eae5e0f3f985f00060cfe76f2b80591. --- src/coreclr/tools/aot/crossgen2/crossgen2.props | 6 +++--- src/coreclr/tools/aot/crossgen2/crossgen2.targets | 14 -------------- .../tools/aot/crossgen2/crossgen2_inbuild.csproj | 2 +- .../tools/aot/crossgen2/crossgen2_publish.csproj | 1 - 4 files changed, 4 insertions(+), 19 deletions(-) delete mode 100644 src/coreclr/tools/aot/crossgen2/crossgen2.targets diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2.props b/src/coreclr/tools/aot/crossgen2/crossgen2.props index b7ec5f35d34726..2ec464eaa54bd5 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2.props +++ b/src/coreclr/tools/aot/crossgen2/crossgen2.props @@ -52,7 +52,7 @@ - $(TargetArchitectureForSharedLibraries) amd64 Microsoft.DiaSymReader.Native.$(DiaSymReaderTargetArch).dll - $([MSBuild]::NormalizePath('$(PkgMicrosoft_DiaSymReader_Native)', 'runtimes', 'win', 'native', '$(DiaSymReaderTargetArchFileName)')) + $(PkgMicrosoft_DiaSymReader_Native)\runtimes\win\native\$(DiaSymReaderTargetArchFileName) - $([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'crossgen2', '$(DiaSymReaderTargetArchFileName)')) + $(CoreCLRArtifactsPath)crossgen2/$(DiaSymReaderTargetArchFileName) diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2.targets b/src/coreclr/tools/aot/crossgen2/crossgen2.targets deleted file mode 100644 index afbe313a2073f4..00000000000000 --- a/src/coreclr/tools/aot/crossgen2/crossgen2.targets +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj b/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj index 73c8e6ec453399..f7752670e406fc 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj +++ b/src/coreclr/tools/aot/crossgen2/crossgen2_inbuild.csproj @@ -21,5 +21,5 @@ - + diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj b/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj index 1a157bc5a3f2ee..c7041857e08577 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj +++ b/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj @@ -11,5 +11,4 @@ - From 734f791fffaad306ed9b7b558845245272122f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 28 Mar 2025 18:12:21 +0100 Subject: [PATCH 3/3] Ensure native libraries in Content are preserved when PublishSingleFile=true --- src/coreclr/tools/aot/crossgen2/crossgen2.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2.props b/src/coreclr/tools/aot/crossgen2/crossgen2.props index 2ec464eaa54bd5..b2ce7bf75992d7 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2.props +++ b/src/coreclr/tools/aot/crossgen2/crossgen2.props @@ -55,12 +55,14 @@ @@ -69,6 +71,7 @@ @@ -94,6 +97,7 @@