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

loader: suggest to set crate type explicitly #17943

Closed
wants to merge 1 commit into from

Conversation

JIghtuse
Copy link
Contributor

Now loader suggests to set crate type explicitly if it founds file with
name similar to crate name, but different extension.

This commit adds warning if loader found static library instead of rlib
or dylib.
Closes #14416.

Now loader suggests to set crate type explicitly if it founds file with
name similar to crate name, but different extension.

This commit adds warning if loader found static library instead of rlib
or dylib. It fixes issue rust-lang#14416.
--crate-type rlib instead.",
self.crate_name, self.crate_name);
self.sess.span_warn(self.span, msg.as_slice());
}
Copy link
Member

Choose a reason for hiding this comment

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

In this case we actually try to defer warnings such as this until the loading of the crate has failed entirely. It could be the case that a library is compiled as both an rlib and a staticlib, in which case this could end up just being a spurious warning.

Could this modify report_load_errs instead? You'll want to sort of flag some logic here to modify some internal state about the libs that were found as staticlibs, but the actual warnings/notes should be printed out at the end.

Also, can you add a test for this? It would likely be a run-make test in the src/test/run-make folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcrichton ok, I'll try to do that. My solution is indeed too rough to use.

@alexcrichton
Copy link
Member

ping @JIghtuse, any updates here?

@JIghtuse
Copy link
Contributor Author

@alexcrichton pong.
I'm currently stuck with borrowing. I can't change internal state of Context inside of path searching loop. How it can be made Rust-way?

@alexcrichton
Copy link
Member

Do you have a branch that I could take a peek at?

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to reopen with comments addressed!

lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 29, 2024
fix: Improve proc-macro panic message and workspace loading failure diagnostic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message when attempting to use a crate that was created as a staticlib instead of an rlib.
2 participants