-
Notifications
You must be signed in to change notification settings - Fork 440
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
Replace symlinks in the output of cargo build scripts #3067
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
502fa0b
to
1d10ca0
Compare
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.
Hmm... Do you know what the symlink is pointing at which is missing? In generally we want to preserve symlinks if possible - is it a symlink to an absolute path? Or a relative path inside in the outdir? Or a relative path inside the sandbox?
It was an absolute path symlink. Essentially when cmake installs the header files as is. So if they were symlinks it will keep them symlinks. It means that due to the linked change now we symlink the runfiles instead of copying therefore nearly all of the native code dependencies will have absolute path symlinks to the sandbox. I can try to make some change so that relative symlinks in the outdir is preserved. |
1d10ca0
to
5b3d833
Compare
Yeah, I think inlining absolute symlinks feels a lot more reasonable - it's still not obviously the correct semantics, but it's probably reasonable to do. Thanks! |
5b3d833
to
ba87b4a
Compare
I have changed it to skip resolving relative symlinks. Could you please clarify what would be the correct semantics? It feels to me that when the entire source tree of a dependency which needs to be built is symlinked into the sandbox we must resolve them. Otherwise the symlinks will point to the sandbox |
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.
Looks good, thanks! One last piece - can you add a couple of tests to https://github.com/bazelbuild/rules_rust/tree/0.55.6/test/cargo_build_script? I'm imagining:
- A cargo_build_script which writes a tempfile to
/tmp/
with some contents, symlinks to it in $OUT_DIR, then a rust_test whichinclude!
s the $OUT_DIR path and sees the contents is correct, and whichlstat
s with$OUT_DIR
path and checks it's a file not a symlink - The same test, but which writes another file into $OUT_DIR with some contents, creates a relative symlink pointing at the other file in $OUT_DIR, and which does the same checks but checks it's a symlink not a file
ba87b4a
to
7400ddf
Compare
I have added tests EDIT: I tried to make testing the symlink existence work but it doesn't seem to me that we could properly validate from Therefore, I had to skip testing the symlink existence |
10df54a
to
0b18c0d
Compare
c3f6b84
to
8f39cc1
Compare
This comment was marked as outdated.
This comment was marked as outdated.
5ef45f0
to
1263d13
Compare
@UebelAndre You have a lot more context than I do here - can you weigh in on this vs #3111 vs something else? |
1263d13
to
b14a4c9
Compare
a978e00
to
653841d
Compare
@UebelAndre if you have some time could you please review this PR? |
I can take a look this week! |
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.
Just a few nits but this otherwise seems good to me! Thank you for your patience with me!
0b14ad8
to
4159baa
Compare
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.
CI seems to have flaked so this will need one more push. But if you also have time to look into https://github.com/bazelbuild/rules_rust/pull/3067/files#r1902089155 that'd be sweet!
44f4bc5
to
c3ccf85
Compare
After bazelbuild#2948 we symlink the source files in sandbox for most external repositories. When a native build system is involved (e.x.: cmake) it is possible that the installed files will be symlinks especially when header files are installed. This will be placed in the output dir of cargo build scripts and when copied back to the repository cache they become dangling symlinks with references to the sandbox. As a fix we replace symlinks with a copy of them in the output directory.
c3ccf85
to
53a8311
Compare
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.
Awesome! Thank you so much!
Thanks for fixing this. Do you know when you will do include this in a new version of rules_rust? |
#2948 breaks building of rdkafka with
cmake
because of dangling symlinks.When building with latest version we get the following error:
Fixes #3099