-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
rustc: Gives inconsistent error messages if a dependency's dependency rlib has an unexpected filename #110460
Comments
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
…ames Previously the library names were directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This worked fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. So now we instead replace them with underscores directly in the target names so consistent names are used everywhere, and also log a warning to notify the user about this happening. See rust-lang/rust#110460
…ames Previously the library names were directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This worked fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. So now we instead replace them with underscores directly in the target names so consistent names are used everywhere, and also log a warning to notify the user about this happening. See rust-lang/rust#110460
…ames Previously the library names were directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This worked fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. So now we instead replace them with underscores directly in the target names so consistent names are used everywhere, and also log a warning to notify the user about this happening. See rust-lang/rust#110460
this doesn't error in the first example because you pass I don't have an explanation for why it errors trying to load |
Yes then it fails directly as expected
Me neither but it behaves as if the rlib "remembers" the crate name but not the filename, and then it reconstructs the filename from the crate name and that doesn't work. |
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
This is expected behavior given the current implementation. To reduce work we prune the list of files we attempt to load to get at the embedded crate name etc. (See https://github.com/rust-lang/rust/blob/master/compiler/rustc_metadata/src/locator.rs#L73-L84 for a summary of the steps). The indistinguishable error seems separate though, not quite sure there. |
That makes sense, thanks for checking. Considering that this is a constraint of the current implementation, it would probably make sense to check this during compilation of the first rlib (in this case) and fail directly as it won't be usable at a later step? |
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See rust-lang/rust#110460
Note that the following can only happen when calling
rustc
directly instead of going throughcargo
ascargo
uses an rlib filename scheme that works and AFAIU doesn't allow overriding that anyway.I tried this code:
a/lib.rs
:b/lib.rs
:c/main.rs
:When compiling this as follows it will fail on the third
rustc
invocation.This gives the following error with latest stable (1.68.2) and also 660c966
Note that the crate name of a is
some_a
while the rlib file is calledliba.rlib
. If changing either the crate name toa
or the filename tolibsome_a.rlib
it works.More confusingly, when using 660c966 and uncommenting the
use b::foo
line, it gives a different errorI would expect
rustc
invocation above), or compilation of the above testcase should work fineThe text was updated successfully, but these errors were encountered: