From 845438684a115d500418afea7a74f30fae63c248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 24 Dec 2024 00:12:47 +0100 Subject: [PATCH] move deps to modules --- WORKSPACE | 63 +++---------------- third_party/enzyme/BUILD | 0 third_party/enzyme/workspace.bzl | 12 ++++ third_party/hedron_compile_commands/BUILD | 0 .../hedron_compile_commands/workspace.bzl | 15 +++++ third_party/jax/BUILD | 0 third_party/jax/workspace.bzl | 14 +++++ third_party/xla/BUILD | 0 third_party/xla/workspace.bzl | 14 +++++ workspace.bzl | 2 + 10 files changed, 66 insertions(+), 54 deletions(-) create mode 100644 third_party/enzyme/BUILD create mode 100644 third_party/enzyme/workspace.bzl create mode 100644 third_party/hedron_compile_commands/BUILD create mode 100644 third_party/hedron_compile_commands/workspace.bzl create mode 100644 third_party/jax/BUILD create mode 100644 third_party/jax/workspace.bzl create mode 100644 third_party/xla/BUILD create mode 100644 third_party/xla/workspace.bzl diff --git a/WORKSPACE b/WORKSPACE index 23286788..1686b4ad 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,18 +1,6 @@ # add support for generating compile_commands -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - - -# Hedron's Compile Commands Extractor for Bazel -# https://github.com/hedronvision/bazel-compile-commands-extractor -http_archive( - name = "hedron_compile_commands", - - # Replace the commit hash (0e990032f3c5a866e72615cf67e5ce22186dcb97) in both places (below) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main), rather than using the stale one here. - # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). - url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/4f28899228fb3ad0126897876f147ca15026151e.tar.gz", - strip_prefix = "bazel-compile-commands-extractor-4f28899228fb3ad0126897876f147ca15026151e", - # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..." -) +load("//third_party/hedron_compile_commands:workspace.bzl", hedron_compile_commands_workspace = "repo") +hedron_compile_commands_workspace() load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") hedron_compile_commands_setup() load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive") @@ -22,41 +10,11 @@ hedron_compile_commands_setup_transitive_transitive() load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive") hedron_compile_commands_setup_transitive_transitive_transitive() -load("//:workspace.bzl", "JAX_COMMIT", "JAX_SHA256", "ENZYME_COMMIT", "ENZYME_SHA256", "XLA_PATCHES") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# http_archive( -# name = "rules_cc", -# sha256 = "a281b09e003a119bda2cea98c590129b783cc241fdd1a1de3baa656117e6cc3f" -# strip_prefix = "rules_cc-34f0e1f038cff9bf28d65d101c806b48f35bf92e", -# urls = [ -# "https://github.com/bazelbuild/rules_cc/archive/34f0e1f038cff9bf28d65d101c806b48f35bf92e.tar.gz", -# ], -# ) -# -# load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") -# -# rules_cc_dependencies() - -LLVM_TARGETS = ["X86", "AArch64", "AMDGPU", "NVPTX"] - -http_archive( - name = "jax", - sha256 = JAX_SHA256, - strip_prefix = "jax-" + JAX_COMMIT, - urls = ["https://github.com/google/jax/archive/{commit}.tar.gz".format(commit = JAX_COMMIT)], - patch_args = ["-p1"], - patches = ["//:patches/jax.patch"], -) +load("//third_party/jax:workspace.bzl", jax_workspace = "repo") +jax_workspace() -load("@jax//third_party/xla:workspace.bzl", "XLA_COMMIT", "XLA_SHA256") -http_archive( - name = "xla", - sha256 = XLA_SHA256, - strip_prefix = "xla-" + XLA_COMMIT, - urls = ["https://github.com/wsmoses/xla/archive/{commit}.tar.gz".format(commit = XLA_COMMIT)], - patch_cmds = XLA_PATCHES, -) +load("//third_party/xla:workspace.bzl", xla_workspace = "repo") +xla_workspace() load("@xla//third_party/py:python_init_rules.bzl", "python_init_rules") python_init_rules() @@ -82,14 +40,11 @@ python_init_pip() load("@pypi//:requirements.bzl", "install_deps") install_deps() -http_archive( - name = "enzyme", - sha256 = ENZYME_SHA256, - strip_prefix = "Enzyme-" + ENZYME_COMMIT + "/enzyme", - urls = ["https://github.com/EnzymeAD/Enzyme/archive/{commit}.tar.gz".format(commit = ENZYME_COMMIT)], -) +load("//third_party/enzyme:workspace.bzl", enzyme_workspace = "repo") +enzyme_workspace() load("@xla//third_party/llvm:workspace.bzl", llvm = "repo") +load("//:workspace.bzl", "LLVM_TARGETS") llvm("llvm-raw") load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") llvm_configure(name = "llvm-project", targets = LLVM_TARGETS) diff --git a/third_party/enzyme/BUILD b/third_party/enzyme/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/enzyme/workspace.bzl b/third_party/enzyme/workspace.bzl new file mode 100644 index 00000000..236917fa --- /dev/null +++ b/third_party/enzyme/workspace.bzl @@ -0,0 +1,12 @@ +"""Loads Enzyme.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "ENZYME_COMMIT", "ENZYME_SHA256") + +def repo(): + http_archive( + name = "enzyme", + sha256 = ENZYME_SHA256, + strip_prefix = "Enzyme-" + ENZYME_COMMIT + "/enzyme", + urls = ["https://github.com/EnzymeAD/Enzyme/archive/{commit}.tar.gz".format(commit = ENZYME_COMMIT)], + ) diff --git a/third_party/hedron_compile_commands/BUILD b/third_party/hedron_compile_commands/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/hedron_compile_commands/workspace.bzl b/third_party/hedron_compile_commands/workspace.bzl new file mode 100644 index 00000000..bbb25a02 --- /dev/null +++ b/third_party/hedron_compile_commands/workspace.bzl @@ -0,0 +1,15 @@ +"""Loads Hedron's Compile Commands Extractor for Bazel.""" +# https://github.com/hedronvision/bazel-compile-commands-extractor + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def repo(): + http_archive( + name = "hedron_compile_commands", + + # Replace the commit hash (0e990032f3c5a866e72615cf67e5ce22186dcb97) in both places (below) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main), rather than using the stale one here. + # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). + url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/4f28899228fb3ad0126897876f147ca15026151e.tar.gz", + strip_prefix = "bazel-compile-commands-extractor-4f28899228fb3ad0126897876f147ca15026151e", + # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..." + ) diff --git a/third_party/jax/BUILD b/third_party/jax/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/jax/workspace.bzl b/third_party/jax/workspace.bzl new file mode 100644 index 00000000..6249b37a --- /dev/null +++ b/third_party/jax/workspace.bzl @@ -0,0 +1,14 @@ +"""Loads JAX.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "JAX_COMMIT", "JAX_SHA256") + +def repo(): + http_archive( + name = "jax", + sha256 = JAX_SHA256, + strip_prefix = "jax-" + JAX_COMMIT, + urls = ["https://github.com/google/jax/archive/{commit}.tar.gz".format(commit = JAX_COMMIT)], + patch_args = ["-p1"], + patches = ["//:patches/jax.patch"], + ) diff --git a/third_party/xla/BUILD b/third_party/xla/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/xla/workspace.bzl b/third_party/xla/workspace.bzl new file mode 100644 index 00000000..daa8155b --- /dev/null +++ b/third_party/xla/workspace.bzl @@ -0,0 +1,14 @@ +"""Loads XLA.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "XLA_PATCHES") +load("@jax//third_party/xla:workspace.bzl", "XLA_COMMIT", "XLA_SHA256") + +def repo(): + http_archive( + name = "xla", + sha256 = XLA_SHA256, + strip_prefix = "xla-" + XLA_COMMIT, + urls = ["https://github.com/wsmoses/xla/archive/{commit}.tar.gz".format(commit = XLA_COMMIT)], + patch_cmds = XLA_PATCHES, + ) diff --git a/workspace.bzl b/workspace.bzl index 02779c30..56f96449 100644 --- a/workspace.bzl +++ b/workspace.bzl @@ -30,3 +30,5 @@ XLA_PATCHES = [ "find . -type f -name BUILD -exec sed -i.bak2 's/\\/\\/xla\\/mlir\\/memref:friends/\\/\\/visibility:public/g' {} +", "find xla/mlir -type f -name BUILD -exec sed -i.bak3 's/\\/\\/xla:internal/\\/\\/\\/\\/visibility:public/g' {} +" ] + +LLVM_TARGETS = ["X86", "AArch64", "AMDGPU", "NVPTX"]