diff --git a/packages.yaml b/packages.yaml
index 1dd5e099c40089e3fe392b8c10520693e83dc82b..54619e5b7025c457912075ed202c4022b9d27ab0 100644
--- a/packages.yaml
+++ b/packages.yaml
@@ -7,3 +7,5 @@ packages:
     py-torch:
         version: [1.11.0]
         variants: [~cuda~rocm~valgrind~mkldnn~mpi~gloo+tensorpipe~onnx_ml]
+    py-jax:
+        variants: [~cuda]
diff --git a/packages/bazel/add-include-limits-0.25.patch b/packages/bazel/add-include-limits-0.25.patch
new file mode 100644
index 0000000000000000000000000000000000000000..643bde5facc17c7530257e0f4c1ddecc7aaf1a8c
--- /dev/null
+++ b/packages/bazel/add-include-limits-0.25.patch
@@ -0,0 +1,11 @@
+diff -pur third_party/ijar/mapped_file_unix.cc third_party/ijar/mapped_file_unix.cc
+--- third_party/ijar/mapped_file_unix.cc	2021-10-05 15:24:37.243946507 +0200
++++ third_party/ijar/mapped_file_unix.cc	2021-10-05 15:24:28.707823401 +0200
+@@ -19,6 +19,7 @@
+ #include <sys/mman.h>
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "third_party/ijar/mapped_file.h"
+ 
diff --git a/packages/bazel/add-include-limits-zlib_client.patch b/packages/bazel/add-include-limits-zlib_client.patch
new file mode 100644
index 0000000000000000000000000000000000000000..bb64145dbb519fcbba9cad9584272e44121df5f7
--- /dev/null
+++ b/packages/bazel/add-include-limits-zlib_client.patch
@@ -0,0 +1,11 @@
+diff -pur third_party/ijar/zlib_client.h third_party/ijar/zlib_client.h
+--- third_party/ijar/zlib_client.h	2021-10-07 09:32:57.087301302 +0200
++++ third_party/ijar/zlib_client.h	1980-01-01 00:00:00.000000000 +0100
+@@ -16,6 +16,7 @@
+ #define THIRD_PARTY_IJAR_ZLIB_CLIENT_H_
+ 
+ #include <limits.h>
++#include <limits>
+ 
+ #include "third_party/ijar/common.h"
+ 
diff --git a/packages/bazel/bazelconfiguration-0.3.patch b/packages/bazel/bazelconfiguration-0.3.patch
new file mode 100644
index 0000000000000000000000000000000000000000..e6a974a98a9cbb6dd4118c3d056c61949571af07
--- /dev/null
+++ b/packages/bazel/bazelconfiguration-0.3.patch
@@ -0,0 +1,16 @@
+--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfiguration.java
++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfiguration.java
+@@ -150,6 +150,13 @@
+       builder.put("PATH", null);
+       builder.put("LD_LIBRARY_PATH", null);
+     }
++
++    Map<String, String> spackEnv = System.getenv();
++    for (String envName : spackEnv.keySet()) {
++      if (envName.startsWith("SPACK_")) {
++        builder.put(envName, spackEnv.get(envName));
++      }
++    }
+   }
+ 
+   private static PathFragment determineShellExecutable(OS os, PathFragment fromOption) {
diff --git a/packages/bazel/bazelruleclassprovider-0.14.patch b/packages/bazel/bazelruleclassprovider-0.14.patch
new file mode 100644
index 0000000000000000000000000000000000000000..b0aebdf359b6cd2e69bdca3820aa6faab9b03040
--- /dev/null
+++ b/packages/bazel/bazelruleclassprovider-0.14.patch
@@ -0,0 +1,16 @@
+--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+@@ -168,6 +168,13 @@ public class BazelRuleClassProvider {
+       env.put("PATH", null);
+     }
+ 
++    Map<String, String> spackEnv = System.getenv();
++    for (String envName : spackEnv.keySet()) {
++      if (envName.startsWith("SPACK_")) {
++        env.put(envName, spackEnv.get(envName));
++      }
++    }
++
+     // Shell environment variables specified via options take precedence over the
+     // ones inherited from the fragments. In the long run, these fragments will
+     // be replaced by appropriate default rc files anyway.
diff --git a/packages/bazel/bazelruleclassprovider-0.25.patch b/packages/bazel/bazelruleclassprovider-0.25.patch
new file mode 100644
index 0000000000000000000000000000000000000000..0d68cd98d97c1a2ca718577f449605878d48af07
--- /dev/null
+++ b/packages/bazel/bazelruleclassprovider-0.25.patch
@@ -0,0 +1,16 @@
+--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+@@ -181,6 +181,13 @@ public class BazelRuleClassProvider {
+           env.put("PATH", null);
+         }
+ 
++        Map<String, String> spackEnv = System.getenv();
++        for (String envName : spackEnv.keySet()) {
++          if (envName.startsWith("SPACK_")) {
++            env.put(envName, spackEnv.get(envName));
++          }
++        }
++
+         // Shell environment variables specified via options take precedence over the
+         // ones inherited from the fragments. In the long run, these fragments will
+         // be replaced by appropriate default rc files anyway.
diff --git a/packages/bazel/bazelruleclassprovider_fj-0.25.patch b/packages/bazel/bazelruleclassprovider_fj-0.25.patch
new file mode 100644
index 0000000000000000000000000000000000000000..709e5ee0202c07e6bc5b6202d654dbe2b97168a7
--- /dev/null
+++ b/packages/bazel/bazelruleclassprovider_fj-0.25.patch
@@ -0,0 +1,11 @@
+--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+@@ -185,7 +185,7 @@ public class BazelRuleClassProvider {
+ 
+         Map<String, String> spackEnv = System.getenv();
+         for (String envName : spackEnv.keySet()) {
+-          if (envName.startsWith("SPACK_")) {
++          if ((envName.startsWith("SPACK_")) || (envName.equals("fcc_ENV")) || (envName.equals("FCC_ENV"))) {
+             env.put(envName, spackEnv.get(envName));
+           }
+         }
diff --git a/packages/bazel/blaze_util_posix-0.29.1.patch b/packages/bazel/blaze_util_posix-0.29.1.patch
new file mode 100644
index 0000000000000000000000000000000000000000..aa773a33a5d7a4a87086c17b8cdb56b685e3c67c
--- /dev/null
+++ b/packages/bazel/blaze_util_posix-0.29.1.patch
@@ -0,0 +1,12 @@
+diff -Naur a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
+--- a/src/main/cpp/blaze_util_posix.cc	1980-01-01 00:00:00.000000000 -0800
++++ b/src/main/cpp/blaze_util_posix.cc	2022-06-30 23:34:08.000000000 -0700
+@@ -600,7 +600,7 @@
+   // Prefer OFD locks if available.  POSIX locks can be lost "accidentally"
+   // due to any close() on the lock file, and are not reliably preserved
+   // across execve() on Linux, which we need for --batch mode.
+-  if (fcntl(fd, F_OFD_SETLK, lock) == 0) return 0;
++  if (fcntl(fd, F_SETLK, lock) == 0) return 0;
+   if (errno != EINVAL) {
+     if (errno != EACCES && errno != EAGAIN) {
+       BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
diff --git a/packages/bazel/build-0.29.1.patch b/packages/bazel/build-0.29.1.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c3ed9ab254b253066ce37f9b0eb497ebb1e589d4
--- /dev/null
+++ b/packages/bazel/build-0.29.1.patch
@@ -0,0 +1,61 @@
+From 9c9d27561780bc56d9f0867e325c7421a94ee1cb Mon Sep 17 00:00:00 2001
+From: Harsh Bhatia <bhatia4@llnl.gov>
+Date: Tue, 15 Dec 2020 15:56:10 -0800
+Subject: [PATCH] https://github.com/bazelbuild/bazel/commit/ab62a6e097590dac5ec946ad7a796ea0e8593ae0 
+
+---
+ src/conditions/BUILD | 6 ++++++
+ third_party/BUILD    | 8 ++++++--
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/conditions/BUILD b/src/conditions/BUILD
+index 2b28e28057..faa41a439d 100644
+--- a/src/conditions/BUILD
++++ b/src/conditions/BUILD
+@@ -10,6 +10,12 @@ filegroup(
+     visibility = ["//src:__pkg__"],
+ )
+ 
++config_setting(
++    name = "linux_ppc",
++    values = {"cpu": "ppc"},
++    visibility = ["//visibility:public"],
++)
++
+ config_setting(
+     name = "linux_x86_64",
+     values = {"cpu": "k8"},
+diff --git a/third_party/BUILD b/third_party/BUILD
+index 159006d741..4fcae54c00 100644
+--- a/third_party/BUILD
++++ b/third_party/BUILD
+@@ -523,12 +523,13 @@ UNNECESSARY_DYNAMIC_LIBRARIES = select({
+     "//src/conditions:darwin": "*.so *.dll",
+     "//src/conditions:darwin_x86_64": "*.so *.dll",
+     "//src/conditions:linux_x86_64": "*.jnilib *.dll",
++    "//src/conditions:linux_ppc": "*.so *.jnilib *.dll",
+     # The .so file is an x86 one, so we can just remove it if the CPU is not x86
+     "//src/conditions:arm": "*.so *.jnilib *.dll",
+     "//src/conditions:linux_aarch64": "*.so *.jnilib *.dll",
+     # Play it safe -- better have a big binary than a slow binary
+     # zip -d does require an argument. Supply something bogus.
+-    "//conditions:default": "*.bogusextension",
++    "//conditions:default": "",
+ })
+ 
+ # Remove native libraries that are for a platform different from the one we are
+@@ -537,7 +538,10 @@ genrule(
+     name = "filter_netty_dynamic_libs",
+     srcs = ["netty_tcnative/netty-tcnative-boringssl-static-2.0.24.Final.jar"],
+     outs = ["netty_tcnative/netty-tcnative-filtered.jar"],
+-    cmd = "cp $< $@ && zip -qd $@ " + UNNECESSARY_DYNAMIC_LIBRARIES,
++    cmd = "cp $< $@ && " +
++      # End successfully if there is nothing to be deleted from the archive
++      "if [ -n '" + UNNECESSARY_DYNAMIC_LIBRARIES + "' ]; then " +
++      "zip -qd $@ " + UNNECESSARY_DYNAMIC_LIBRARIES + "; fi",
+ )
+ 
+ java_import(
+-- 
+2.21.0 (Apple Git-122.2)
+
diff --git a/packages/bazel/cc_configure-0.3.0.patch b/packages/bazel/cc_configure-0.3.0.patch
new file mode 100644
index 0000000000000000000000000000000000000000..79e12269a6bfeb05e684400a68450a9f3a709470
--- /dev/null
+++ b/packages/bazel/cc_configure-0.3.0.patch
@@ -0,0 +1,24 @@
+--- a/tools/cpp/cc_configure.bzl
++++ b/tools/cpp/cc_configure.bzl
+@@ -173,8 +173,19 @@
+   else:
+     inc_dirs = result.stderr[index1 + 1:index2].strip()
+ 
+-  return [repository_ctx.path(_cxx_inc_convert(p))
+-          for p in inc_dirs.split("\n")]
++  default_inc_directories = [
++    repository_ctx.path(_cxx_inc_convert(p))
++    for p in inc_dirs.split("\n")
++  ]
++
++  env = repository_ctx.os.environ
++  if "SPACK_INCLUDE_DIRS" in env:
++    for path in env["SPACK_INCLUDE_DIRS"].split(":"):
++      default_inc_directories.append(
++        repository_ctx.path(_cxx_inc_convert(path))
++      )
++
++  return default_inc_directories
+ 
+ def _add_option_if_supported(repository_ctx, cc, option):
+   """Checks that `option` is supported by the C compiler."""
diff --git a/packages/bazel/cc_configure-0.5.0.patch b/packages/bazel/cc_configure-0.5.0.patch
new file mode 100644
index 0000000000000000000000000000000000000000..470986bec6650579a8a58951752fb0bfc43943a7
--- /dev/null
+++ b/packages/bazel/cc_configure-0.5.0.patch
@@ -0,0 +1,24 @@
+--- a/tools/cpp/cc_configure.bzl
++++ b/tools/cpp/cc_configure.bzl
+@@ -200,8 +200,19 @@
+   else:
+     inc_dirs = result.stderr[index1 + 1:index2].strip()
+ 
+-  return [_escape_string(repository_ctx.path(_cxx_inc_convert(p)))
+-          for p in inc_dirs.split("\n")]
++  default_inc_directories = [
++    _escape_string(repository_ctx.path(_cxx_inc_convert(p)))
++    for p in inc_dirs.split("\n")
++  ]
++
++  env = repository_ctx.os.environ
++  if "SPACK_INCLUDE_DIRS" in env:
++    for path in env["SPACK_INCLUDE_DIRS"].split(":"):
++      default_inc_directories.append(
++        repository_ctx.path(_cxx_inc_convert(path))
++      )
++
++  return default_inc_directories
+ 
+ 
+ def _add_option_if_supported(repository_ctx, cc, option):
diff --git a/packages/bazel/cc_env.patch b/packages/bazel/cc_env.patch
new file mode 100644
index 0000000000000000000000000000000000000000..034fb77c9dd26a0d3663aaaaf853668bde1217e9
--- /dev/null
+++ b/packages/bazel/cc_env.patch
@@ -0,0 +1,13 @@
+diff --git a/compile.sh b/compile.sh
+index ed506d2..a5474ac 100755
+--- a/compile.sh
++++ b/compile.sh
+@@ -92,7 +92,7 @@ display "."
+ log "Building output/bazel"
+ # We set host and target platform directly since the defaults in @bazel_tools
+ # have not yet been generated.
+-bazel_build "src:bazel_nojdk${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel_nojdk${EXE_EXT}" \
+   --host_platform=@bazel_tools//platforms:host_platform \
+   --platforms=@bazel_tools//platforms:target_platform \
+   || fail "Could not build Bazel"
diff --git a/packages/bazel/compile-0.13.patch b/packages/bazel/compile-0.13.patch
new file mode 100644
index 0000000000000000000000000000000000000000..13c82e7631bbcde85d0fd4301297166a32815721
--- /dev/null
+++ b/packages/bazel/compile-0.13.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -92,7 +92,7 @@
+ log "Building output/bazel"
+ # We set host and target platform directly since the defaults in @bazel_tools
+ # have not yet been generated.
+-bazel_build "src:bazel${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel${EXE_EXT}" \
+   --host_platform=@bazel_tools//platforms:host_platform \
+   --platforms=@bazel_tools//platforms:target_platform \
+   || fail "Could not build Bazel"
diff --git a/packages/bazel/compile-0.16.patch b/packages/bazel/compile-0.16.patch
new file mode 100644
index 0000000000000000000000000000000000000000..f61f521a15b9affe110a6b8c703c6ad31c234fa0
--- /dev/null
+++ b/packages/bazel/compile-0.16.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -92,7 +92,7 @@ display "."
+ log "Building output/bazel"
+ # We set host and target platform directly since the defaults in @bazel_tools
+ # have not yet been generated.
+-bazel_build "src:bazel_nojdk${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel_nojdk${EXE_EXT}" \
+   --host_platform=@bazel_tools//platforms:host_platform \
+   --platforms=@bazel_tools//platforms:target_platform \
+   || fail "Could not build Bazel"
diff --git a/packages/bazel/compile-0.21.patch b/packages/bazel/compile-0.21.patch
new file mode 100644
index 0000000000000000000000000000000000000000..d666a0f055ca04560c5cb0c885708b8c42acd794
--- /dev/null
+++ b/packages/bazel/compile-0.21.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -92,7 +92,7 @@ display "."
+ log "Building output/bazel"
+ # We set host and target platform directly since the defaults in @bazel_tools
+ # have not yet been generated.
+-bazel_build "src:bazel_nojdk${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel_nojdk${EXE_EXT}" \
+   --action_env=PATH \
+   --host_platform=@bazel_tools//platforms:host_platform \
+   --platforms=@bazel_tools//platforms:target_platform \
diff --git a/packages/bazel/compile-0.29.patch b/packages/bazel/compile-0.29.patch
new file mode 100644
index 0000000000000000000000000000000000000000..6cb2eb0b57277f39bbb6d7d3f372e8adfa27722e
--- /dev/null
+++ b/packages/bazel/compile-0.29.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -63,7 +63,7 @@
+ log "Building output/bazel"
+ # We set host and target platform directly because we are building for the local
+ # host.
+-bazel_build "src:bazel_nojdk${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel_nojdk${EXE_EXT}" \
+   --action_env=PATH \
+   --host_platform=@local_config_platform//:host \
+   --platforms=@local_config_platform//:host \
diff --git a/packages/bazel/compile-0.3.patch b/packages/bazel/compile-0.3.patch
new file mode 100644
index 0000000000000000000000000000000000000000..82db6efb6e86f766c169d93f11e8272385e30eba
--- /dev/null
+++ b/packages/bazel/compile-0.3.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -99,7 +99,7 @@
+   new_step 'Building Bazel with Bazel'
+   display "."
+   log "Building output/bazel"
+-  bazel_build "src:bazel${EXE_EXT}"
++  CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel${EXE_EXT}"
+   cp -f "bazel-bin/src/bazel${EXE_EXT}" "output/bazel${EXE_EXT}"
+   chmod 0755 "output/bazel${EXE_EXT}"
+   BAZEL="$(pwd)/output/bazel${EXE_EXT}"
diff --git a/packages/bazel/compile-0.4.patch b/packages/bazel/compile-0.4.patch
new file mode 100644
index 0000000000000000000000000000000000000000..80eab26a88279781198f6a23e6ccf4675175dd45
--- /dev/null
+++ b/packages/bazel/compile-0.4.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -124,7 +124,7 @@
+   new_step 'Building Bazel with Bazel'
+   display "."
+   log "Building output/bazel"
+-  bazel_build "src:bazel${EXE_EXT}" \
++  CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel${EXE_EXT}" \
+     || fail "Could not build Bazel"
+   bazel_bin_path="$(get_bazel_bin_path)/src/bazel${EXE_EXT}"
+   [ -e "$bazel_bin_path" ] \
diff --git a/packages/bazel/compile-0.6.patch b/packages/bazel/compile-0.6.patch
new file mode 100644
index 0000000000000000000000000000000000000000..64eb408e5df8743d6083e904d7b3049575115c49
--- /dev/null
+++ b/packages/bazel/compile-0.6.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -85,7 +85,7 @@
+ log "Building output/bazel"
+ # We set host and target platform directly since the defaults in @bazel_tools
+ # have not yet been generated.
+-bazel_build "src:bazel${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel${EXE_EXT}" \
+   --experimental_host_platform=//tools/platforms:host_platform \
+   --experimental_platforms=//tools/platforms:target_platform \
+   || fail "Could not build Bazel"
diff --git a/packages/bazel/compile-0.9.patch b/packages/bazel/compile-0.9.patch
new file mode 100644
index 0000000000000000000000000000000000000000..135de3a00fdadc3e1e4fa3b6d64d1da90f2ec67e
--- /dev/null
+++ b/packages/bazel/compile-0.9.patch
@@ -0,0 +1,11 @@
+--- a/compile.sh
++++ b/compile.sh
+@@ -92,7 +92,7 @@
+ log "Building output/bazel"
+ # We set host and target platform directly since the defaults in @bazel_tools
+ # have not yet been generated.
+-bazel_build "src:bazel${EXE_EXT}" \
++CC=$SPACK_CC CXX=$SPACK_CXX bazel_build "src:bazel${EXE_EXT}" \
+   --host_platform=//tools/platforms:host_platform \
+   --platforms=//tools/platforms:target_platform \
+   || fail "Could not build Bazel"
diff --git a/packages/bazel/cppcompileaction-0.3.0.patch b/packages/bazel/cppcompileaction-0.3.0.patch
new file mode 100644
index 0000000000000000000000000000000000000000..dd23972d9925de9b9631361ad5d7759e985f6d66
--- /dev/null
+++ b/packages/bazel/cppcompileaction-0.3.0.patch
@@ -0,0 +1,11 @@
+--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java.orig    2020-06-08 13:42:14.035342560 -0400
++++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java 2020-06-08 13:42:25.149375458 -0400
+@@ -963,7 +963,7 @@
+           // are, it's probably due to a non-hermetic #include, & we should stop
+           // the build with an error.
+           if (execPath.startsWith(execRoot)) {
+-            execPathFragment = execPath.relativeTo(execRoot); // funky but tolerable path
++             //  execPathFragment = execPath.relativeTo(execRoot); // funky but tolerable path
+           } else {
+             problems.add(execPathFragment.getPathString());
+             continue;
diff --git a/packages/bazel/cppcompileaction-0.3.2.patch b/packages/bazel/cppcompileaction-0.3.2.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c15d3bf64a180050bbdd00e59620f40b0fb2d168
--- /dev/null
+++ b/packages/bazel/cppcompileaction-0.3.2.patch
@@ -0,0 +1,11 @@
+--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java.orig  2020-03-25 08:54:37.914186251 -0400
++++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java       2020-03-25 08:55:01.356250657 -0400
+@@ -148,7 +148,7 @@
+         if (execPath.startsWith(execRoot)) {
+           execPathFragment = execPath.relativeTo(execRoot); // funky but tolerable path
+         } else {
+-          problems.add(execPathFragment.getPathString());
++          //          problems.add(execPathFragment.getPathString());
+           continue;
+         }
+       }
diff --git a/packages/bazel/disabledepcheck.patch b/packages/bazel/disabledepcheck.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c15d3bf64a180050bbdd00e59620f40b0fb2d168
--- /dev/null
+++ b/packages/bazel/disabledepcheck.patch
@@ -0,0 +1,11 @@
+--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java.orig  2020-03-25 08:54:37.914186251 -0400
++++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java       2020-03-25 08:55:01.356250657 -0400
+@@ -148,7 +148,7 @@
+         if (execPath.startsWith(execRoot)) {
+           execPathFragment = execPath.relativeTo(execRoot); // funky but tolerable path
+         } else {
+-          problems.add(execPathFragment.getPathString());
++          //          problems.add(execPathFragment.getPathString());
+           continue;
+         }
+       }
diff --git a/packages/bazel/disabledepcheck_old.patch b/packages/bazel/disabledepcheck_old.patch
new file mode 100644
index 0000000000000000000000000000000000000000..dd23972d9925de9b9631361ad5d7759e985f6d66
--- /dev/null
+++ b/packages/bazel/disabledepcheck_old.patch
@@ -0,0 +1,11 @@
+--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java.orig    2020-06-08 13:42:14.035342560 -0400
++++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java 2020-06-08 13:42:25.149375458 -0400
+@@ -963,7 +963,7 @@
+           // are, it's probably due to a non-hermetic #include, & we should stop
+           // the build with an error.
+           if (execPath.startsWith(execRoot)) {
+-            execPathFragment = execPath.relativeTo(execRoot); // funky but tolerable path
++             //  execPathFragment = execPath.relativeTo(execRoot); // funky but tolerable path
+           } else {
+             problems.add(execPathFragment.getPathString());
+             continue;
diff --git a/packages/bazel/gcc11_1.patch b/packages/bazel/gcc11_1.patch
new file mode 100644
index 0000000000000000000000000000000000000000..5868f20291ee13c0a8988b312c05e2e7f1fefa3c
--- /dev/null
+++ b/packages/bazel/gcc11_1.patch
@@ -0,0 +1,12 @@
+diff --git a/third_party/ijar/zlib_client.h b/third_party/ijar/zlib_client.h
+index ed6616362fcc..c4b051e0100c 100644
+--- a/third_party/ijar/zlib_client.h
++++ b/third_party/ijar/zlib_client.h
+@@ -16,6 +16,7 @@
+ #define THIRD_PARTY_IJAR_ZLIB_CLIENT_H_
+ 
+ #include <limits.h>
++#include <limits>
+ 
+ #include "third_party/ijar/common.h"
+ 
diff --git a/packages/bazel/gcc11_2.patch b/packages/bazel/gcc11_2.patch
new file mode 100644
index 0000000000000000000000000000000000000000..aac5b08b07348e4db69e4d76a715c49e52e5a32e
--- /dev/null
+++ b/packages/bazel/gcc11_2.patch
@@ -0,0 +1,14 @@
+diff --git a/third_party/ijar/zlib_client.h b/third_party/ijar/zlib_client.h
+index c4b051e0100c..0a917ff0a99a 100644
+--- a/third_party/ijar/zlib_client.h
++++ b/third_party/ijar/zlib_client.h
+@@ -16,7 +16,9 @@
+ #define THIRD_PARTY_IJAR_ZLIB_CLIENT_H_
+ 
+ #include <limits.h>
++
+ #include <limits>
++#include <stdexcept>
+ 
+ #include "third_party/ijar/common.h"
+ 
diff --git a/packages/bazel/gcc11_3.patch b/packages/bazel/gcc11_3.patch
new file mode 100644
index 0000000000000000000000000000000000000000..78d24e768ebe18619cb624ae4dc0be1a6e5a855a
--- /dev/null
+++ b/packages/bazel/gcc11_3.patch
@@ -0,0 +1,17 @@
+diff --git a/third_party/ijar/mapped_file_unix.cc b/third_party/ijar/mapped_file_unix.cc
+index 6e3a90871844..65179e3290ec 100644
+--- a/third_party/ijar/mapped_file_unix.cc
++++ b/third_party/ijar/mapped_file_unix.cc
+@@ -15,10 +15,11 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <stdio.h>
+-#include <unistd.h>
+ #include <sys/mman.h>
++#include <unistd.h>
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "third_party/ijar/mapped_file.h"
+ 
diff --git a/packages/bazel/gcc11_4.patch b/packages/bazel/gcc11_4.patch
new file mode 100644
index 0000000000000000000000000000000000000000..972c9035d648f9df6c6da75dd41c96318d95e3f8
--- /dev/null
+++ b/packages/bazel/gcc11_4.patch
@@ -0,0 +1,44 @@
+--- a/third_party/grpc/grpc_1.33.1.patch
++++ b/third_party/grpc/grpc_1.33.1.patch
+@@ -58,6 +58,14 @@ index 09fcad95a2..9b737e5deb 100644
+      )
+  
+      native.bind(
++@@ -245,6 +245,7 @@ def grpc_deps():
++                 "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
++                 "https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
++             ],
+++            patches = ["@com_github_grpc_grpc//:third_party/abseil-cpp/absl.patch"],
++         )
++
++     if "bazel_toolchains" not in native.existing_rules():
+ diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl
+ index 4c1dfad2e8..f63c54ddef 100644
+ --- a/bazel/grpc_extra_deps.bzl
+@@ -120,3 +128,25 @@ index c047f0c515..7c24fbc617 100644
+          ":windows": "@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h",
+          ":android": "@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h",
+          "//conditions:default": "@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h",
++
++--- /dev/null
+++++ b/third_party/abseil-cpp/absl.patch
++@@ -0,0 +1,18 @@
+++0e2c62da1dcaf6529abab952bdcc96c6de2d9506 by Abseil Team <absl-team@google.com>:
+++
+++Add missing <limits> include
+++
+++PiperOrigin-RevId: 339054753
+++
+++--
+++
+++--- absl/synchronization/internal/graphcycles.cc
++++++ absl/synchronization/internal/graphcycles.cc
+++@@ -37,6 +37,7 @@
+++ 
+++ #include <algorithm>
+++ #include <array>
++++#include <limits>
+++ #include "absl/base/internal/hide_ptr.h"
+++ #include "absl/base/internal/raw_logging.h"
+++ #include "absl/base/internal/spinlock.h"
+
diff --git a/packages/bazel/linux_ppc-0.29.1.patch b/packages/bazel/linux_ppc-0.29.1.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c3ed9ab254b253066ce37f9b0eb497ebb1e589d4
--- /dev/null
+++ b/packages/bazel/linux_ppc-0.29.1.patch
@@ -0,0 +1,61 @@
+From 9c9d27561780bc56d9f0867e325c7421a94ee1cb Mon Sep 17 00:00:00 2001
+From: Harsh Bhatia <bhatia4@llnl.gov>
+Date: Tue, 15 Dec 2020 15:56:10 -0800
+Subject: [PATCH] https://github.com/bazelbuild/bazel/commit/ab62a6e097590dac5ec946ad7a796ea0e8593ae0 
+
+---
+ src/conditions/BUILD | 6 ++++++
+ third_party/BUILD    | 8 ++++++--
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/conditions/BUILD b/src/conditions/BUILD
+index 2b28e28057..faa41a439d 100644
+--- a/src/conditions/BUILD
++++ b/src/conditions/BUILD
+@@ -10,6 +10,12 @@ filegroup(
+     visibility = ["//src:__pkg__"],
+ )
+ 
++config_setting(
++    name = "linux_ppc",
++    values = {"cpu": "ppc"},
++    visibility = ["//visibility:public"],
++)
++
+ config_setting(
+     name = "linux_x86_64",
+     values = {"cpu": "k8"},
+diff --git a/third_party/BUILD b/third_party/BUILD
+index 159006d741..4fcae54c00 100644
+--- a/third_party/BUILD
++++ b/third_party/BUILD
+@@ -523,12 +523,13 @@ UNNECESSARY_DYNAMIC_LIBRARIES = select({
+     "//src/conditions:darwin": "*.so *.dll",
+     "//src/conditions:darwin_x86_64": "*.so *.dll",
+     "//src/conditions:linux_x86_64": "*.jnilib *.dll",
++    "//src/conditions:linux_ppc": "*.so *.jnilib *.dll",
+     # The .so file is an x86 one, so we can just remove it if the CPU is not x86
+     "//src/conditions:arm": "*.so *.jnilib *.dll",
+     "//src/conditions:linux_aarch64": "*.so *.jnilib *.dll",
+     # Play it safe -- better have a big binary than a slow binary
+     # zip -d does require an argument. Supply something bogus.
+-    "//conditions:default": "*.bogusextension",
++    "//conditions:default": "",
+ })
+ 
+ # Remove native libraries that are for a platform different from the one we are
+@@ -537,7 +538,10 @@ genrule(
+     name = "filter_netty_dynamic_libs",
+     srcs = ["netty_tcnative/netty-tcnative-boringssl-static-2.0.24.Final.jar"],
+     outs = ["netty_tcnative/netty-tcnative-filtered.jar"],
+-    cmd = "cp $< $@ && zip -qd $@ " + UNNECESSARY_DYNAMIC_LIBRARIES,
++    cmd = "cp $< $@ && " +
++      # End successfully if there is nothing to be deleted from the archive
++      "if [ -n '" + UNNECESSARY_DYNAMIC_LIBRARIES + "' ]; then " +
++      "zip -qd $@ " + UNNECESSARY_DYNAMIC_LIBRARIES + "; fi",
+ )
+ 
+ java_import(
+-- 
+2.21.0 (Apple Git-122.2)
+
diff --git a/packages/bazel/package.py b/packages/bazel/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..a83c5cb6339f7055f93e809eb36d502b169fe9f4
--- /dev/null
+++ b/packages/bazel/package.py
@@ -0,0 +1,288 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+import re
+
+from spack.package import *
+
+
+class Bazel(Package):
+    """Bazel is an open-source build and test tool similar to Make, Maven, and
+    Gradle. It uses a human-readable, high-level build language. Bazel supports
+    projects in multiple languages and builds outputs for multiple platforms.
+    Bazel supports large codebases across multiple repositories, and large
+    numbers of users."""
+
+    homepage = "https://bazel.build/"
+    url = "https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-dist.zip"
+
+    tags = ["build-tools"]
+
+    version("5.2.0", sha256="820a94dbb14071ed6d8c266cf0c080ecb265a5eea65307579489c4662c2d582a")
+    version("5.1.1", sha256="7f5d3bc1d344692b2400f3765fd4b5c0b636eb4e7a8a7b17923095c7b56a4f78")
+    version("5.1.0", sha256="4de301f509fc6d0cbc697b2017384ecdc94df8f36245bbcbedc7ea6780acc9f5")
+    version("5.0.0", sha256="072dd62d237dbc11e0bac02e118d8c2db4d0ba3ba09f1a0eb1e2a460fb8419db")
+    version("4.2.2", sha256="9981d0d53a356c4e87962847750a97c9e8054e460854748006c80f0d7e2b2d33")
+    version("4.2.1", sha256="12ea7aa11e2bdb12de1dceb9939a22e96f5a480437cb17c123379d8e0fdf5e82")
+    version("4.2.0", sha256="74814b63920aaee47dbbbee7082e5c4317e4eebaf07e03c5fb5626e1716f1034")
+    version("4.1.0", sha256="f377d755c96a50f6bd2f423562598d822f43356783330a0b780ad442864d6eeb")
+    version("4.0.0", sha256="d350f80e70654932db252db380d2ec0144a00e86f8d9f2b4c799ffdb48e9cdd1")
+    version("3.7.2", sha256="de255bb42163a915312df9f4b86e5b874b46d9e8d4b72604b5123c3a845ed9b1")
+    version("3.7.1", sha256="c9244e5905df6b0190113e26082c72d58b56b1b0dec66d076f083ce4089b0307")
+    version("3.7.0", sha256="63873623917c756d1be49ff4d5fc23049736180e6b9a7d5236c6f204eddae3cc")
+    version("3.6.0", sha256="3a18f24febb5203f11b0985b27e120ac623058d1d5ca79cd6df992e67d57240a")
+    version("3.5.1", sha256="67eae714578b22d24192b0eb3a2d35b07578bbd57a33c50f1e74f8acd6378b3c")
+    version("3.5.0", sha256="334429059cf82e222ca8a9d9dbbd26f8e1eb308613463c2b8655dd4201b127ec")
+    version("3.4.1", sha256="27af1f11c8f23436915925b25cf6e1fb07fccf2d2a193a307c93437c60f63ba8")
+    version("3.4.0", sha256="7583abf8905ba9dd5394294e815e8873635ac4e5067e63392e8a33b397e450d8")
+    version("3.3.1", sha256="e0f1f43c65c4e0a38522b37e81f6129d8a1f7cd3d8884847be306544a7492747")
+    version("3.3.0", sha256="05a03960de09d5775839c5766ad8a0a30f261feaba5fa53ce3e49168d1eee826")
+    version("3.2.0", sha256="44ec129436f6de45f2230e14100104919443a1364c2491f5601666b358738bfa")
+    version("3.1.0", sha256="d7f40d0cac95a06cea6cb5b7f7769085257caebc3ee84269dd9298da760d5615")
+    version("3.0.0", sha256="530f5132e0a50da7ebb0ed08d9b6f1ddfd0d7d9b5d0beb2df5d687a4c8daf6b3")
+    version("2.2.0", sha256="9379878a834d105a47a87d3d7b981852dd9f64bc16620eacd564b48533e169a7")
+    version("2.1.1", sha256="83f67f28f4e47ff69043307d1791c9bffe83949e84165d49058b84eded932647")
+    version("2.1.0", sha256="3371cd9050989173a3b27364668328653a65653a50a85c320adc53953b4d5f46")
+    version("2.0.1", sha256="a863ed9e6fc420fbd92e63a12fe1a5b9be1a7a36f11f61f1fdc582c813bbe543")
+    version("2.0.0", sha256="724da3c656f68e787a86ebb9844773aa1c2e3a873cc39462a8f1b336153d6cbb")
+    version("1.2.1", sha256="255da49d0f012bc4f2c1d6d3ccdbe578e22fe97b8d124e1629a486fe2a09d3e1")
+    version("1.2.0", sha256="9cb46b0a18b9166730307a0e82bf4c02281a1cc6da0fb11239e6fe4147bdee6e")
+    version("1.1.0", sha256="4b66a8c93af7832ed32e7236cf454a05f3aa06d25a8576fc3f83114f142f95ab")
+    version("1.0.1", sha256="f4d2dfad011ff03a5fae41b9b02cd96cd7297c1205d496603d66516934fbcfee")
+    version("1.0.0", sha256="c61daf0b69dd95205c695b2f9022d296d052c727062cfd396d54ffb2154f8cac")
+    version("0.29.1", sha256="872a52cff208676e1169b3e1cae71b1fe572c4109cbd66eab107d8607c378de5")
+    version("0.29.0", sha256="01cb6f2e808bd016cf0e217e12373c9efb808123e58b37885be8364458d3a40a")
+    version("0.28.1", sha256="2cea463d611f5255d2f3d41c8de5dcc0961adccb39cf0ac036f07070ba720314")
+    version("0.28.0", sha256="26ad8cdadd413b8432cf46d9fc3801e8db85d9922f85dd8a7f5a92fec876557f")
+    version("0.27.2", sha256="5e1bf2b48e54eb7e518430667d29aef53695d6dd7c718665a52131ab27aadab2")
+    version("0.27.1", sha256="8051d77da4ec338acd91770f853e4c25f4407115ed86fd35a6de25921673e779")
+    version("0.27.0", sha256="c3080d3b959ac08502ad5c84a51608c291accb1481baad88a628bbf79b30c67a")
+    version("0.26.1", sha256="c0e94f8f818759f3f67af798c38683520c540f469cb41aea8f5e5a0e43f11600")
+    version("0.26.0", sha256="d26dadf62959255d58e523da3448a6222af768fe1224e321b120c1d5bbe4b4f2")
+    version("0.25.3", sha256="23eafd3e439bc71baba9c592b52cb742dabc8640a13b9da1751fec090a2dda99")
+    version("0.25.2", sha256="7456032199852c043e6c5b3e4c71dd8089c1158f72ec554e6ec1c77007f0ab51")
+    version("0.25.1", sha256="a52bb31aeb1f821e649d25ef48023cfb54a12887aff875c6349ebcac36c2f056")
+    version("0.25.0", sha256="f624fe9ca8d51de192655369ac538c420afb7cde16e1ad052554b582fff09287")
+    version("0.24.1", sha256="56ea1b199003ad832813621744178e42b39e6206d34fbae342562c287da0cd54")
+    version("0.24.0", sha256="621d2a97899a88850a913eabf9285778331a309fd4658b225b1377f80060fa85")
+    version("0.23.2", sha256="293a5a7d851e0618eeb5e6958d94a11d45b6a00f2ba9376de61ac2bd5f917439")
+    version("0.23.1", sha256="dd47199f92452bf67b2c5d60ad4b7143554eaf2c6196ab6e8713449d81a0491d")
+    version("0.23.0", sha256="2daf9c2c6498836ed4ebae7706abb809748b1350cacd35b9f89452f31ac0acc1")
+    version("0.22.0", sha256="6860a226c8123770b122189636fb0c156c6e5c9027b5b245ac3b2315b7b55641")
+    version("0.21.0", sha256="6ccb831e683179e0cfb351cb11ea297b4db48f9eab987601c038aa0f83037db4")
+    version("0.20.0", sha256="1945afa84fd8858b0a3c68c09915a4bc81065c61df2591387b2985e2297d30bd")
+    version("0.19.2", sha256="11234cce4f6bdc62c3ac688f41c7b5c178eecb6f7e2c4ba0bcf00ba8565b1d19")
+    version("0.19.1", sha256="c9405f7b8c79ebc81f9f0e49bb656df4a0da246771d010c2cdd6bb30e2500ac0")
+    version("0.19.0", sha256="ee6135c5c47306c8421d43ad83aabc4f219cb065376ee37797f2c8ba9a615315")
+    version("0.18.1", sha256="baed9f28c317000a4ec1ad2571b3939356d22746ca945ac2109148d7abb860d4")
+    version("0.18.0", sha256="d0e86d2f7881ec8742a9823a986017452d2da0dfe4e989111da787cb89257155")
+    version("0.17.2", sha256="b6e87acfa0a405bb8b3417c58477b66d5bc27dc0d31ba6fa12bc255b9278d33b")
+    version("0.17.1", sha256="23e4281c3628cbd746da3f51330109bbf69780bd64461b63b386efae37203f20")
+    version("0.16.1", sha256="09c66b94356c82c52f212af52a81ac28eb06de1313755a2f23eeef84d167b36c")
+    version("0.16.0", sha256="c730593916ef0ba62f3d113cc3a268e45f7e8039daf7b767c8641b6999bd49b1")
+    version("0.15.2", sha256="bf53ec73be3a6d412d85ef612cec6e9c85db45da42001fab0cf1dad44cfc03f1")
+    version("0.15.1", sha256="c62b351fa4c1ba5aeb34d0a137176f8e8f1d89a32f548a10e96c11df176ffc6c")
+    version("0.15.0", sha256="c3b716e6625e6b8c323350c95cd3ae0f56aeb00458dddd10544d5bead8a7b602")
+    version("0.14.1", sha256="d49cdcd82618ae7a7a190e6f0a80d9bf85c1a66b732f994f37732dc14ffb0025")
+    version("0.14.0", sha256="259627de8b9d415cc80904523facf3d50e6e8e68448ab968eb1c9cb8ca1ef843")
+    version("0.13.1", sha256="b0269e75b40d87ff87886e5f3432cbf88f70c96f907ab588e6c21b2922d72db0")
+    version("0.13.0", sha256="82e9035084660b9c683187618a29aa896f8b05b5f16ae4be42a80b5e5b6a7690")
+    version("0.12.0", sha256="3b3e7dc76d145046fdc78db7cac9a82bc8939d3b291e53a7ce85315feb827754")
+    version("0.11.1", sha256="e8d762bcc01566fa50952c8028e95cfbe7545a39b8ceb3a0d0d6df33b25b333f")
+    version("0.11.0", sha256="abfeccc94728cb46be8dbb3507a23ccffbacef9fbda96a977ef4ea8d6ab0d384")
+    version("0.10.1", sha256="708248f6d92f2f4d6342006c520f22dffa2f8adb0a9dc06a058e3effe7fee667")
+    version("0.10.0", sha256="47e0798caaac4df499bce5fe554a914abd884a855a27085a4473de1d737d9548")
+    version("0.9.0", sha256="efb28fed4ffcfaee653e0657f6500fc4cbac61e32104f4208da385676e76312a")
+    version("0.8.1", sha256="dfd0761e0b7e36c1d74c928ad986500c905be5ebcfbc29914d574af1db7218cf")
+    version("0.8.0", sha256="aa840321d056abd3c6be10c4a1e98a64f9f73fff9aa89c468dae8c003974a078")
+    version("0.7.0", sha256="a084a9c5d843e2343bf3f319154a48abe3d35d52feb0ad45dec427a1c4ffc416")
+    version("0.6.1", sha256="dada1f60a512789747011184b2767d2b44136ef3b036d86947f1896d200d2ba7")
+    version("0.6.0", sha256="a0e53728a9541ef87934831f3d05f2ccfdc3b8aeffe3e037be2b92b12400598e")
+    version("0.5.4", sha256="2157b05309614d6af0e4bbc6065987aede590822634a0522161f3af5d647abc9")
+    version("0.5.3", sha256="76b5c5880a0b15f5b91f7d626c5bc3b76ce7e5d21456963c117ab711bf1c5333")
+    version("0.5.2", sha256="2418c619bdd44257a170b85b9d2ecb75def29e751b725e27186468ada2e009ea")
+    version("0.5.1", sha256="85e6a18b111afeea2e475fe991db2a441ec3824211d659bee7b0012c36be9a40")
+    version("0.5.0", sha256="ebba7330a8715e96a6d6dc0aa085125d529d0740d788f0544c6169d892e4f861")
+    version("0.4.5", sha256="2b737be42678900470ae9e48c975ac5b2296d9ae23c007bf118350dbe7c0552b")
+    version("0.4.4", sha256="d52a21dda271ae645711ce99c70cf44c5d3a809138e656bbff00998827548ebb")
+    version("0.4.3", sha256="cbd2ab580181c17317cf18b2bf825bcded2d97cab01cd5b5fe4f4d520b64f90f")
+    version("0.4.2", sha256="8e6f41252abadcdb2cc7a07f910ec4b45fb12c46f0a578672c6a186c7efcdb36")
+    version("0.4.1", sha256="008c648d3c46ece063ae8b5008480d8ae6d359d35967356685d1c09da07e1064")
+    version("0.4.0", sha256="6474714eee72ba2d4e271ed00ce8c05d67a9d15327bc03962b821b2af2c5ca36")
+    version("0.3.2", sha256="ca5caf7b2b48c7639f45d815b32e76d69650f3199eb8caa541d402722e3f6c10")
+    version("0.3.1", sha256="218d0e28b4d1ee34585f2ac6b18d169c81404d93958815e73e60cc0368efcbb7")
+    version("0.3.0", sha256="357fd8bdf86034b93902616f0844bd52e9304cccca22971ab7007588bf9d5fb3")
+    version("0.2.0", sha256="e9ba2740d9727ae6d0f9b1ac0c5df331814fd03518fe4b511396ed10780d5272")
+    version("0.1.4", sha256="f3c395f5cd78cfef96f4008fe842f327bc8b03b77f46999387bc0ad223b5d970")
+    version("0.1.1", sha256="c6ae19610b936a0aa940b44a3626d6e660fc457a8187d295cdf0b21169453d20")
+
+    variant(
+        "nodepfail",
+        default=True,
+        description="Disable failing dependency checks due to injected absolute paths - "
+        "required for most builds using bazel with spack",
+    )
+
+    depends_on("java", type=("build", "run"))
+    depends_on("java@11", when="@5.3:", type=("build", "run"))
+    depends_on("java@8,11", when="@3.3:5.2", type=("build", "run"))
+    depends_on("java@8", when="@0.6:3.2", type=("build", "run"))
+    depends_on("java@7:8", when="@:0.5", type=("build", "run"))
+    depends_on("python+pythoncmd", type=("build", "run"))
+    depends_on("zip", when="platform=linux", type=("build", "run"))
+
+    # Pass Spack environment variables to the build
+    patch("bazelruleclassprovider-0.25.patch", when="@0.25:")
+    patch("bazelruleclassprovider-0.14.patch", when="@0.14:0.24")
+    patch("bazelconfiguration-0.3.patch", when="@:0.13")
+
+    # Inject include paths
+    patch("unix_cc_configure-3.0.patch", when="@3:")
+    patch("unix_cc_configure-0.15.patch", when="@0.15:2")
+    patch("unix_cc_configure-0.10.patch", when="@0.10:0.14")
+    patch("unix_cc_configure-0.5.3.patch", when="@0.5.3:0.9")
+    patch("cc_configure-0.5.0.patch", when="@0.5.0:0.5.2")
+    patch("cc_configure-0.3.0.patch", when="@0.3:0.4")
+
+    # Set CC and CXX
+    patch("compile-0.29.patch", when="@0.29:")
+    patch("compile-0.21.patch", when="@0.21:0.28")
+    patch("compile-0.16.patch", when="@0.16:0.20")
+    patch("compile-0.13.patch", when="@0.13:0.15")
+    patch("compile-0.9.patch", when="@0.9:0.12")
+    patch("compile-0.6.patch", when="@0.6:0.8")
+    patch("compile-0.4.patch", when="@0.4:0.5")
+    patch("compile-0.3.patch", when="@0.2:0.3")
+
+    # Disable dependency search
+    patch("cppcompileaction-0.3.2.patch", when="@0.3.2:+nodepfail")
+    patch("cppcompileaction-0.3.0.patch", when="@0.3.0:0.3.1+nodepfail")
+
+    # Fix build on power9 (2x commits)
+    # https://github.com/bazelbuild/bazel/commit/5cff4f1edf8b95bf0612791632255852332f72b5
+    # https://github.com/bazelbuild/bazel/commit/ab62a6e097590dac5ec946ad7a796ea0e8593ae0
+    patch("build-0.29.1.patch", when="@0.29.1")
+
+    # Fix build with Fujitsu compiler
+    patch("blaze_util_posix-0.29.1.patch", when="@0.29.1:%fj")
+    patch("unix_cc_configure_fj-5.2.patch", when="@5.2:%fj")
+    patch("unix_cc_configure_fj-5.0.patch", when="@5.0:5.1%fj")
+    patch("unix_cc_configure_fj-0.29.1.patch", when="@0.29.1:4%fj")
+    patch("bazelruleclassprovider_fj-0.25.patch", when="@0.25:%fj")
+    conflicts(
+        "%fj",
+        when="@:0.24.1",
+        msg="Fujitsu Compiler cannot build 0.24.1 or less, " "please use a newer release.",
+    )
+
+    # https://blog.bazel.build/2021/05/21/bazel-4-1.html
+    conflicts("platform=darwin target=aarch64:", when="@:4.0")
+
+    # patches for compiling bazel-4.1:4 with gcc-11
+    # these are derived from
+    # https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/29084/
+    patch("gcc11_1.patch", when="@0.3.2:4%gcc@11:")
+    patch("gcc11_2.patch", when="@0.3.2:4%gcc@11:")
+    patch("gcc11_3.patch", when="@0.3:4%gcc@11:")
+    patch("gcc11_4.patch", when="@4.1:4%gcc@11:")
+
+    # bazel-4.0.0 does not compile with gcc-11
+    # newer versions of grpc and abseil dependencies are needed but are not in
+    # bazel-4.0.0
+    conflicts("@:0.2,4.0.0", when="%gcc@11:")
+
+    executables = ["^bazel$"]
+
+    @classmethod
+    def determine_version(cls, exe):
+        output = Executable(exe)("version", output=str, error=str)
+        match = re.search(r"Build label: ([\d.]+)", output)
+        return match.group(1) if match else None
+
+    def url_for_version(self, version):
+        if version >= Version("0.4.1"):
+            url = "https://github.com/bazelbuild/bazel/releases/download/{0}/bazel-{0}-dist.zip"
+        else:
+            url = "https://github.com/bazelbuild/bazel/archive/{0}.tar.gz"
+
+        return url.format(version)
+
+    def setup_build_environment(self, env):
+        # fix the broken linking (on power9)
+        # https://github.com/bazelbuild/bazel/issues/10327
+        env.set("BAZEL_LINKOPTS", "")
+        env.set("BAZEL_LINKLIBS", "-lstdc++")
+
+        env.set(
+            "EXTRA_BAZEL_ARGS",
+            # Spack's logs don't handle colored output well
+            "--color=no --host_javabase=@local_jdk//:jdk"
+            # Enable verbose output for failures
+            " --verbose_failures"
+            # Ask bazel to explain what it's up to
+            # Needs a filename as argument
+            " --explain=explainlogfile.txt"
+            # Increase verbosity of explanation,
+            " --verbose_explanations"
+            # Show (formatted) subcommands being executed
+            " --subcommands=pretty_print" " --jobs={0}".format(make_jobs),
+        )
+
+    @run_before("install")
+    def bootstrap(self):
+        bash = which("bash")
+        bash("./compile.sh")
+
+    def install(self, spec, prefix):
+        mkdir(prefix.bin)
+        install("output/bazel", prefix.bin)
+
+    @run_after("install")
+    @on_package_attributes(run_tests=True)
+    def install_test(self):
+        # https://github.com/Homebrew/homebrew-core/blob/master/Formula/bazel.rb
+
+        # Bazel does not work properly on NFS, switch to /tmp
+        with working_dir("/tmp/spack/bazel/spack-test", create=True):
+            touch("WORKSPACE")
+
+            with open("ProjectRunner.java", "w") as f:
+                f.write(
+                    """\
+public class ProjectRunner {
+    public static void main(String args[]) {
+        System.out.println("Hi!");
+    }
+}"""
+                )
+
+            with open("BUILD", "w") as f:
+                f.write(
+                    """\
+java_binary(
+    name = "bazel-test",
+    srcs = glob(["*.java"]),
+    main_class = "ProjectRunner",
+)"""
+                )
+
+            # Spack's logs don't handle colored output well
+            bazel = Executable(self.prefix.bin.bazel)
+            bazel(
+                "--output_user_root=/tmp/spack/bazel/spack-test",
+                "build",
+                "--color=no",
+                "//:bazel-test",
+            )
+
+            exe = Executable("bazel-bin/bazel-test")
+            assert exe(output=str) == "Hi!\n"
+
+    def setup_dependent_package(self, module, dependent_spec):
+        module.bazel = Executable("bazel")
+
+    @property
+    def parallel(self):
+        return not self.spec.satisfies("%fj")
diff --git a/packages/bazel/patch_for_fcc.patch b/packages/bazel/patch_for_fcc.patch
new file mode 100644
index 0000000000000000000000000000000000000000..d90448b0bae90cd963ea533f6e3b05a6f02b98cd
--- /dev/null
+++ b/packages/bazel/patch_for_fcc.patch
@@ -0,0 +1,37 @@
+diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
+index 87ba899180..1c967ee818 100644
+--- a/src/main/cpp/blaze_util_posix.cc
++++ b/src/main/cpp/blaze_util_posix.cc
+@@ -565,7 +565,8 @@ static int setlk(int fd, struct flock *lock) {
+   // Prefer OFD locks if available.  POSIX locks can be lost "accidentally"
+   // due to any close() on the lock file, and are not reliably preserved
+   // across execve() on Linux, which we need for --batch mode.
+-  if (fcntl(fd, F_OFD_SETLK, lock) == 0) return 0;
++  //if (fcntl(fd, F_OFD_SETLK, lock) == 0) return 0;
++  if (fcntl(fd, F_SETLK, lock) == 0) return 0;
+   if (errno != EINVAL) {
+     if (errno != EACCES && errno != EAGAIN) {
+       BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
+diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
+index ccb18a431a..0c5c8fd6f0 100644
+--- a/tools/cpp/unix_cc_configure.bzl
++++ b/tools/cpp/unix_cc_configure.bzl
+@@ -379,7 +379,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
+         "",
+         False,
+     ), ":")
+-    gold_linker_path = _find_gold_linker_path(repository_ctx, cc)
++    #gold_linker_path = _find_gold_linker_path(repository_ctx, cc)
++    gold_linker_path = None
+     cc_path = repository_ctx.path(cc)
+     if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"):
+         # cc is outside the repository, set -B
+@@ -468,7 +469,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
+                     # Security hardening requires optimization.
+                     # We need to undef it as some distributions now have it enabled by default.
+                     "-U_FORTIFY_SOURCE",
+-                    "-fstack-protector",
++                    #"-fstack-protector",
+                     # All warnings are enabled. Maybe enable -Werror as well?
+                     "-Wall",
+                     # Enable a few more warnings that aren't part of -Wall.
diff --git a/packages/bazel/patch_for_fcc2.patch b/packages/bazel/patch_for_fcc2.patch
new file mode 100644
index 0000000000000000000000000000000000000000..709e5ee0202c07e6bc5b6202d654dbe2b97168a7
--- /dev/null
+++ b/packages/bazel/patch_for_fcc2.patch
@@ -0,0 +1,11 @@
+--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+@@ -185,7 +185,7 @@ public class BazelRuleClassProvider {
+ 
+         Map<String, String> spackEnv = System.getenv();
+         for (String envName : spackEnv.keySet()) {
+-          if (envName.startsWith("SPACK_")) {
++          if ((envName.startsWith("SPACK_")) || (envName.equals("fcc_ENV")) || (envName.equals("FCC_ENV"))) {
+             env.put(envName, spackEnv.get(envName));
+           }
+         }
diff --git a/packages/bazel/rename-gettid-functions-0.25.patch b/packages/bazel/rename-gettid-functions-0.25.patch
new file mode 100644
index 0000000000000000000000000000000000000000..fe06a6fc1825c9d70c5e84c8572d6b59c1511db6
--- /dev/null
+++ b/packages/bazel/rename-gettid-functions-0.25.patch
@@ -0,0 +1,78 @@
+From d1d017390b799c59d6fdf7b8afa6136d218bdd61 Mon Sep 17 00:00:00 2001
+From: Benjamin Peterson <benjamin@dropbox.com>
+Date: Fri, 3 May 2019 08:11:00 -0700
+Subject: [PATCH] Rename gettid() functions.
+
+glibc 2.30 will declare its own gettid; see https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92. Rename the grpc versions to avoid naming conflicts.
+---
+ src/core/lib/gpr/log_linux.cc          | 4 ++--
+ src/core/lib/gpr/log_posix.cc          | 4 ++--
+ src/core/lib/iomgr/ev_epollex_linux.cc | 4 ++--
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git third_party/grpc/src/core/lib/gpr/log_linux.cc.orig src/core/lib/gpr/log_linux.cc
+index 561276f0c20..8b597b4cf2f 100644
+--- third_party/grpc/src/core/lib/gpr/log_linux.cc.orig	2019-06-21 10:42:13.235611417 -0400
++++ third_party/grpc/src/core/lib/gpr/log_linux.cc	2019-06-21 10:42:16.686608855 -0400
+@@ -40,7 +40,7 @@
+ #include <time.h>
+ #include <unistd.h>
+ 
+-static long gettid(void) { return syscall(__NR_gettid); }
++static long sys_gettid(void) { return syscall(__NR_gettid); }
+ 
+ void gpr_log(const char* file, int line, gpr_log_severity severity,
+              const char* format, ...) {
+@@ -70,7 +70,7 @@ void gpr_default_log(gpr_log_func_args*
+   gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
+   struct tm tm;
+   static __thread long tid = 0;
+-  if (tid == 0) tid = gettid();
++  if (tid == 0) tid = sys_gettid();
+ 
+   timer = static_cast<time_t>(now.tv_sec);
+   final_slash = strrchr(args->file, '/');
+diff --git third_party/grpc/src/core/lib/gpr/log_posix.cc.orig src/core/lib/gpr/log_posix.cc
+index b6edc14ab6b..2f7c6ce3760 100644
+--- third_party/grpc/src/core/lib/gpr/log_posix.cc.orig	2019-06-21 10:42:13.242611412 -0400
++++ third_party/grpc/src/core/lib/gpr/log_posix.cc	2019-06-21 10:42:22.794604319 -0400
+@@ -30,7 +30,7 @@
+ #include <string.h>
+ #include <time.h>
+ 
+-static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
++static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); }
+ 
+ void gpr_log(const char* file, int line, gpr_log_severity severity,
+              const char* format, ...) {
+@@ -85,7 +85,7 @@ void gpr_default_log(gpr_log_func_args*
+   char* prefix;
+   gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]",
+                gpr_log_severity_string(args->severity), time_buffer,
+-               (int)(now.tv_nsec), gettid(), display_file, args->line);
++               (int)(now.tv_nsec), sys_gettid(), display_file, args->line);
+ 
+   fprintf(stderr, "%-70s %s\n", prefix, args->message);
+   gpr_free(prefix);
+diff --git third_party/grpc/src/core/lib/iomgr/ev_epollex_linux.cc.orig src/core/lib/iomgr/ev_epollex_linux.cc
+index 08116b3ab53..76f59844312 100644
+--- third_party/grpc/src/core/lib/iomgr/ev_epollex_linux.cc.orig	2019-06-21 10:42:13.247611408 -0400
++++ third_party/grpc/src/core/lib/iomgr/ev_epollex_linux.cc	2019-06-21 10:42:29.767599141 -0400
+@@ -1150,7 +1150,7 @@ static void end_worker(grpc_pollset* pol
+ }
+ 
+ #ifndef NDEBUG
+-static long gettid(void) { return syscall(__NR_gettid); }
++static long sys_gettid(void) { return syscall(__NR_gettid); }
+ #endif
+ 
+ /* pollset->mu lock must be held by the caller before calling this.
+@@ -1170,7 +1170,7 @@ static grpc_error* pollset_work(grpc_pol
+ #define WORKER_PTR (&worker)
+ #endif
+ #ifndef NDEBUG
+-  WORKER_PTR->originator = gettid();
++  WORKER_PTR->originator = sys_gettid();
+ #endif
+   if (grpc_polling_trace.enabled()) {
+     gpr_log(GPR_INFO,
diff --git a/packages/bazel/unix_cc_configure-0.10.patch b/packages/bazel/unix_cc_configure-0.10.patch
new file mode 100644
index 0000000000000000000000000000000000000000..bdd24e1152b5ac76c027690b720068550c9ef8e6
--- /dev/null
+++ b/packages/bazel/unix_cc_configure-0.10.patch
@@ -0,0 +1,22 @@
+--- a/tools/cpp/unix_cc_configure.bzl
++++ b/tools/cpp/unix_cc_configure.bzl
+@@ -147,9 +147,18 @@ def get_escaped_cxx_inc_directories(repository_ctx, cc, additional_flags = []):
+   else:
+     inc_dirs = result.stderr[index1 + 1:index2].strip()
+ 
+-  return [_prepare_include_path(repository_ctx, _cxx_inc_convert(p))
+-          for p in inc_dirs.split("\n")]
++  default_inc_directories = [
++    _prepare_include_path(repository_ctx, _cxx_inc_convert(p))
++      for p in inc_dirs.split("\n")
++  ]
++ 
++  env = repository_ctx.os.environ
++  if "SPACK_INCLUDE_DIRS" in env:
++    for path in env["SPACK_INCLUDE_DIRS"].split(":"):
++      default_inc_directories.append(path)
++
++  return default_inc_directories
+ 
+
+ def _is_option_supported(repository_ctx, cc, option):
diff --git a/packages/bazel/unix_cc_configure-0.15.patch b/packages/bazel/unix_cc_configure-0.15.patch
new file mode 100644
index 0000000000000000000000000000000000000000..74fd8bfb79b868dc2f8a9d0ac83fdd878b432495
--- /dev/null
+++ b/packages/bazel/unix_cc_configure-0.15.patch
@@ -0,0 +1,22 @@
+--- a/tools/cpp/unix_cc_configure.bzl
++++ b/tools/cpp/unix_cc_configure.bzl
+@@ -145,11 +145,18 @@ def get_escaped_cxx_inc_directories(repository_ctx, cc, lang_flag, additional_fl
+     else:
+         inc_dirs = result.stderr[index1 + 1:index2].strip()
+ 
+-    return [
++    default_inc_directories = [
+         _prepare_include_path(repository_ctx, _cxx_inc_convert(p))
+         for p in inc_dirs.split("\n")
+     ]
+ 
++    env = repository_ctx.os.environ
++    if "SPACK_INCLUDE_DIRS" in env:
++        for path in env["SPACK_INCLUDE_DIRS"].split(":"):
++            default_inc_directories.append(path)
++
++    return default_inc_directories
++
+ def _is_compiler_option_supported(repository_ctx, cc, option):
+     """Checks that `option` is supported by the C compiler. Doesn't %-escape the option."""
+     result = repository_ctx.execute([
diff --git a/packages/bazel/unix_cc_configure-0.5.3.patch b/packages/bazel/unix_cc_configure-0.5.3.patch
new file mode 100644
index 0000000000000000000000000000000000000000..79b583ba84606d75fa35797229e08f723f538dc6
--- /dev/null
+++ b/packages/bazel/unix_cc_configure-0.5.3.patch
@@ -0,0 +1,24 @@
+--- a/tools/cpp/unix_cc_configure.bzl
++++ b/tools/cpp/unix_cc_configure.bzl
+@@ -117,9 +117,19 @@ def get_escaped_cxx_inc_directories(repository_ctx, cc):
+   else:
+     inc_dirs = result.stderr[index1 + 1:index2].strip()
+ 
+-  return [escape_string(repository_ctx.path(_cxx_inc_convert(p)))
+-          for p in inc_dirs.split("\n")]
++  default_inc_directories = [
++    escape_string(repository_ctx.path(_cxx_inc_convert(p)))
++          for p in inc_dirs.split("\n")
++  ]
+ 
++  env = repository_ctx.os.environ
++  if "SPACK_INCLUDE_DIRS" in env:
++    for path in env["SPACK_INCLUDE_DIRS"].split(":"):
++      default_inc_directories.append(
++        repository_ctx.path(_cxx_inc_convert(path))
++      )
++
++  return default_inc_directories
+ 
+ def _add_option_if_supported(repository_ctx, cc, option):
+   """Checks that `option` is supported by the C compiler. Doesn't %-escape the option."""
diff --git a/packages/bazel/unix_cc_configure-3.0.patch b/packages/bazel/unix_cc_configure-3.0.patch
new file mode 100644
index 0000000000000000000000000000000000000000..1140b0c306c5ef89519d5b82767e18c34a5119f7
--- /dev/null
+++ b/packages/bazel/unix_cc_configure-3.0.patch
@@ -0,0 +1,19 @@
+diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
+index 5feb10b76a..cde0b8f8f1 100644
+--- a/tools/cpp/unix_cc_configure.bzl
++++ b/tools/cpp/unix_cc_configure.bzl
+@@ -151,8 +151,14 @@ def get_escaped_cxx_inc_directories(repository_ctx, cc, lang_flag, additional_fl
+         ).stdout.strip() + "/share"
+         inc_directories.append(_prepare_include_path(repository_ctx, resource_dir))
+ 
++    env = repository_ctx.os.environ
++    if "SPACK_INCLUDE_DIRS" in env:
++        for path in env["SPACK_INCLUDE_DIRS"].split(":"):
++            inc_directories.append(path)
++
+     return inc_directories
+ 
++
+ def _is_compiler_option_supported(repository_ctx, cc, option):
+     """Checks that `option` is supported by the C compiler. Doesn't %-escape the option."""
+     result = repository_ctx.execute([
diff --git a/packages/bazel/unix_cc_configure_fj-0.29.1.patch b/packages/bazel/unix_cc_configure_fj-0.29.1.patch
new file mode 100644
index 0000000000000000000000000000000000000000..376aeee2f20e04562d1f13a2c86e9af7d05f034b
--- /dev/null
+++ b/packages/bazel/unix_cc_configure_fj-0.29.1.patch
@@ -0,0 +1,20 @@
+diff -Naur a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
+--- a/tools/cpp/unix_cc_configure.bzl	1980-01-01 00:00:00.000000000 -0800
++++ b/tools/cpp/unix_cc_configure.bzl	2022-06-30 23:53:17.000000000 -0700
+@@ -379,7 +379,7 @@
+         "",
+         False,
+     ), ":")
+-    gold_linker_path = _find_gold_linker_path(repository_ctx, cc)
++    gold_linker_path = None
+     cc_path = repository_ctx.path(cc)
+     if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"):
+         # cc is outside the repository, set -B
+@@ -468,7 +468,6 @@
+                     # Security hardening requires optimization.
+                     # We need to undef it as some distributions now have it enabled by default.
+                     "-U_FORTIFY_SOURCE",
+-                    "-fstack-protector",
+                     # All warnings are enabled. Maybe enable -Werror as well?
+                     "-Wall",
+                     # Enable a few more warnings that aren't part of -Wall.
diff --git a/packages/bazel/unix_cc_configure_fj-5.0.patch b/packages/bazel/unix_cc_configure_fj-5.0.patch
new file mode 100644
index 0000000000000000000000000000000000000000..5f1304b7247904f64b41968b198bc62af63bdea7
--- /dev/null
+++ b/packages/bazel/unix_cc_configure_fj-5.0.patch
@@ -0,0 +1,23 @@
+diff -Naur a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
+--- a/tools/cpp/unix_cc_configure.bzl	1980-01-01 00:00:00.000000000 -0800
++++ b/tools/cpp/unix_cc_configure.bzl	2022-06-30 23:35:14.000000000 -0700
+@@ -417,10 +417,7 @@
+         bazel_linklibs,
+         False,
+     ), ":")
+-    gold_or_lld_linker_path = (
+-        _find_linker_path(repository_ctx, cc, "lld", is_clang) or
+-        _find_linker_path(repository_ctx, cc, "gold", is_clang)
+-    )
++    gold_or_lld_linker_path = None
+     cc_path = repository_ctx.path(cc)
+     if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"):
+         # cc is outside the repository, set -B
+@@ -531,7 +528,6 @@
+                     # Security hardening requires optimization.
+                     # We need to undef it as some distributions now have it enabled by default.
+                     "-U_FORTIFY_SOURCE",
+-                    "-fstack-protector",
+                     # All warnings are enabled. Maybe enable -Werror as well?
+                     "-Wall",
+                     # Enable a few more warnings that aren't part of -Wall.
diff --git a/packages/bazel/unix_cc_configure_fj-5.2.patch b/packages/bazel/unix_cc_configure_fj-5.2.patch
new file mode 100644
index 0000000000000000000000000000000000000000..f7ad3e30815341d95f305e2dfa2a8b4fdbd9dbde
--- /dev/null
+++ b/packages/bazel/unix_cc_configure_fj-5.2.patch
@@ -0,0 +1,23 @@
+diff -Naur a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
+--- a/tools/cpp/unix_cc_configure.bzl	1980-01-01 00:00:00.000000000 -0800
++++ b/tools/cpp/unix_cc_configure.bzl	2022-06-30 23:58:26.945067883 -0700
+@@ -419,10 +419,7 @@
+         bazel_linklibs,
+         False,
+     ), ":")
+-    gold_or_lld_linker_path = (
+-        _find_linker_path(repository_ctx, cc, "lld", is_clang) or
+-        _find_linker_path(repository_ctx, cc, "gold", is_clang)
+-    )
++    gold_or_lld_linker_path = None
+     cc_path = repository_ctx.path(cc)
+     if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"):
+         # cc is outside the repository, set -B
+@@ -530,7 +527,6 @@
+             "%{cxx_builtin_include_directories}": get_starlark_list(builtin_include_directories),
+             "%{compile_flags}": get_starlark_list(
+                 [
+-                    "-fstack-protector",
+                     # All warnings are enabled. Maybe enable -Werror as well?
+                     "-Wall",
+                     # Enable a few more warnings that aren't part of -Wall.
diff --git a/packages/hxtorch/package.py b/packages/hxtorch/package.py
index 6b36a3685216db881fcea689cf567f2159e8539d..30a5566d1fe485d9b2b1ab6ffcb1b9d05a2a51a8 100644
--- a/packages/hxtorch/package.py
+++ b/packages/hxtorch/package.py
@@ -37,6 +37,7 @@ class Hxtorch(WafPackage):
     depends_on('pkgconfig', type=('build', 'link', 'run'))
     depends_on('python@3.7.0:', type=('build', 'link', 'run')) # BrainScaleS(-2, type=('build', 'link', 'run')) only supports Python >= 3.7
     depends_on('py-h5py', type=('build', 'link', 'run')) # PyNN tests need it
+    depends_on('py-jax@0.3.25:', type=('build', 'link', 'run'))
     depends_on('py-matplotlib', type=('build', 'link', 'run'))
     depends_on('py-nose', type=('build', 'link', 'run'))
     depends_on('py-numpy', type=('build', 'link', 'run'))
@@ -47,6 +48,7 @@ class Hxtorch(WafPackage):
     depends_on('py-pylint', type=('build', 'link', 'run'))
     depends_on('py-torch@1.9.1:', type=('build', 'link', 'run'))
     depends_on('py-torchvision', type=('run')) # for demos
+    depends_on('py-tree-math', type=('build', 'link', 'run'))
     depends_on('py-pyyaml', type=('build', 'link', 'run'))
     depends_on('py-scipy', type=('build', 'link', 'run'))
     depends_on('py-sqlalchemy', type=('build', 'link', 'run'))
diff --git a/packages/py-jax/package.py b/packages/py-jax/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..95833f4c8e9488987d5ad810faf2df8d204473f5
--- /dev/null
+++ b/packages/py-jax/package.py
@@ -0,0 +1,50 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+
+from spack.package import *
+
+
+class PyJax(PythonPackage, CudaPackage):
+    """JAX is Autograd and XLA, brought together for high-performance
+    machine learning research. With its updated version of Autograd,
+    JAX can automatically differentiate native Python and NumPy
+    functions. It can differentiate through loops, branches,
+    recursion, and closures, and it can take derivatives of
+    derivatives of derivatives. It supports reverse-mode
+    differentiation (a.k.a. backpropagation) via grad as well as
+    forward-mode differentiation, and the two can be composed
+    arbitrarily to any order."""
+
+    homepage = "https://github.com/google/jax"
+    pypi = "jax/jax-0.2.25.tar.gz"
+
+    version("0.3.25", sha256="18bea69321cb95ea5ea913adfe5e2c1d453cade9d4cfd0dc814ecba9fc0cb6e3")
+    version("0.2.25", sha256="822e8d1e06257eaa0fdc4c0a0686c4556e9f33647fa2a766755f984786ae7446")
+
+    variant("cuda", default=True, description="CUDA support")
+
+    depends_on("python@3.7:", type=("build", "run"))
+    depends_on("py-setuptools", type="build")
+    depends_on("py-numpy@1.18:", type=("build", "run"))
+    depends_on("py-absl-py", type=("build", "run"))
+    depends_on("py-opt-einsum", type=("build", "run"))
+    depends_on("py-scipy@1.2.1:", type=("build", "run"))
+    depends_on("py-typing-extensions", type=("build", "run"))
+    depends_on("py-jaxlib@0.1.69:", type=("build", "run"), when="~cuda")
+    depends_on("py-jaxlib@0.1.69:+cuda", type=("build", "run"), when="+cuda")
+    depends_on("py-jaxlib@0.3.22:", type=("build", "run"), when="@0.3.25:~cuda")
+    depends_on("py-jaxlib@0.3.22:+cuda", type=("build", "run"), when="@0.3.25:+cuda")
+    for arch in CudaPackage.cuda_arch_values:
+        depends_on(
+            "py-jaxlib@0.1.69:+cuda cuda_arch={0}".format(arch),
+            type=("build", "run"),
+            when="cuda_arch={0}".format(arch),
+        )
+        depends_on(
+            "py-jaxlib@0.3.22:+cuda cuda_arch={0}".format(arch),
+            type=("build", "run"),
+            when="@0.3.25:cuda_arch={0}".format(arch),
+        )
diff --git a/packages/py-jaxlib/package.py b/packages/py-jaxlib/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..ed403158bc5ef0351b234f70c987dbf823b5ed25
--- /dev/null
+++ b/packages/py-jaxlib/package.py
@@ -0,0 +1,77 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+import tempfile
+
+import llnl.util.tty as tty
+
+from spack.package import *
+
+
+class PyJaxlib(PythonPackage, CudaPackage):
+    """XLA library for Jax"""
+
+    homepage = "https://github.com/google/jax"
+    url = "https://github.com/google/jax/archive/refs/tags/jaxlib-v0.1.74.tar.gz"
+
+    tmp_path = ""
+
+    version("0.3.25", sha256="73ebc7868631cd9d520385557bbd7f08762d748a5a6a1bebef0f3b8d7ba748ef")
+    version("0.1.74", sha256="bbc78c7a4927012dcb1b7cd135c7521f782d7dad516a2401b56d3190f81afe35")
+
+    depends_on("python@3.7:", type=("build", "run"))
+    depends_on("py-setuptools", type="build")
+    depends_on("py-numpy@1.18:", type=("build", "run"))
+    depends_on("py-numpy@1.20:", type=("build", "run"), when="@0.3.16:")
+    depends_on("py-opt-einsum", type=("build", "run"), when="@0.2.8:")
+    depends_on("py-scipy", type=("build", "run"))
+    depends_on("py-scipy@1.5:", type=("build", "run"), when="@0.3.14:")
+    depends_on("py-typing-extensions", type=("build", "run"), when="@0.2.23:")
+    depends_on("py-absl-py", type=("build", "run"))
+    depends_on("py-flatbuffers@1.12:2", type=("build", "run"))
+    # Bazel 5 not yet supported: https://github.com/google/jax/issues/8440
+    depends_on("bazel@4.1.0:4", type=("build"), when="@:0.3.5")
+    depends_on("bazel@5.1.1:", type=("build"), when="@0.3.6:")
+    depends_on("cudnn@8.0.5:", when="+cuda")
+    depends_on("cuda@11.1:", when="+cuda")
+
+    def install(self, spec, prefix):
+        args = []
+        args.append("build/build.py")
+        if "+cuda" in spec:
+            args.append("--enable_cuda")
+            args.append("--cuda_path={0}".format(self.spec["cuda"].prefix))
+            args.append("--cudnn_path={0}".format(self.spec["cudnn"].prefix))
+            capabilities = ",".join(
+                "{0:.1f}".format(float(i) / 10.0) for i in spec.variants["cuda_arch"].value
+            )
+            args.append("--cuda_compute_capabilities={0}".format(capabilities))
+        args.append("--bazel_startup_options=" "--output_user_root={0}".format(self.buildtmp))
+        python(*args)
+        with working_dir(self.tmp_path):
+            tty.warn("in dir " + self.tmp_path)
+            args = std_pip_args + ["--prefix=" + self.prefix, "."]
+            pip(*args)
+        remove_linked_tree(self.tmp_path)
+        remove_linked_tree(self.buildtmp)
+
+    def patch(self):
+        self.tmp_path = tempfile.mkdtemp(prefix="spack")
+        self.buildtmp = tempfile.mkdtemp(prefix="spack")
+        filter_file(
+            """f"--output_path={output_path}",""",
+            """f"--output_path={output_path}","""
+            """f"--sources_path=%s","""
+            """f"--nohome_rc'","""
+            """f"--nosystem_rc'",""" % self.tmp_path,
+            "build/build.py",
+        )
+        filter_file(
+            "args = parser.parse_args()",
+            "args,junk = parser.parse_known_args()",
+            "build/build_wheel.py",
+            string=True,
+        )
+
diff --git a/packages/py-tensorboard/package.py b/packages/py-tensorboard/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..cccf282409699dff834090537fd3b5e86716c690
--- /dev/null
+++ b/packages/py-tensorboard/package.py
@@ -0,0 +1,100 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class PyTensorboard(PythonPackage):
+    """TensorBoard is a suite of web applications for
+    inspecting and understanding your TensorFlow runs and
+    graphs."""
+
+    homepage = "https://github.com/tensorflow/tensorboard"
+    url = "https://files.pythonhosted.org/packages/py3/t/tensorboard/tensorboard-2.9.1-py3-none-any.whl"
+    list_url = "https://pypi.org/simple/tensorboard/"
+
+    maintainers = ["aweits"]
+
+    version(
+        "2.11.0",
+        sha256="a0e592ee87962e17af3f0dce7faae3fbbd239030159e9e625cce810b7e35c53d",
+        expand=False,
+    )
+    version(
+        "2.10.0",
+        sha256="76c91a5e8959cd2208cc32cb17a0cb002badabb66a06ac2af02a7810f49a59e3",
+        expand=False,
+    )
+    version(
+        "2.9.1",
+        sha256="baa727f791776f9e5841d347127720ceed4bbd59c36b40604b95fb2ae6029276",
+        expand=False,
+    )
+    version(
+        "2.9.0",
+        sha256="bd78211076dca5efa27260afacfaa96cd05c7db12a6c09cc76a1d6b2987ca621",
+        expand=False,
+    )
+    version(
+        "2.8.0",
+        sha256="65a338e4424e9079f2604923bdbe301792adce2ace1be68da6b3ddf005170def",
+        expand=False,
+    )
+    version(
+        "2.7.0",
+        sha256="239f78a4a8dff200ce585a030c787773a8c1184d5c159252f5f85bac4e3c3b38",
+        expand=False,
+    )
+    version(
+        "2.6.0",
+        sha256="f7dac4cdfb52d14c9e3f74585ce2aaf8e6203620a864e51faf84988b09f7bbdb",
+        expand=False,
+    )
+    version(
+        "2.5.0",
+        sha256="e167460085b6528956b33bab1c970c989cdce47a6616273880733f5e7bde452e",
+        expand=False,
+    )
+    version(
+        "2.4.1",
+        sha256="7b8c53c396069b618f6f276ec94fc45d17e3282d668979216e5d30be472115e4",
+        expand=False,
+    )
+    version(
+        "2.4.0",
+        sha256="cde0c663a85609441cb4d624e7255fd8e2b6b1d679645095aac8a234a2812738",
+        expand=False,
+    )
+    version(
+        "2.3.0",
+        sha256="d34609ed83ff01dd5b49ef81031cfc9c166bba0dabd60197024f14df5e8eae5e",
+        expand=False,
+    )
+    version(
+        "2.2.0",
+        sha256="bb6bbc75ad2d8511ba6cbd49e4417276979f49866e11841e83da8298727dbaed",
+        expand=False,
+    )
+
+    depends_on("python@2.7:2.8,3.2:", type=("build", "run"), when="@:2.5")
+    depends_on("python@3.6:", type=("build", "run"), when="@2.6:")
+    depends_on("py-absl-py@0.4:", type=("build", "run"))
+    depends_on("py-grpcio@1.24.3:", type=("build", "run"), when="@2.3:")
+    depends_on("py-grpcio@1.23.3:", type=("build", "run"), when="@2.2")
+    depends_on("py-google-auth@1.6.3:1", type=("build", "run"), when="@:2.6")
+    depends_on("py-google-auth@1.6.3:2", type=("build", "run"), when="@2.7:")
+    depends_on("py-google-auth-oauthlib@0.4.1:0.4", type=("build", "run"))
+    depends_on("py-markdown@2.6.8:", type=("build", "run"))
+    depends_on("py-numpy@1.12.0:", type=("build", "run"))
+    depends_on("py-protobuf@3.6.0:3.19", type=("build", "run"), when="@:2.8")
+    depends_on("py-protobuf@3.9.2:3.19", type=("build", "run"), when="@2.9:")
+    depends_on("py-requests@2.21.0:2", type=("build", "run"))
+    depends_on("py-setuptools@41.0.0:", type=("build", "run"))
+    depends_on("py-tensorboard-data-server@0.6", type=("build", "run"), when="@2.5:")
+    depends_on("py-tensorboard-plugin-wit@1.6.0:", type=("build", "run"))
+    depends_on("py-werkzeug@0.11.15:", type=("build", "run"))
+    depends_on("py-werkzeug@1.0.1:", type=("build", "run"), when="@2.9:")
+    depends_on("py-wheel@0.26:", type="build")
+    depends_on("py-six@1.10.0:", type=("build", "run"), when="@:2.4")
diff --git a/packages/py-tree-math/package.py b/packages/py-tree-math/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..59f93429735ec4270df4c3641b1cbdd410b2414a
--- /dev/null
+++ b/packages/py-tree-math/package.py
@@ -0,0 +1,26 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class PyTreeMath(PythonPackage):
+    """
+    tree-math makes it easy to implement numerical algorithms that work on
+    JAX pytrees, such as iterative methods for optimization and equation
+    solving. It does so by providing a wrapper class tree_math.Vector that
+    defines array operations such as infix arithmetic and dot-products on
+    pytrees as if they were vectors.
+    """
+
+    homepage = "https://github.com/google/tree-math"
+    pypi = "tree-math/tree-math-0.1.0.tar.gz"
+    git = "https://github.com/google/tree-math.git"
+
+    version('0.1.0.post', commit='0af9679125c13cc38dab5159bc8413ed79465344')
+    version('0.1.0', sha256='77eb8d6ba4d6cfdd2d986a6bc3fc2d1b16212f0172863a3ca509720babf75929')
+
+    depends_on('py-setuptools', type='build')
+    depends_on('py-jax', type=('build', 'run'))