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: 0.4.5 -> 0.5.3 #27861

Closed
wants to merge 2 commits into from
Closed

bazel: 0.4.5 -> 0.5.3 #27861

wants to merge 2 commits into from

Conversation

sigma
Copy link
Contributor

@sigma sigma commented Aug 2, 2017

Motivation for this change
Things done

Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers.

  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@sigma, thanks for your PR! By analyzing the history of the files in this pull request, we identified @izuk, @IreneKnapp and @benley to be potential reviewers.

postPatch = ''
makeWrapper "${bash}/bin/bash" "$out/bin/bash" --argv0 '$0' --prefix PATH : ${coreutils}/bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to hide this $out/bin/bash somewhere other than $out, which might otherwise cause confusion when using buildEnv and friends (since a certain other package also contains a bin/bash 😄)

@cstrahan
Copy link
Contributor

cstrahan commented Aug 3, 2017

I think we should also keep the old version, for the time being; I tried applying this to my branch where I'm building Envoy (#27629), but I get this failure with 0.5.3:

ERROR: java.io.IOException: Could not read the crosstool configuration file 'CROSSTOOL file /tmp/nix-build-envoy-1.3.0.drv-0/envoy-v1.3.0-src/.home/.cache/bazel/_bazel_nixbld/cbe181aaebf3d7253cbcf6057028e514/external/local_config_cc/CROSSTOOL', because of a parser error (924:1: Expected identifier. Found '%')

@cstrahan
Copy link
Contributor

cstrahan commented Aug 3, 2017

To address @copumpkin's point, I'd suggest doing something like this:

diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix
index dcdc55f0ae..84ca80f5f4 100644
--- a/pkgs/development/tools/build-managers/bazel/default.nix
+++ b/pkgs/development/tools/build-managers/bazel/default.nix
@@ -1,8 +1,23 @@
-{ stdenv, fetchurl, jdk, zip, unzip, bash, makeWrapper, which }:
+{ stdenv, fetchurl, jdk, zip, unzip, bash, makeWrapper, which, coreutils, symlinkJoin }:
+
+let
+  bashEnv =
+    symlinkJoin {
+      name = "bazel-bash-env";
+      paths = [ coreutils ];
+      buildInputs = [ makeWrapper ];
+      postBuild = ''
+        makeWrapper "${bash}/bin/bash" "$out/bin/bash" \
+          --argv0 '$0' \
+          --prefix PATH : "$out/bin"
+      '';
+    };
+
+in
 
 stdenv.mkDerivation rec {
 
-  version = "0.4.5";
+  version = "0.5.3";
 
   meta = with stdenv.lib; {
     homepage = http://github.com/bazelbuild/bazel/;
@@ -16,14 +31,15 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
-    sha256 = "0asmq3kxnl4326zhgh13mvcrc8jvmiswjj4ymrq0943q4vj7nwrb";
+    sha256 = "0csk3jzi3dvs24y9cmhlsbjyfv5pqddnqqkx3ywza58b1a4cbdbn";
   };
 
   sourceRoot = ".";
 
+  # bazel expects bash to find coreutils when starting from an empty environment
   postPatch = ''
     for f in $(grep -l -r '#!/bin/bash'); do
-      substituteInPlace "$f" --replace '#!/bin/bash' '#!${bash}/bin/bash'
+      substituteInPlace "$f" --replace '#!/bin/bash' '#!'${bashEnv}/bin/bash
     done
     for f in \
       src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java \
@@ -31,7 +47,7 @@ stdenv.mkDerivation rec {
       src/main/java/com/google/devtools/build/lib/bazel/rules/sh/BazelShRuleClasses.java \
       src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java \
       ; do
-      substituteInPlace "$f" --replace /bin/bash ${bash}/bin/bash
+      substituteInPlace "$f" --replace /bin/bash ${bashEnv}/bin/bash
     done
   '';
 

@benley
Copy link
Member

benley commented Aug 3, 2017

FYI I think bazel 0.5.3 has some known issues; 0.5.4 should be out pretty soon to fix things

@sigma sigma closed this Oct 1, 2017
@sigma sigma deleted the pr/bazel-0.5.3 branch October 1, 2017 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants