Commit 69c21d5b authored by Uri Baghin's avatar Uri Baghin
Browse files

bazel_6: fix darwin build

parent 095a37e1
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -185,6 +185,10 @@ stdenv.mkDerivation rec {
    # argument if it's found to be an empty string.
    ../trim-last-argument-to-gcc-if-empty.patch

    # `java_proto_library` ignores `strict_proto_deps`
    # https://github.com/bazelbuild/bazel/pull/16146
    ./strict_proto_deps.patch

    # On Darwin, using clang 6 to build fails because of a linker error (see #105573),
    # but using clang 7 fails because libarclite_macosx.a cannot be found when linking
    # the xcode_locator tool.
@@ -218,7 +222,7 @@ stdenv.mkDerivation rec {
      src = ../bazel_rc.patch;
      bazelSystemBazelRCPath = bazelRC;
    })
  ] ++ lib.optional enableNixHacks ../nix-hacks.patch;
  ] ++ lib.optional enableNixHacks ./nix-hacks.patch;


  # Additional tests that check bazel’s functionality. Execute
@@ -472,6 +476,8 @@ stdenv.mkDerivation rec {
      build --verbose_failures
      build --curses=no
      build --features=-layering_check
      build --experimental_strict_java_deps=off
      build --strict_proto_deps=off
      EOF

      cat >> third_party/grpc/bazel_1.41.0.patch <<EOF
@@ -501,6 +507,8 @@ stdenv.mkDerivation rec {
          -e "/\$command \\\\$/a --verbose_failures \\\\" \
          -e "/\$command \\\\$/a --curses=no \\\\" \
          -e "/\$command \\\\$/a --features=-layering_check \\\\" \
          -e "/\$command \\\\$/a --experimental_strict_java_deps=off \\\\" \
          -e "/\$command \\\\$/a --strict_proto_deps=off \\\\" \
          -i scripts/bootstrap/compile.sh

      # This is necessary to avoid:
+40 −0
Original line number Diff line number Diff line
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
index 25fbdcac9d..49616d37df 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
@@ -568,22 +568,7 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
       String content;
       try {
         content = FileSystemUtils.readContent(markerPath, StandardCharsets.UTF_8);
-        String markerRuleKey = readMarkerFile(content, markerData);
-        boolean verified = false;
-        if (Preconditions.checkNotNull(ruleKey).equals(markerRuleKey)) {
-          verified = handler.verifyMarkerData(rule, markerData, env);
-          if (env.valuesMissing()) {
-            return null;
-          }
-        }
-
-        if (verified) {
-          return new Fingerprint().addString(content).digestAndReset();
-        } else {
-          // So that we are in a consistent state if something happens while fetching the repository
-          markerPath.delete();
-          return null;
-        }
+        return new Fingerprint().addString(content).digestAndReset();
       } catch (IOException e) {
         throw new RepositoryFunctionException(e, Transience.TRANSIENT);
       }
diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
index 1a45b8a3a2..a6b73213f6 100644
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
@@ -152,7 +152,6 @@ public class JavaSubprocessFactory implements SubprocessFactory {
     ProcessBuilder builder = new ProcessBuilder();
     builder.command(params.getArgv());
     if (params.getEnv() != null) {
-      builder.environment().clear();
       builder.environment().putAll(params.getEnv());
     }
 
+21 −0
Original line number Diff line number Diff line
diff --git a/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl b/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl
index 63f68167e4..f106e64c9b 100644
--- a/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl
+++ b/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl
@@ -114,6 +114,7 @@ def java_compile_for_protos(ctx, output_jar_suffix, source_jar = None, deps = []
             exports = exports,
             output = output_jar,
             output_source_jar = source_jar,
+            strict_deps = ctx.fragments.proto.strict_proto_deps(),
             injecting_rule_kind = injecting_rule_kind,
             javac_opts = java_toolchain.compatible_javacopts("proto"),
             enable_jspecify = False,
@@ -140,7 +141,7 @@ bazel_java_proto_aspect = aspect(
     attr_aspects = ["deps", "exports"],
     required_providers = [ProtoInfo],
     provides = [JavaInfo, JavaProtoAspectInfo],
-    fragments = ["java"],
+    fragments = ["java", "proto"],
 )
 
 def bazel_java_proto_library_rule(ctx):
+11 −6
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
  bazel
, bazelTest
, bazel-examples
, gccStdenv
, stdenv
, darwin
, lib
, runLocal
, runtimeShell
@@ -16,9 +17,10 @@ let
  toolsBazel = writeScript "bazel" ''
    #! ${runtimeShell}

    export CXX='${gccStdenv.cc}/bin/g++'
    export LD='${gccStdenv.cc}/bin/ld'
    export CC='${gccStdenv.cc}/bin/gcc'
    export CXX='${stdenv.cc}/bin/clang++'
    export LD='${darwin.cctools}/bin/ld'
    export LIBTOOL='${darwin.cctools}/bin/libtool'
    export CC='${stdenv.cc}/bin/clang'

    # XXX: hack for macosX, this flags disable bazel usage of xcode
    # See: https://github.com/bazelbuild/bazel/issues/4231
@@ -31,7 +33,7 @@ let
    cp -r ${bazel-examples}/cpp-tutorial/stage3 $out
    find $out -type d -exec chmod 755 {} \;
  ''
  + (lib.optionalString gccStdenv.isDarwin ''
  + (lib.optionalString stdenv.isDarwin ''
    mkdir $out/tools
    cp ${toolsBazel} $out/tools/bazel
  ''));
@@ -46,7 +48,10 @@ let
        --distdir=${distDir} \
        --curses=no \
        --sandbox_debug \
          //...
        //... \
    '' + lib.optionalString (stdenv.isDarwin) ''
        --cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
        --linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
    '';
  };

+15 −12
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
  bazel
, bazelTest
, bazel-examples
, gccStdenv
, stdenv
, darwin
, lib
, openjdk8
, jdk11_headless
@@ -18,9 +19,10 @@ let
  toolsBazel = writeScript "bazel" ''
    #! ${runtimeShell}

    export CXX='${gccStdenv.cc}/bin/g++'
    export LD='${gccStdenv.cc}/bin/ld'
    export CC='${gccStdenv.cc}/bin/gcc'
    export CXX='${stdenv.cc}/bin/clang++'
    export LD='${darwin.cctools}/bin/ld'
    export LIBTOOL='${darwin.cctools}/bin/libtool'
    export CC='${stdenv.cc}/bin/clang'

    # XXX: hack for macosX, this flags disable bazel usage of xcode
    # See: https://github.com/bazelbuild/bazel/issues/4231
@@ -33,7 +35,7 @@ let
    cp -r ${bazel-examples}/java-tutorial $out
    find $out -type d -exec chmod 755 {} \;
  ''
  + (lib.optionalString gccStdenv.isDarwin ''
  + (lib.optionalString stdenv.isDarwin ''
    mkdir $out/tools
    cp ${toolsBazel} $out/tools/bazel
  ''));
@@ -50,6 +52,7 @@ let
        --verbose_failures \
        --curses=no \
        --sandbox_debug \
        --strict_java_deps=off \
        //:ProjectRunner \
    '' + lib.optionalString (lib.strings.versionOlder bazel.version "5.0.0") ''
        --host_javabase='@local_jdk//:jdk' \
Loading