Unverified Commit 75862506 authored by Samuel Ainsworth's avatar Samuel Ainsworth Committed by GitHub
Browse files

xla: add aarch64-darwin support (#492814)

parents 5890806f 1de1c2d2
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ index 53e6494656..22261cd268 100644
 import java.util.Map;
 import java.util.Optional;
 import java.util.TreeMap;
@@ -193,16 +194,11 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
@@ -193,16 +194,15 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
       }

       if (shouldUseCachedRepos(env, handler, repoRoot, rule)) {
@@ -20,8 +20,12 @@ index 53e6494656..22261cd268 100644
-          return null;
-        }
-        if (markerHash != null) { // repo exist & up-to-date
+        {
+          // Nix hack: Always consider cached dirs as up-to-date
+        // Nix hack: Skip marker file validation but only for repos that have
+        // been fully initialized. Check for common root files that indicate a
+        // real repo, not an empty dir created by module extensions before the
+        // repository rule has had a chance to run.
+        if (repoRoot.getChild("BUILD").exists() || repoRoot.getChild("BUILD.bazel").exists()
+            || repoRoot.getChild("WORKSPACE").exists() || repoRoot.getChild("WORKSPACE.bazel").exists()) {
           return RepositoryDirectoryValue.builder()
               .setPath(repoRoot)
-              .setDigest(markerHash)
@@ -30,8 +34,6 @@ index 53e6494656..22261cd268 100644
               .build();
         }
       }


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 649647c5f2..64d05b530c 100644
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+22 −14
Original line number Diff line number Diff line
{
  bazel_7,
  buildBazelPackage,
  cctools,
  curl,
  double-conversion,
  fetchFromGitHub,
@@ -18,6 +19,7 @@
  python3,
  snappy,
  sqlite,
  stdenv,
  which,
  zlib,
}:
@@ -71,7 +73,8 @@ in
    gitMinimal
    pythonEnv # necessary for some patchShebang'ing
    which
  ];
  ]
  ++ lib.optional stdenv.hostPlatform.isDarwin cctools.libtool;

  buildInputs = [
    curl
@@ -136,6 +139,14 @@ in
    "--host_cxxopt=cstdint"
    # Exclude mobile/iOS targets that have Bazel incompatibilities
    "--build_tag_filters=-mobile,-ios"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # Set macOS deployment target to suppress availability errors (e.g.
    # futimens requires 10.13+) in both target and host-tool builds.
    "--copt=-mmacosx-version-min=11.0"
    "--host_copt=-mmacosx-version-min=11.0"
    "--linkopt=-mmacosx-version-min=11.0"
    "--host_linkopt=-mmacosx-version-min=11.0"
  ];

  removeRulesCC = false;
@@ -146,10 +157,16 @@ in
  removeLocal = false;

  fetchAttrs = {
    sha256 = "sha256-OJfSqDlEC+yhWwwMwaD5HGvuHm8OWk+yQxmbH0/gZ88=";
    sha256 =
      {
        x86_64-linux = "sha256-OJfSqDlEC+yhWwwMwaD5HGvuHm8OWk+yQxmbH0/gZ88=";
        aarch64-darwin = "sha256-sKxtdgozCV1on1gd+bm8FKyFxP0u70Hs24OdLNA3jh0=";
      }
      .${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}");
    preInstall = ''
      rm -rf $bazelOut/external/{local_config_python,\@local_config_python.marker}
      rm -rf $bazelOut/external/{local_config_sh,\@local_config_sh.marker}
      rm -rf $bazelOut/external/{local_config_xcode,\@local_config_xcode.marker}
      rm -rf $bazelOut/external/{local_execution_config_python,\@local_execution_config_python.marker}
      rm -rf $bazelOut/external/{local_jdk,\@local_jdk.marker}
    '';
@@ -187,18 +204,9 @@ in
    homepage = "https://github.com/openxla/xla";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ samuela ];
    platforms = lib.platforms.unix;
    badPlatforms = [
      # ERROR: /build/output/external/local_config_cc/BUILD: no such target
      # '@@local_config_cc//:cc-compiler-k8': target 'cc-compiler-k8' not declared in package ''
      # defined by /build/output/external/local_config_cc/BUILD
      "aarch64-linux"

      # Bazel fails to build on darwin:
      # ERROR: no such package '@@bazel_tools~xcode_configure_extension~local_config_xcode//':
      # BUILD file not found in directory '' of external repository @@bazel_tools~xcode_configure_extension~local_config_xcode.
      # Add a BUILD file to a directory to mark it as a package.
      lib.systems.inspect.patterns.isDarwin
    platforms = [
      "x86_64-linux"
      "aarch64-darwin"
    ];
  };
}