Skip to content

Do not output multiple #[link directives for same library? #475

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

Closed
knopp opened this issue Jan 29, 2021 · 2 comments
Closed

Do not output multiple #[link directives for same library? #475

knopp opened this issue Jan 29, 2021 · 2 comments
Labels
question Further information is requested

Comments

@knopp
Copy link

knopp commented Jan 29, 2021

I just noticed a huge large amount of "USER32.lib" repetitions in the linker command.

It seems that for every method annotated with #[link(name = "USER32")] rust adds "USER32.lib" in linker command line, regardless of whether the method was called or not. Perhaps harmless but it doesn't seem right. I'm not entirely sure if this is windows-rs issue or rust issue, though it should be fixable on windows-rs side by not generating #link directive for a library more than once.

@kennykerr
Copy link
Collaborator

This is mostly a Rust compiler issue. The fact that a declaration exists in a library, doesn't mean the executable is calling that import. I noticed this myself and consider that a compiler bug. I'm not sure whether others agree, but that's not the way C++ works. I don't really see how windows-rs can do much about this. Since the imports span modules, I necessarily need to have multiple link attributes. The long-term plan is to move away from libs entirely, so I'm reluctant to do much more work here anyway. See #463

@kennykerr kennykerr added the question Further information is requested label Jan 30, 2021
@knopp
Copy link
Author

knopp commented Jan 30, 2021

Fair enough. At this point it seems more like a nitpick (doesn't seem to affect functionality) so I'm closing the issue. Thanks for quick reply!

@knopp knopp closed this as completed Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants