-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiler lookup path separation #19767
Comments
This design seems sensible to me. |
An alternative here is to use prioritization of libraries based on the path they're found in (as traditional linkers do) insead of failing when 2 of the same lib are found. If we do impliment filesearch path categories, do they really eliminate all the duplicate lib conditions we could run into? |
I thought we would be able to do so, but I don't think that it will solve all of our problems. It would primarily not solve rust-lang/cargo#1037 as it wouldn't prevent the operation, and it would only solve #16402 if the compiler's We could still choose to do what traditional linkers do with conflicting libs if we have path categories, however. |
P-backcompat-libs, 1.0. |
Another thing to consider (gcc, ld, and probably others allow) is simply being able to specify the full path to a library when linking, rather than appending a path & library name and hoping that we manage to choose the one intended. Doing this would also allow cargo (and others) to more accurately communicate their intent to rustc. |
That's largely what |
This commit adds support for the compiler to distinguish between different forms of lookup paths in the compiler itself. Issue rust-lang#19767 has some background on this topic, as well as some sample bugs which can occur if these lookup paths are not separated. This commits extends the existing command line flag `-L` with the same trailing syntax as the `-l` flag. Each argument to `-L` can now have a trailing `:all`, `:native`, `:crate`, or `:dependency`. This suffix indicates what form of lookup path the compiler should add the argument to. The `dependency` lookup path is used when looking up crate dependencies, the `crate` lookup path is used when looking for immediate dependencies (`extern crate` statements), and the `native` lookup path is used for probing for native libraries to insert into rlibs. Paths with `all` are used for all of these purposes (the default). The default compiler lookup path (the rustlib libdir) is by default added to all of these paths. Additionally, the `RUST_PATH` lookup path is added to all of these paths. Closes rust-lang#19767
This commit adds support for the compiler to distinguish between different forms of lookup paths in the compiler itself. Issue #19767 has some background on this topic, as well as some sample bugs which can occur if these lookup paths are not separated. This commits extends the existing command line flag `-L` with the same trailing syntax as the `-l` flag. Each argument to `-L` can now have a trailing `:all`, `:native`, `:crate`, or `:dependency`. This suffix indicates what form of lookup path the compiler should add the argument to. The `dependency` lookup path is used when looking up crate dependencies, the `crate` lookup path is used when looking for immediate dependencies (`extern crate` statements), and the `native` lookup path is used for probing for native libraries to insert into rlibs. Paths with `all` are used for all of these purposes (the default). The default compiler lookup path (the rustlib libdir) is by default added to all of these paths. Additionally, the `RUST_PATH` lookup path is added to all of these paths. Closes #19767
Right now the compiler has one lookup path, defined by
-L
andRUST_PATH
. This one lookup path is used for many different purposes, leading to a number of conflicts. In the compiler today there are a number of distinct concepts of lookup paths, including:extern crate
dependenciesextern crate
directives.Conflating all of these concepts into one lookup path leads to bugs such as rust-lang/cargo#1037 and #16402 which would benefit greatly from distinct sets of lookup paths.
I would initially propose something like:
Using this, cargo itself would only pass
-L dependency=...
, build scripts would pass-L native=...
, and normal uses of the compiler would continue just using-L
. This behavior is also backwards compatible with today's semantics.I'd like to nominate this issue, however, as rust-lang/cargo#1037 is quite a worrying issue which needs to be solved as part of Cargo's stability story.
The text was updated successfully, but these errors were encountered: