Skip to content

Do not add proc-macro deps to transitive_link_search_paths - #1424

Merged
krasimirgg merged 1 commit into
bazelbuild:mainfrom
krasimirgg:transitive_link_search_paths
Jul 13, 2022
Merged

krasimirgg merged 1 commit into
bazelbuild:mainfrom
krasimirgg:transitive_link_search_paths

Conversation

@krasimirgg

@krasimirgg krasimirgg commented Jun 28, 2022 •

Copy link
Copy Markdown
Collaborator

While working on #1420, which added a user-defined transition on the deps attribute of rust_proc_macro, I was hitting a strange //crate_universe:rustdoc_test failure:
https://buildkite.com/bazel/rules-rust-rustlang/builds/6631#01819625-365a-42fd-bb11-f3a95db9f999/280-523

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //crate_universe:rustdoc_test
-----------------------------------------------------------------------------
thread 'main' panicked at 'process wrapper error: No such file or directory (os error 2)', util/process_wrapper/main.rs:54:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.

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 cfg of rust_proc_macro.deps, these were pointing to a configuration-specific relative path starting with blaze-out/, like
bazel-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 to bin/, e.g., external/crate_universe_crate_index__blah-1.0.39/blah_build_script.linksearchpaths.

I updated rules_rust to not add the link_search_paths for transitive deps of proc_macros and added some error logging to process_wrapper so errors like these are more evident. I believe this is reasonable since proc_macro's and their deps are not attempted to be linked into their clients, instead rustc dynamically loads them while compiling clients.

Required by #1420. Without this change, that PR fails tests, so that will act as a test for this in practice.

@krasimirgg
krasimirgg force-pushed the transitive_link_search_paths branch from 0ea6a6c to dec399c Compare June 28, 2022 09:17
@krasimirgg krasimirgg changed the title do not add proc-macro deps to transitive_link_search_paths Do not add proc-macro deps to transitive_link_search_paths Jun 28, 2022
@krasimirgg krasimirgg changed the title Do not add proc-macro deps to transitive_link_search_paths [WIP] Do not add proc-macro deps to transitive_link_search_paths Jun 29, 2022
@krasimirgg
krasimirgg force-pushed the transitive_link_search_paths branch 2 times, most recently from 9c6d5d2 to 05cc179 Compare July 7, 2022 13:01
@krasimirgg krasimirgg changed the title [WIP] Do not add proc-macro deps to transitive_link_search_paths Do not add proc-macro deps to transitive_link_search_paths Jul 7, 2022
@krasimirgg
krasimirgg force-pushed the transitive_link_search_paths branch 3 times, most recently from 6d4286b to 4a2f4c7 Compare July 12, 2022 14:08
@krasimirgg
krasimirgg requested a review from scentini July 12, 2022 14:09
@krasimirgg
krasimirgg marked this pull request as ready for review July 12, 2022 14:09
@krasimirgg
krasimirgg force-pushed the transitive_link_search_paths branch 2 times, most recently from 61706a1 to a99f261 Compare July 12, 2022 14:22
@krasimirgg
krasimirgg enabled auto-merge (squash) July 12, 2022 14:22

@scentini scentini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding some tests around link_search_path_files !!

@krasimirgg
krasimirgg force-pushed the transitive_link_search_paths branch from a99f261 to 4b9e150 Compare July 13, 2022 09:55
@krasimirgg
krasimirgg merged commit 1e83e74 into bazelbuild:main Jul 13, 2022
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.

2 participants