-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
is missing some --extern
s
#12059
Comments
It is intentional that transitive dependencies are not listed in |
Hi @bjorn3 thanks for take the time.
I'm not sure I see what I understand |
Say
Rustc has no use for this information at all. For transitive dependencies it already records a hash in the crate metadata to prevent the wrong version being used. It only needs help with finding the transitive dependencies, hence why If Another route you can take is to parse the output of |
Since design choice is summarized pretty well, I am going to close this as “won't fix”.
|
Problem
I notice that transitive dependencies are not listed among the
--extern ..=..
arguments torustc
.Maintaining the list myself is acceptable but turn out to be a longer list of dependencies than actually needed.
Steps
RUSTC_WRAPPER
such as:rustc
calls and run it as adocker
build. Say withclap v4.2.1
(using the full tree for clap here):--extern ..=..
than there are--mount
s. With only the--extern
as--mount
the build doesn't pass:Possible Solution(s)
Possible reason: since edition 2018 all externs needn't be mentioned. See: rust-lang/rust#68417 (comment)
A fix I use today is to simply maintain a list of a crate's deps and their deps and so on. This works but it does seem to bring in more deps than are actually required. Minimizing this list means cheaper builds for my wrapper project.
Notes
My script to generate mounts from externs: https://github.com/fenollp/buildxargs/blob/6aff80c1d16b93ea448104fea57e79fe4e6b0b09/tryin.sh
Context: I am writing a
RUSTC_WRAPPER
that usesdocker buildx
. I aim to minimize thedocker
context required to build each crate dependency. Meaning I only mount the paths to--extern
deps. However I notice thatcargo
does not mention every crate required to build a crate: it mentions only the direct dependencies.Is there a flag I can add to
rustc
orcargo
to know what these missing--extern
should be?Also: by manually adding the path to dependencies one by one (selecting these mentioned in the error messages) I notice that a crate's full dependency tree could actually be pruned a bit. See here for
clap v4.2.1
(lib-clap-8996e440435cdc93
):# Short tree: (only iteratively found deps) anstream-47e0535dab3ef0d2 anstyle-3d9b242388653423 anstyle_parse-0d4af9095c79189b bitflags-f255a966af175049 clap_lex-7dfc2f58447e727e concolor_override-305fddcda33650f6 concolor_query-74e38d373bc944a9 io_lifetimes-36f41602071771e6 is_terminal-4b94fef286899229 libc-9de7ca31dbbda4df linux_raw_sys-67b8335e06167307 rustix-120609be99d53c6b strsim-8ed1051e7e58e636 utf8parse-951ca9bdc6d60a50
# Full tree anstream-47e0535dab3ef0d2 anstyle-3d9b242388653423 anstyle_parse-0d4af9095c79189b bitflags-f255a966af175049 clap_builder-02591a0046469edd clap_derive-a4ff03e749cd3808 clap_lex-7dfc2f58447e727e concolor_override-305fddcda33650f6 concolor_query-74e38d373bc944a9 heck-cd1cdbedec0a6dc0 io_lifetimes-36f41602071771e6 is_terminal-4b94fef286899229 libc-9de7ca31dbbda4df linux_raw_sys-67b8335e06167307 once_cell-da1c67e98ff0d3df proc_macro2-ef119f7eb3ef5720 quote-74434efe692a445d rustix-120609be99d53c6b strsim-8ed1051e7e58e636 syn-4befa7538c9a9f80 unicode_ident-417636671c982ef8 utf8parse-951ca9bdc6d60a50
Maybe a shorter/simpler example:
Version
The text was updated successfully, but these errors were encountered: