-
Notifications
You must be signed in to change notification settings - Fork 491
Improve handling of compile_data with mixed sources #3176
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
Improve handling of compile_data with mixed sources #3176
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at generated sources recently, this change makes sense to me.
Needs an owner, @krasimirgg we were talking about this very issue a couple of days ago :-)
|
||
# Optionally join compile data | ||
if crate.compile_data: | ||
compile_data = depset(ctx.files.compile_data, transitive = [crate.compile_data]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to worry about compile_data being None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaict this shouldn't be possible, attr.label_list
defaults to []
, and we set compile_data
explicitly to a depset based on that in all codepaths, but I can add this check back if you think it's better to be defensive. It was a bit confusing to me, which is why I removed it!
03dacc4
to
7c80de4
Compare
Looks good! Please re-format the file that the Buildifier workflow is complaining about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat according to https://buildkite.com/bazel/rules-rust-rustlang/builds/13739#01945f02-1578-4657-8c29-aeaef49853d9/127-128
This fixes issue where generated compile_data didn't work in some cases.
46726d1
to
e6f947e
Compare
Sorry, missed buildifier and one test affected by the last commit, pushed an updated patch now 👍 |
This has lead to a regression for targets which have compile data from completely other packages. See repro at (#3193)
I don't quite know how to solve for this as I'm not sure what the symlink path should be for this foreign path. |
Happy if we rolled this back until we have a full fix for this. |
@krasimirgg The crash should be fixed by #3196 or similar, but it's unclear to me how the repro in #3193 could have worked (as in the Fine with me to roll it back too obviously. |
This PR broke something in my project. I'm using the For a rust library inside a I wanted to report my findings here before having a closer look to the PR and maybe open a more detailed issue, or even a PR with a fix. I have migrations in a diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl
index 74d458ee..0dc8b4e6 100644
--- a/rust/private/rust.bzl
+++ b/rust/private/rust.bzl
@@ -203,7 +203,7 @@ def _rust_library_common(ctx, crate_type):
rustc_env_files = ctx.files.rustc_env_files,
is_test = False,
data = depset(ctx.files.data),
- compile_data = depset(compile_data),
+ compile_data = depset(ctx.files.compile_data),
compile_data_targets = depset(ctx.attr.compile_data),
owner = ctx.label,
),
@@ -419,7 +419,7 @@ def _rust_test_impl(ctx):
rustc_env = rustc_env,
rustc_env_files = ctx.files.rustc_env_files,
is_test = True,
- compile_data = depset(compile_data),
+ compile_data = depset(ctx.files.compile_data),
compile_data_targets = depset(ctx.attr.compile_data),
owner = ctx.label,
) |
Hi @jgsogo, do you have a minimal reproduction of your issue? It's been a while since I've looked at this, but your patch breaks the stuff that this PR was meant to fix, so I hope we can find a different solution! |
Here it is: https://github.com/jgsogo/rules_rust-3176 Reproducing the errorgit clone https://github.com/jgsogo/rules_rust-3176
cd rules_rust-3176
bazel build //libraries/diesel_utils:integration_tests --verbose_failures --sandbox_debug
Error log (uses
indeed, if you check the working directory, the
The issueIn the Using the commits that works, the migrations are available in the working directory:
The issue comes from the target Don't judge the way I'm generating this |
btw, in my project I will decouple the
With this approach, this is no longer an issue for me. However I can imagine other scenarios where several rules contribute files to a rust library. |
I see, the way this library looks for the migrations does mesh well with bazel in general really, as it seems it's hard-coded to search from CARGO_MANIFEST_DIR as the root. You could try a hack by setting |
I'm not very well versed in starlark nor the rules_rust codebase, so feel free to ignore this and address the issue in a more fitting way, but this fixes #3171 and a related issue for me.