Skip to content
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

bazel: fix java toolchain regression #54780

Merged

Conversation

Projects
None yet
3 participants
@Profpatsch
Copy link
Member

commented Jan 28, 2019

By changing the default toolchain to JDK8, we broke the default Java
toolchain, which assumes JDK9.

Instead, set host_java_toolchain manually for our build of bazel,
and set java_toolchain to run the java tests with the build JDK as
well.

Fixes #54289

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@Profpatsch

This comment has been minimized.

Copy link
Member Author

commented Jan 28, 2019

@GrahamcOfBorg build bazel.tests

$out/bin/bazel test --test_output=errors \
$out/bin/bazel test \
--test_output=errors \
--java_toolchain='${javaToolchain}' \

This comment has been minimized.

Copy link
@robinp

robinp Jan 28, 2019

Contributor

Somewhat orthogonal question: should this nix derivation provide among its outputs a .bazelrc file ready to import into the user's own .bazelrc, setting up all these flags? They are needed anyway for compilations to succeed in a nix env.

This comment has been minimized.

Copy link
@Profpatsch

Profpatsch Jan 29, 2019

Author Member

Hm, which flags would be interesting except for --java_toolchain?
The user codebases I know of are mostly rather large company repositories, with custom toolchains and everything.

This comment has been minimized.

Copy link
@robinp

robinp Jan 29, 2019

Contributor

Sorry, I had in my mind all the other non-Java flags as well, like gcc and linker flags. But that's a separate issue.

@@ -8279,6 +8279,8 @@ in
bazel = callPackage ../development/tools/build-managers/bazel {
inherit (darwin) cctools;
inherit (darwin.apple_sdk.frameworks) CoreFoundation CoreServices Foundation;
buildJdk = jdk8;
buildJdkName = "jdk8";

This comment has been minimized.

Copy link
@robinp

robinp Jan 28, 2019

Contributor

Seems a bit out of context here - it is not guaranteed that concating jdkX with this will result in a valid toolchain name. Could either pass in the full bazel target name for the toolchain, not expose it at all and derive from some version attribute of buildJdk, if that's possible?

That said, I don't see how different users of bazel-nix would want to configure their various toolchains, so it is hard to come up with any sensible parameter api.

This comment has been minimized.

Copy link
@Profpatsch

Profpatsch Jan 28, 2019

Author Member

There’s nothing to configure. This is just a codified reminder to change both the jdk and the toolchain when updating bazel.

bazel: fix java toolchain regression
By changing the default toolchain to JDK8, we broke the default Java
toolchain, which assumes JDK9.

Instead, set `host_java_toolchain` manually for our build of bazel,
and set `java_toolchain` to run the java tests with the build JDK as
well.

Fixes #54289

@Profpatsch Profpatsch force-pushed the Profpatsch:bazel-0.21-fix-java_toolchain-regression branch from 55ac070 to 214e08b Jan 29, 2019

@Profpatsch Profpatsch merged commit 5c6892e into NixOS:master Jan 29, 2019

12 of 13 checks passed

bazel on aarch64-linux No attempt
Details
bazel on x86_64-darwin Success
Details
bazel on x86_64-linux Success
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.