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

Proposal: More robust handling of dynamic/static libs in winmdgenerator #679

Closed
riverar opened this issue Sep 24, 2021 · 6 comments
Closed
Assignees
Labels
usability Touch-up to improve the user experience for a language projection

Comments

@riverar
Copy link
Collaborator

riverar commented Sep 24, 2021

Summary

The winmdgenerator requires import libraries to generate Windows Metadata describing APIs that reside in both dynamic-link and static libraries. Import libraries are not generally available for static libraries, requiring some additional acrobatics and potentially an additional sidecar project to create an otherwise unused dynamic-link library.

I propose we change winmdgenerator to not require import libs for static library scenarios and instead handle these libraries directly. That is, rather than scan import libraries for matching symbols and then do an awkward remapping to static libraries, we instead read the static libs directly and if a symbol match is found, emit the StaticLibraryAttribute et al.

The project file schema will also need some tweaking, to accommodate.

Before:

<ImportLibs Include="..\..\target\$(Platform)\$(Configuration)\component.lib">
  <StaticLibs>component=static_component</StaticLibs>
</ImportLibs>

After:

<StaticLibs Include="..\..\target\$(Platform)\$(Configuration)\static_component.lib" />

Scope

Capability Priority
Generate Windows Metadata with functions annotated with DllImport and/or StaticLibrary attributes Must
Generate Windows Metadata for static libraries using a MSBuild Project (.proj) Must
Generate Windows Metadata for import libraries using a MSBuild Project (.proj) Must
@mikebattista mikebattista added the usability Touch-up to improve the user experience for a language projection label Sep 24, 2021
@mikebattista
Copy link
Contributor

@sotteson1 do you agree with the proposal?

@sotteson1
Copy link
Contributor

I see what you mean, although in the current implementation, you don't need the static lib to exist for it to work. Also, instead of making a new element, we could have ImportLibs work with both DLL and static libs and detect the difference and do the right thing depending on what it sees. @wravery, what do you think? (Since you were the one who introduced static libs into the emitter.)

@wravery
Copy link
Contributor

wravery commented Sep 24, 2021

Sounds good to me, although I'd like to keep supporting a single winmd for scenarios where both already exist (e.g. WebView2). Can we do it in a way that supports both a standalone static lib and a static lib as an alternative to the DLL? That way we keep the fallback for libraries that include both and projections that don't do static linking.

@riverar
Copy link
Collaborator Author

riverar commented Sep 25, 2021

@wravery I added a table to the original post to cover some requirements. If I understood correctly, you'd like to continue scanning both import/static libs and emit both DllImport and StaticLibrary attributes on functions in the metadata.

@wravery
Copy link
Contributor

wravery commented Sep 25, 2021

Yes, I'd like to have support for either, or both attributes in the same winmd.

@mikebattista mikebattista assigned chenss3 and unassigned sotteson1 Nov 2, 2022
@riverar
Copy link
Collaborator Author

riverar commented May 31, 2023

Stale and my use case vanished, so closing for now. We can revive this when we have new scenarios that need it.

@riverar riverar closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usability Touch-up to improve the user experience for a language projection
Projects
None yet
Development

No branches or pull requests

5 participants