Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a additional linker flags for libraries in NuGets #17665

Open
rolfbjarne opened this issue Mar 2, 2023 · 0 comments
Open

Add support for a additional linker flags for libraries in NuGets #17665

rolfbjarne opened this issue Mar 2, 2023 · 0 comments
Labels
feature A feature to be implemented
Milestone

Comments

@rolfbjarne
Copy link
Member

We have support for custom linker flags creating NuGets from binding projects: they're stored either in a LinkWith attribute in the assembly or a manifest next to the assembly or in a binding resource package.

However, we don't have any support for additional linker flags when we link with libraries from a NuGet that don't come from a binding project (those automatically added to ResolvedFileToPublish by NuGet's logic, see https://github.com/xamarin/xamarin-macios/blob/main/dotnet/BundleContents.md for more info).

This is particularly common for NuGets that have support for numerous platforms, in which case the native library will likely be a C library, and not have any specific binding code for our platforms.

We should come up with a solution here.

Idea: add support for a manifest file next to the library. This file would have the same format as our other manifest file.

Example manifest file:

<BindingAssembly>
	<NativeReference Name="libtest.a">
		<ForceLoad></ForceLoad>
		<Frameworks>CoreLocation Foundation ModelIO</Frameworks>
		<IsCxx></IsCxx>
		<Kind>Static</Kind>
		<LinkerFlags></LinkerFlags>
		<NeedsGccExceptionHandling></NeedsGccExceptionHandling>
		<SmartLink></SmartLink>
		<WeakFrameworks></WeakFrameworks>
	</NativeReference>
</BindingAssembly>

this file would be next to wherever libtest.a is in the NuGet (named libtest.manifest).

In theory these linker flags are only needed for static libraries, not for dylibs nor xcframeworks, but it should be trivial to add support for the manifest file for all types of libraries, so we should just do that as well (this could become useful if we use the manifest file to store more information in the future).

@rolfbjarne rolfbjarne added the feature A feature to be implemented label Mar 2, 2023
@rolfbjarne rolfbjarne added this to the .NET 9 milestone Mar 2, 2023
@rolfbjarne rolfbjarne modified the milestones: .NET 9, .NET 10 Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature to be implemented
Projects
None yet
Development

No branches or pull requests

1 participant