Skip to content

Instantly share code, notes, and snippets.

@pamaury
Created December 17, 2024 11:10
Show Gist options
  • Save pamaury/8ec5a71235c03d1c87f4730e5692a6cb to your computer and use it in GitHub Desktop.
Save pamaury/8ec5a71235c03d1c87f4730e5692a6cb to your computer and use it in GitHub Desktop.
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index 2923d8acb2..2d0771949a 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -13694,7 +13694,7 @@
},
"@@toolchains_llvm~//toolchain/extensions:llvm.bzl%llvm": {
"general": {
- "bzlTransitiveDigest": "i2QyNjD/qcSQlxaKhQjSN1uw8mm+ZusH07AWV6RnyQU=",
+ "bzlTransitiveDigest": "M4HHCg9Yz0gvoVQnnqi5wlJY1oxlqaj4Khqr94ZjtXo=",
"usagesDigest": "VkFLWYT36e0E0cIEzYI8Sea6Ww4GK5ceD6oJqC8Xof8=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
diff --git a/third_party/rust/rust.MODULE.bazel b/third_party/rust/rust.MODULE.bazel
index c787accbb1..59a4dbd7d4 100644
--- a/third_party/rust/rust.MODULE.bazel
+++ b/third_party/rust/rust.MODULE.bazel
@@ -15,6 +15,13 @@ single_version_override(
],
version = "0.49.3",
)
+single_version_override(
+ module_name = "toolchains_llvm",
+ patches = [
+ "//third_party/rust/patches:toolchains_llvm.add_nixos.patch",
+ ],
+ version = "1.1.2",
+)
# Rust toolchain:
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
(python-venv) [12:09:45][pamaury@jamesBOND:/home/pamaury/project/opentitan]master$ git add third_party/rust/
patches/ rust.MODULE.bazel target/
(python-venv) [12:09:45][pamaury@jamesBOND:/home/pamaury/project/opentitan]master$ git add third_party/rust/patches/
rules_rust.bindgen_system_include.patch toolchains_llvm.add_nixos.patch
(python-venv) [12:09:45][pamaury@jamesBOND:/home/pamaury/project/opentitan]master$ git add third_party/rust/patches/toolchains_llvm.add_nixos.patch
(python-venv) [12:09:54][pamaury@jamesBOND:/home/pamaury/project/opentitan]master$ git diff --staged
diff --git a/third_party/rust/patches/toolchains_llvm.add_nixos.patch b/third_party/rust/patches/toolchains_llvm.add_nixos.patch
new file mode 100644
index 0000000000..d66b84f6b1
--- /dev/null
+++ b/third_party/rust/patches/toolchains_llvm.add_nixos.patch
@@ -0,0 +1,13 @@
+diff --git a/toolchain/internal/release_name.bzl b/toolchain/internal/release_name.bzl
+index e3d4a54..ce0d193 100755
+--- toolchain/internal/release_name.bzl
++++ toolchain/internal/release_name.bzl
+@@ -177,6 +177,8 @@ def _linux(llvm_version, distname, version, arch):
+ os_name = "linux-gnueabihf"
+ elif distname in ["rhel", "ol", "almalinux"]:
+ os_name = _rhel_osname(arch, version, major_llvm_version, llvm_version)
++ elif distname == "nixos":
++ os_name = _ubuntu_osname(arch, "20.04", major_llvm_version, llvm_version)
+
+ if not os_name:
+ fail("Unsupported linux distribution and version: %s, %s" % (distname, version))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment