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

Disable linker warning LNK4104 when building native AOT libraries #98084

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

MichalStrehovsky
Copy link
Member

link.exe hardcodes a list of magic symbol names that it thinks should not be generated into import library and emits warnings if they are.

We don't have a mechanism to set visibility of UnmanagedCallersOnly methods and I don't think we'd want to make a public API for that. But this means that users get a warning that is not particularly actionable. We could either replicate this magic list of symbol names into compiler and generate these as PRIVATE (but then how do people opt out if they don't actually want this as PRIVATE?), or we can just suppress the warning.

This PR suppresses the warning.

Cc @dotnet/ilc-contrib @Sergio0694

@ghost
Copy link

ghost commented Feb 7, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

link.exe hardcodes a list of magic symbol names that it thinks should not be generated into import library and emits warnings if they are.

We don't have a mechanism to set visibility of UnmanagedCallersOnly methods and I don't think we'd want to make a public API for that. But this means that users get a warning that is not particularly actionable. We could either replicate this magic list of symbol names into compiler and generate these as PRIVATE (but then how do people opt out if they don't actually want this as PRIVATE?), or we can just suppress the warning.

This PR suppresses the warning.

Cc @dotnet/ilc-contrib @Sergio0694

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@ghost ghost assigned MichalStrehovsky Feb 7, 2024
@@ -94,6 +94,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Condition="'$(OutputType)' == 'WinExe' or '$(OutputType)' == 'Exe'" Include="/ENTRY:$(EntryPointSymbol) /NOEXP /NOIMPLIB" />
<LinkerArg Include="/NATVIS:&quot;$(MSBuildThisFileDirectory)NativeAOT.natvis&quot;" />
<LinkerArg Condition="'$(ControlFlowGuard)' == 'Guard'" Include="/guard:cf" />
<LinkerArg Include="/IGNORE:4104" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth it to add a comment here with some context, maybe a link to the original issue or something so people will be able to understand why this is here? This suppression seems a bit random and arbitrary otherwise, and I could imagine folks having no idea about the WinRT shenanigans being confused when looking at this 😅

@jkotas jkotas closed this Feb 8, 2024
@jkotas jkotas reopened this Feb 8, 2024
@MichalStrehovsky MichalStrehovsky merged commit f64c078 into main Feb 8, 2024
99 of 110 checks passed
@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky-patch-2 branch February 8, 2024 12:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants