Skip to content

Commit

Permalink
[dotnet] Fix the identity for mono's dynamic libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Jun 19, 2020
1 parent 085a742 commit be3568f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,32 @@
</CompileNativeCode>
</Target>


<!-- The .dylibs shipped with mono comes with the original identity:
$ otool -l ~/.nuget/packages/microsoft.netcore.app.runtime.ios-x64/5.0.0-*/runtimes/ios-x64/native/libSystem.IO.Compression.Native.dylib | grep LC_ID_DYLIB -A 2
cmd LC_ID_DYLIB
cmdsize 184
name /Users/runner/runners/2.165.2/work/1/s/artifacts/obj/native/netcoreapp5.0-iOS-Release-x64/System.IO.Compression.Native/libSystem.IO.Compression.Native.dylib (offset 24)
This doesn't work after linking with these libraries, so this must be fixed to be @executable_path/. Eventually mono will ship dylibs we don't have to fix (https://github.com/dotnet/runtime/issues/34637).
-->
<Target Name="_UpdateDynamicLibraryId" DependsOnTargets="_ComputeVariables" Inputs="@(_MonoLibrary)" Outputs="@(_MonoLibrary -> '$(_IntermediateNativeLibraryDir)%(Filename)%(Extension)')">
<!-- install_name_tool modifies the file in-place, so copy it first to a temporary directory before we fix it -->
<Copy SourceFiles="%(_MonoLibrary.FullPath)" DestinationFolder="$(_IntermediateNativeLibraryDir)" />
<Exec Command="install_name_tool -id @executable_path/%(_MonoLibrary.Filename)%(_MonoLibrary.Extension) $(_IntermediateNativeLibraryDir)%(_MonoLibrary.Filename)%(_MonoLibrary.Extension)" />
<!-- Update our item groups -->
<ItemGroup>
<_MonoLibraryFixed Include="@(_MonoLibrary -> '$(_IntermediateNativeLibraryDir)%(Filename)%(Extension)')" />
<ResolvedFileToPublish Remove="@(_MonoLibrary)" />
<ResolvedFileToPublish Include="@(_MonoLibraryFixed)" />
<_MonoLibrary Remove="@(_MonoLibrary)" />
<_MonoLibrary Include="@(_MonoLibraryFixed)" />
</ItemGroup>
</Target>

<Target Name="_LinkNativeExecutable"
DependsOnTargets="_DetectSdkLocations;_ComputeTargetArchitectures;_GenerateBundleName;_CompileNativeExecutable;_CompileAppManifest"
DependsOnTargets="_DetectSdkLocations;_ComputeTargetArchitectures;_GenerateBundleName;_CompileNativeExecutable;_CompileAppManifest;_UpdateDynamicLibraryId"
Inputs="@(_NativeExecutableObjectFiles)"
Outputs="$(_IntermediateNativeLibraryDir)$(_NativeExecutableName)"
>
Expand Down

0 comments on commit be3568f

Please sign in to comment.