Skip to content

Commit

Permalink
[LLVM] Restore LLVM toolchains patch removed by openxla/xla#2013
Browse files Browse the repository at this point in the history
This patch turns out to be essential for Mac x86->Mac ARM cross compilation to work (jax-ml/jax#15951).

Unfortunately there's no way to test this except manually, because we have no Mac ARM machines in CI at the moment.

PiperOrigin-RevId: 531065713
  • Loading branch information
hawkinsp authored and copybara-github committed May 11, 2023
1 parent 1e13f13 commit 391748a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions third_party/llvm/toolchains.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index d53167dc618d..de20ef527d05 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -19,6 +19,14 @@ licenses(["notice"])

exports_files(["LICENSE.TXT"])

+config_setting(
+ name = "macos_arm64",
+ values = {
+ "apple_platform_type": "macos",
+ "cpu": "darwin_arm64",
+ },
+)
+
# It may be tempting to add compiler flags here, but that should be avoided.
# The necessary warnings and other compile flags should be provided by the
# toolchain or the `.bazelrc` file. This is just a workaround until we have a
diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl
index b15ec9e1bb39..0d95a1e4d5c1 100644
--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -89,7 +89,7 @@ os_defines = select({
# TODO: We should split out host vs. target here.
llvm_config_defines = os_defines + select({
"@bazel_tools//src/conditions:windows": native_arch_defines("X86", "x86_64-pc-win32"),
- "@bazel_tools//src/conditions:darwin_arm64": native_arch_defines("AArch64", "arm64-apple-darwin"),
+ "//llvm:macos_arm64": native_arch_defines("AArch64", "arm64-apple-darwin"),
"@bazel_tools//src/conditions:darwin_x86_64": native_arch_defines("X86", "x86_64-unknown-darwin"),
"@bazel_tools//src/conditions:linux_aarch64": native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"),
"@bazel_tools//src/conditions:linux_ppc64le": native_arch_defines("PowerPC", "powerpc64le-unknown-linux-gnu"),
1 change: 1 addition & 0 deletions third_party/llvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def repo(name):
"//third_party/llvm:generated.patch", # Autogenerated, don't remove.
"//third_party/llvm:build.patch",
"//third_party/llvm:mathextras.patch",
"//third_party/llvm:toolchains.patch",
"//third_party/llvm:zstd.patch",
],
link_files = {"//third_party/llvm:run_lit.sh": "mlir/run_lit.sh"},
Expand Down

0 comments on commit 391748a

Please sign in to comment.