-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix issue where libtool_check_unique isn't found for sandbox builds #12046
Fix issue where libtool_check_unique isn't found for sandbox builds #12046
Conversation
I'm also not sure if there are other places this is needed. Probably worth grepping or doing a rdeps query on libtool itself, but this seems like a solid fix and likely the only other place |
Maybe worth editing the script to error if this is missing vs treating that as the same type of failure? |
in a way, i'm glad the script kept working without it. but if we feel confident enough in this change, or at least that doing a simple build with + without the sandbox is enough to test it properly, i can have it fail early |
There's also https://github.com/bazelbuild/bazel/blob/master/tools/objc/BUILD#L14 ? (That is referenced in java code here: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java#L531) Alternatively, unless we're certain that we have all the uses necessary, we could also make the script warn and continue gracefully if it is not present--considering it is just an optimization. |
f2ac19c
to
b9261d2
Compare
to be clear, i don't know when that missing rule in tools/objc/BUILD would cause a problem anyways |
@@ -50,6 +50,7 @@ cc_toolchain_suite( | |||
":builtin_include_directory_paths", | |||
":cc_wrapper", | |||
":libtool", | |||
":libtool_check_unique", |
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.
+1 on this one, seems like this label references the binary in the toolchain setup
tools/objc/BUILD
Outdated
], | ||
) | ||
|
||
cc_binary( | ||
name = "libtool_check_unique", | ||
srcs = ["libtool_check_unique.cc"], |
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 can't figure out how this stuff is actually used, so I can't tell if it works or not.
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.
Doing some archaeology, I think this was a remnant of the pre-crosstool ObjcCompilation rule implementations. Which is presumably why you can't find it.
I bet this can actually be removed, but I am not knowledgeable enough about the Bazel CI to know if we'd catch any issues.
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.
related #12073
I do think some of it looks more used in j2objc stuff tho
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.
It looks like they pass it along in the J2ObjcAspect, but I can't find any references to it being used after that. Did you catch something else? (We can also take this to your other PR)
EDIT: link
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.
sounds like we can pretty safely ignore this piece for this use case and fix it if anything comes up, so I think this PR should be good to go!
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.
so then i can leave it as-is and we can merge? or does it need to be deleted?
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 would delete it for now unless we can prove it is needed otherwise.
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.
Up to whoever can merge, but unless mine merges first I do think this should work, so we could leave it to try and get this in 3.6, and I can remove it if it's really unused.
@@ -37,7 +37,9 @@ WRAPPER="${MY_LOCATION}/xcrunwrapper.sh" | |||
# Ensure 0 timestamping for hermetic results. | |||
export ZERO_AR_DATE=1 | |||
|
|||
if "${MY_LOCATION}"/libtool_check_unique "$@"; then | |||
if [ ! -f "${MY_LOCATION}"/libtool_check_unique ] ; then |
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.
my bash is not fantastic, but this at least works for me
@michaeleisel, thanks for the PR. We'd really like to have a test for what exactly this PR fixes to make sure that it stays fixed. Would you mind either writing a test or providing a small case to reproduce the problem so that we can add a test based on that? |
@tetromino sure, here's a test case. if we have a folder with the following three files:
a.c
WORKSPACE (empty)
if we run
e.g., a test could check for |
@keith to resolve the merge conflict i just undid any changes for that file |
a problem with a test case is it doesn't fail, it just follows the slow path |
@tetromino curious what your thoughts are |
@michaeleisel, I'm really sorry for the delayed response. Unfortunately, I cannot reproduce the problem (the error message you are seeing) using bazel-3.5.0 on my Mac (macOS 10.15.6, Xcode 11.6) and the example you gave. I see the following:
What version of Bazel are you seeing this in? What build flags are you using (if not |
I see - the problem only occurs in Bazel built after d8723b4. I should have read more carefully... |
I wrote a small test for this which I'm not entirely happy with (would like to get it reviewed). But for this sort of highly user visible error message, I'm ok with accepting the PR without a test. Thank you for the test case! |
This is a regression test for the issue in #12046 - ensure that in sandboxed mode, we don't get error messages about missing tools from our toolchain.
This is a regression test for the issue in bazelbuild#12046 - ensure that in sandboxed mode, we don't get error messages about missing tools from our toolchain.
This is a regression test for the issue in bazelbuild#12046 - ensure that in sandboxed mode, we don't get error messages about missing tools from our toolchain.
This is a regression test for the issue in bazelbuild#12046 - ensure that in sandboxed mode, we don't get error messages about missing tools from our toolchain.
Looks like this CL is breaking rules_cc in downstream: Culprit Finder: https://buildkite.com/bazel/culprit-finder/builds/556 Please take a look |
@meteorcloudy discussion is at bazelbuild/rules_cc#80 |
based on that discussion, there will be some syncing of rules_cc with this, but no changes are needed in bazel. rules_cc just has to catch up (which will be worked on shortly) |
Can you explain more why this should be cherrypicked in Bazel 3.6? |
The rules_cc fix is here bazelbuild/rules_cc#80 The tl;dr of this change is that the introduction of this optimization here: #11958 didn't work for sandboxed builds, that wasn't noticed because builds still pass, they just take the non-optimized path (test for that here #12136) and without this change it leads to significant log spam for every static archive action:
The reason rules_cc broke is because there's no automated path (or even process AFAICT) for updating when there are breaking changes with bazel's crosstool, which seems like something that should also be fixed. IMO this is worth the cherry pick since it's a very localized change that without will discourage people from using sandboxing even more than they already are because of the performance implications |
@oquenchil What's the status of this? |
@laurentlb note that rules_cc is broken regardless of whether or not this cherry pick is added to 3.6 since that was broken by the first PR, not this one |
Thanks for the precision! |
I don't see this cherry pick in the list of commits here: #12040 (comment) |
It seems that for sandbox builds, the executable isn't copied over. libtool still succeeds, but it prints out an error message about the missing executable. This change, which I just made to mimic wrapped_clang, appears to fix it. I have no idea if there are other changes that should also be made for this, e.g. in tools/osx/crosstool/cc_toolchain_config.bzl wrapped_clang is referenced a lot but libtool_check_unique is not. Closes #12046. PiperOrigin-RevId: 332511362
Oops, thanks for noticing (I copied the previous list). I've created a new rc. |
It seems that for sandbox builds, the executable isn't copied over. libtool still succeeds, but it prints out an error message about the missing executable. This change, which I just made to mimic wrapped_clang, appears to fix it. I have no idea if there are other changes that should also be made for this, e.g. in tools/osx/crosstool/cc_toolchain_config.bzl wrapped_clang is referenced a lot but libtool_check_unique is not. Closes bazelbuild#12046. PiperOrigin-RevId: 332511362
This is a regression test for the issue in bazelbuild#12046 - ensure that in sandboxed mode, we don't get error messages about missing tools from our toolchain.
This is a regression test for the issue in bazelbuild#12046 - ensure that in sandboxed mode, we don't get error messages about missing tools from our toolchain.
It seems that for sandbox builds, the executable isn't copied over. libtool still succeeds, but it prints out an error message about the missing executable. This change, which I just made to mimic wrapped_clang, appears to fix it. I have no idea if there are other changes that should also be made for this, e.g. in tools/osx/crosstool/cc_toolchain_config.bzl wrapped_clang is referenced a lot but libtool_check_unique is not.