Repository navigation
Add a way to distinguish proc-macro deps - #1420
Conversation
67a9fd7 to
dcc23d5
Compare
12fb234 to
b4970a1
Compare
1489f6c to
df177cf
Compare
30af393 to
baa9e1b
Compare
|
Hey @UebelAndre -- could you please take a look, I'd appreciate your help. With this I'm hitting an issue on windows build bots (https://buildkite.com/bazel/rules-rust-rustlang/builds/6734#0181d931-f2a4-4427-810d-f18596a5cb4d/237-312). This we suspect is because the addition of a cfg on the deps of a proc-macro pushed some of the absolute path names for the cargo_universe actions over the windows (260 characters), e.g.: |
|
re: #1420 (comment) I think that'd be acceptable but unfortunate. The fundamental problem (#1120) is not solved in the rename and could definitely come back if an external crate just happens to have a long path somewhere. Is there anyone on or around your team that has any amount of windows experience to take a look at the root issues. I know there are ways to tell windows to ignore |
There's a bazel run //crate_universe/3rdparty:crates_vendorThis should update the generated files without changing any of the pins. I filed: |
This is awesome! Thank you very much! |
We will follow-up on #1120. It seems like there are multiple separate issues that contribute the problems with long paths on Windows and addressing all of them doesn't seem likely in the near future. |
baa9e1b to
daf2ee2
Compare
daf2ee2 to
612cb01
Compare
UebelAndre
left a comment
There was a problem hiding this comment.
I think the change looks fine but am over-all nervous about introducing a transition here. I don't have any concrete issue from this though so fingers crossed, and thanks!
612cb01 to
9ed50de
Compare
f32013c to
3485cf0
Compare
|
Thanks! With the latest update my concern about building some targets 3 instead of 2 times goes away and I think we're ready to land this. |
3485cf0 to
05bf6aa
Compare
Depends on #1424.
We have a peculiar use case related to bootstrapping rustc (https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html).
At
stage0, thebetacompiler is used:stage0-stdlib),stage0-rustc).To build
stage0-rustc, there are two kinds of dependencies of rustc:The bootstrapping wrapper treats these two types of dependencies differently:
betawith thebetasysroot,betawith thestage0-stdlibsysroot.The reason for this is that proc-macros are loaded by the
betarustc while building everything else, and they need to be compiled using a sysroot containing the proc-macro rlib crate ABI compatible with thebetacompiler (which thestage0-stdlibone is not always, e.g., rust-lang/rust#98056; https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/ICE.2Fboot.20invalid.20enum.20variant.20tag.20while.20decoding.20.60MacroKind.60).In a setup like this, we need to be able to distinguish somehow whether the rustc action building a crate is building it as a (transitive) proc-macro dependency or not.
In this PR I propose we mark the
depsattribute of therust_proc_macrorule with a custom transition that sets a newis_proc_macro_depboolean setting. The value of this setting is passed over as a newBAZEL_RULES_RUST_IS_PROC_MACRO_DEPenvironment variable. This allows us to have arustcwrapper that examines this value and adapt accordingly in cases where we care about the distinction.This whole feature is gated by the new
is_proc_macro_dep_enabledboolean setting: whenis_proc_macro_dep_enabledis false (the default), there is no difference between deps of proc-macros and "standard" deps (BAZEL_RULES_RUST_IS_PROC_MACRO_DEPis not set). This is to account for a case like this, where we would otherwise have an additional version of the proc-macro dep built: we have arust_library(d), which is a dep of both aproc_macro(p)and a toolrust_binary(t)inexecconfig. Whenis_proc_macro_dep_enabled = false(the default) and we build everything, we will have 2 versions ofd: one top-level non-exec mode, and one in exec mode used both as a dependency to the proc-macro and the tool. Whenis_proc_macro_dep_enabled = trueand we build everything, we will have 3 versions ofd: one top-level in non-exec mode, and two in exec mode: oned1built as a dependency of the proc-macro whereBAZEL_RULES_RUST_IS_PROC_MACRO_DEP=1, and anotherd0, built as a dependency of the tool whereBAZEL_RULES_RUST_IS_PROC_MACRO_DEP=0.A natural way that almost works to distinguish dependencies of proc-macro's from others is to check whether the configuration is
exec:proc_macro_depsare markedexec, andexectrickles down to proc-macro's dependencies as well. This doesn't work however in situations where the top-level target is already in anexecconfiguration -- then all of its dependencies (both proc-macro's and non-proc-macro dependencies) are being compiled inexecconfiguration and we lose the ability to distinguish between those).RESOLVED in the latest version of this PR, but for context on the dependence on #1424: I'm hitting a strange
//crate_universe:rustdoc_testfailure:https://buildkite.com/bazel/rules-rust-rustlang/builds/6631#01819625-365a-42fd-bb11-f3a95db9f999/280-523
It took me a while to figure out exactly what was going on, since the process_wrapper error doesn't mention the path to the missing file nor the context in which the failure had occurred. I added some error logging to process_wrapper so errors like these are more evident:
https://storage.googleapis.com/bazel-untrusted-buildkite-artifacts/0181afb8-96b4-494c-a21c-e4bf120d9698/crate_universe/rustdoc_test/test.log
The root cause of the issue was that link_search_path's for (transitive) dependencies of proc-macro's were being added to the process_wrapper invocation. When I changed the
cfgofrust_proc_macro.deps, these were pointing to a configuration-specific relative path starting with blaze-out/, likebazel-out/k8-opt-exec-2B5CBBC6-ST-fa1bc2ca6f16/bin/external/crate_universe_crate_index__proc-macro2-1.0.39/proc-macro2_build_script.linksearchpaths, which doesn't exist at test time (the "standard" deps link_search_path's are passed relative tobin/, e.g.,external/crate_universe_crate_index__blah-1.0.39/blah_build_script.linksearchpaths.