-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add --trust_install_base option #11905
Add --trust_install_base option #11905
Conversation
a449315
to
5685c4c
Compare
I can confirm that this PR allows the Bazel binary to be safely stripped and will resolve #11842. I tested with a build and install in the current Debian unstable. |
5685c4c
to
18c42b1
Compare
This will allow Bazel client to run individually without the appended zip archive, which is a requirement for Debian installation. The following changes are made: - Add --trust_install_base option. When this is enabled. Bazel client trusts the install base provided by --install_base option and skip the step of verifying the install directory. We need it because the Bazel client alone doesn't contain information to verify the install directory. - Reimplement --version as a actual Bazel startup flag. The version info is read from the zip archive, but when --trust_install_base is enabled it should be read from the given install base. Related: bazelbuild#9408 Fixes: bazelbuild#11842
18c42b1
to
de33eb4
Compare
Folding Also, documentation will need to be updated to reflect that |
So with the implementation in this PR. If the option parsing succeeded and
Adding documentation and test sounds a good idea. Is there any original doc or test for |
Test and documentation added, please take another look ;) |
LGTM except for the build failures ;) |
Oops, forgot to run Thanks for the fast review! |
src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
Outdated
Show resolved
Hide resolved
@michajlo Thanks for the review, please take another look ;) |
<code>bazel version --gnu_format</code>, except without the side-effect of potentially starting | ||
a Bazel server or unpacking the server archive. <code>bazel --version</code> can be run from | ||
anywhere - it does not require a workspace directory. | ||
anywhere - it does not require a workspace directory. When <code>--version</code> is passed, all | ||
other flags and Bazel command will be ignored. |
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 wonder if people will nitpick on this... but all other flags aren't completely ignored... they're parsed (i believe including rc files) then dropped.
actually, this makes me think, should we skip rc parsing if --version is specified, so that a bad rc file doesn't mess things up? i also wonder if we can disallow --version from rc files, but that's probably not worth it...
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.
actually, this makes me think, should we skip rc parsing if --version is specified
Sounds like a good idea, but would implement in a different PR.
@@ -20,6 +20,11 @@ | |||
|
|||
namespace blaze { | |||
|
|||
void DetermineArchiveContentsFromInstallBase( |
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.
document the intended use? (when install base is considered trusted, right?)
@@ -1617,11 +1631,21 @@ int Main(int argc, const char *const *argv, WorkspaceLayout *workspace_layout, | |||
StartupOptions *startup_options = option_processor->GetParsedStartupOptions(); | |||
startup_options->MaybeLogStartupOptionWarnings(); | |||
|
|||
if (startup_options->trust_install_base && startup_options->install_base.empty()) { |
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.
This is making me realize, the semantics of --version
differ now based on if --trust_install_base
is specified. With --trust_install_base
we print the version of the server, without --trust_install_base
we print the version of the client. These could differ. This should definitely be documented, or (probably overkill) we could have separate flags...
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.
These could differ.
How?
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.
Client and server versions fall out of sync. Could be user points client at diff install base, or that some update doesn't go as expected.
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.
Client and server versions fall out of sync. Could be user points client at diff install base, or that some update doesn't go as expected.
FWIW, this would be a highly improbable situation in the Debian package. Certainly possible, but someone would have to purposely hack some things that they shouldn't be touching unless they're a Bazel developer or Debian package manager. ;)
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.
This would be for uses outside of debian as well.
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.
Well of course! I'm just commenting within the scope of my expertise. 🙂 Additional uses are likely in the future but the official Debian package is presently the only user of the trust-install-base option.
<code>bazel version --gnu_format</code>, except without the side-effect of potentially starting | ||
a Bazel server or unpacking the server archive. <code>bazel --version</code> can be run from | ||
anywhere - it does not require a workspace directory. | ||
anywhere - it does not require a workspace directory. When <code>--version</code> is passed, all | ||
other flags and Bazel command will be ignored. |
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.
actually, this makes me think, should we skip rc parsing if --version is specified
Sounds like a good idea, but would implement in a different PR.
@@ -1007,6 +1007,11 @@ static DurationMillis ExtractData(const string &self_path, | |||
<< "install base directory '" << install_base | |||
<< "' could not be created. It exists but is not a directory."; | |||
} | |||
|
|||
if (startup_options.trust_install_base) { |
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 am a little surprised to see this down here.
What's the expected behavior of this option when no install base exists? I would not assume that it should create one (but it does above).
Meanwhile... workaround for debian/ubuntu users whose bazel gets zapped by the prelinker:
( |
Yun, what's the state of this PR? |
Sorry, I haven't found time for this recently. But it's on my to-do list. Will take on this ASAP! |
Friendly ping. If this will never merge, can you close it. That way we will stop seeing it in bug triage. |
Sorry, about that. I'll close this for now until I have time to work on it again. |
This will allow Bazel client to run individually without the appended
zip archive, which is a requirement for Debian installation.
The following changes are made:
trusts the install base provided by --install_base option and skip
the step of verifying the install directory. We need it because the
Bazel client alone doesn't contain information to verify the install
directory.
info is read from the zip archive, but when --trust_install_base is
enabled it should be read from the given install base.
Related: #9408
Fixes: #11842