treewide: bump rust to 1.82.0

This also patches rules_rust to support extra_rustc_flags inside bzlmod
extensions.

Change-Id: I5da146bee580128a7ecfa6d98fa3afe482deb112
Reviewed-on: https://review.monogon.dev/c/monogon/+/3599
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/MODULE.bazel b/MODULE.bazel
index e178fb0..cd39eed 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -46,6 +46,7 @@
         "//third_party/rules_rust:rust-uefi-platform.patch",
         "//third_party/rules_rust:rust-prost-nostd.patch",
         "//third_party/rules_rust:rust-reproducibility.patch",
+        "//third_party/rules_rust:Add-extra_rustc_flags-to-module-extension.patch",
     ],
     version = "0.53.0",
 )
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index e9a8d96..59b2463 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -11883,8 +11883,8 @@
     },
     "@@rules_rust~//rust:extensions.bzl%rust": {
       "general": {
-        "bzlTransitiveDigest": "qOfRbrmdB5RLbhAsABANfZ+PJk0/IojqvaouVVfC4V8=",
-        "usagesDigest": "JumEGPYiqAgG+zPurITf+dVnuq1fvn22VjUl2fKK1IA=",
+        "bzlTransitiveDigest": "MCIZIVafPwJx1oqD86yaqQ96fZHrnK4aqh6eJw8FKPI=",
+        "usagesDigest": "33pmeooYDAbqrHh9dAyocEIWrirAoxT9swN2BtwaizQ=",
         "recordedFileInputs": {},
         "recordedDirentsInputs": {},
         "envVariables": {},
@@ -11897,11 +11897,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "aarch64-unknown-linux-gnu",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -11971,6 +11973,30 @@
               "exec_triple": "aarch64-unknown-linux-gnu"
             }
           },
+          "rust_analyzer_1.82.0_tools": {
+            "bzlFile": "@@rules_rust~//rust:repositories.bzl",
+            "ruleClassName": "rust_analyzer_toolchain_tools_repository",
+            "attributes": {
+              "version": "1.82.0",
+              "sha256s": {},
+              "urls": [
+                "https://static.rust-lang.org/dist/{}.tar.xz"
+              ],
+              "auth": {},
+              "netrc": "",
+              "auth_patterns": []
+            }
+          },
+          "rust_analyzer_1.82.0": {
+            "bzlFile": "@@rules_rust~//rust:repositories.bzl",
+            "ruleClassName": "toolchain_repository_proxy",
+            "attributes": {
+              "toolchain": "@rust_analyzer_1.82.0_tools//:rust_analyzer_toolchain",
+              "toolchain_type": "@rules_rust//rust/rust_analyzer:toolchain_type",
+              "exec_compatible_with": [],
+              "target_compatible_with": []
+            }
+          },
           "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools": {
             "bzlFile": "@@rules_rust~//rust:repositories.bzl",
             "ruleClassName": "rust_toolchain_tools_repository",
@@ -11979,11 +12005,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-linux-gnu",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12003,11 +12031,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "aarch64-pc-windows-msvc",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12037,11 +12067,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-pc-windows-msvc",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12080,11 +12112,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12119,11 +12153,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-freebsd",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12162,11 +12198,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12202,16 +12240,6 @@
               "target_compatible_with": []
             }
           },
-          "rust_analyzer_1.71.0": {
-            "bzlFile": "@@rules_rust~//rust:repositories.bzl",
-            "ruleClassName": "toolchain_repository_proxy",
-            "attributes": {
-              "toolchain": "@rust_analyzer_1.71.0_tools//:rust_analyzer_toolchain",
-              "toolchain_type": "@rules_rust//rust/rust_analyzer:toolchain_type",
-              "exec_compatible_with": [],
-              "target_compatible_with": []
-            }
-          },
           "rust_linux_s390x": {
             "bzlFile": "@@rules_rust~//rust:repositories.bzl",
             "ruleClassName": "rust_toolchain_set_repository",
@@ -12245,11 +12273,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12308,11 +12338,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12370,11 +12402,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12394,11 +12428,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12557,11 +12593,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "aarch64-apple-darwin",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12595,11 +12633,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "s390x-unknown-linux-gnu",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12619,11 +12659,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12751,20 +12793,6 @@
               ]
             }
           },
-          "rust_analyzer_1.71.0_tools": {
-            "bzlFile": "@@rules_rust~//rust:repositories.bzl",
-            "ruleClassName": "rust_analyzer_toolchain_tools_repository",
-            "attributes": {
-              "version": "1.71.0",
-              "sha256s": {},
-              "urls": [
-                "https://static.rust-lang.org/dist/{}.tar.xz"
-              ],
-              "auth": {},
-              "netrc": "",
-              "auth_patterns": []
-            }
-          },
           "rust_windows_aarch64__aarch64-pc-windows-msvc__stable": {
             "bzlFile": "@@rules_rust~//rust:repositories.bzl",
             "ruleClassName": "toolchain_repository_proxy",
@@ -12811,11 +12839,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-unknown-uefi",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
@@ -12875,7 +12905,7 @@
             "ruleClassName": "toolchain_repository_hub",
             "attributes": {
               "toolchain_names": [
-                "rust_analyzer_1.71.0",
+                "rust_analyzer_1.82.0",
                 "rust_darwin_aarch64__aarch64-apple-darwin__stable",
                 "rust_darwin_aarch64__x86_64-unknown-uefi__stable",
                 "rustfmt_nightly-2024-09-05__aarch64-apple-darwin",
@@ -12902,7 +12932,7 @@
                 "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu"
               ],
               "toolchain_labels": {
-                "rust_analyzer_1.71.0": "@rust_analyzer_1.71.0_tools//:rust_analyzer_toolchain",
+                "rust_analyzer_1.82.0": "@rust_analyzer_1.82.0_tools//:rust_analyzer_toolchain",
                 "rust_darwin_aarch64__aarch64-apple-darwin__stable": "@rust_darwin_aarch64__aarch64-apple-darwin__stable_tools//:rust_toolchain",
                 "rust_darwin_aarch64__x86_64-unknown-uefi__stable": "@rust_darwin_aarch64__x86_64-unknown-uefi__stable_tools//:rust_toolchain",
                 "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": "@rustfmt_nightly-2024-09-05__aarch64-apple-darwin_tools//:rustfmt_toolchain",
@@ -12929,7 +12959,7 @@
                 "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": "@rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu_tools//:rustfmt_toolchain"
               },
               "toolchain_types": {
-                "rust_analyzer_1.71.0": "@rules_rust//rust/rust_analyzer:toolchain_type",
+                "rust_analyzer_1.82.0": "@rules_rust//rust/rust_analyzer:toolchain_type",
                 "rust_darwin_aarch64__aarch64-apple-darwin__stable": "@rules_rust//rust:toolchain",
                 "rust_darwin_aarch64__x86_64-unknown-uefi__stable": "@rules_rust//rust:toolchain",
                 "rustfmt_nightly-2024-09-05__aarch64-apple-darwin": "@rules_rust//rust/rustfmt:toolchain_type",
@@ -12956,7 +12986,7 @@
                 "rustfmt_nightly-2024-09-05__x86_64-unknown-linux-gnu": "@rules_rust//rust/rustfmt:toolchain_type"
               },
               "exec_compatible_with": {
-                "rust_analyzer_1.71.0": [],
+                "rust_analyzer_1.82.0": [],
                 "rust_darwin_aarch64__aarch64-apple-darwin__stable": [
                   "@platforms//cpu:aarch64",
                   "@platforms//os:osx"
@@ -13055,7 +13085,7 @@
                 ]
               },
               "target_compatible_with": {
-                "rust_analyzer_1.71.0": [],
+                "rust_analyzer_1.82.0": [],
                 "rust_darwin_aarch64__aarch64-apple-darwin__stable": [
                   "@platforms//cpu:aarch64",
                   "@platforms//os:osx"
@@ -13139,11 +13169,13 @@
               "allocator_library": "@rules_rust//ffi/cc/allocator_library",
               "global_allocator_library": "@rules_rust//ffi/cc/global_allocator_library",
               "target_triple": "x86_64-apple-darwin",
-              "version": "1.71.0",
+              "version": "1.82.0",
               "rustfmt_version": "nightly/2024-09-05",
               "edition": "2021",
               "dev_components": false,
-              "extra_rustc_flags": [],
+              "extra_rustc_flags": [
+                "-Clinker=rust-lld"
+              ],
               "extra_exec_rustc_flags": [],
               "opt_level": {},
               "sha256s": {},
diff --git a/build/bazel/rust.MODULE.bazel b/build/bazel/rust.MODULE.bazel
index 3d33e88..eeedb06 100644
--- a/build/bazel/rust.MODULE.bazel
+++ b/build/bazel/rust.MODULE.bazel
@@ -4,7 +4,8 @@
     extra_target_triples = [
         "x86_64-unknown-uefi",
     ],
-    versions = ["1.71.0"],
+    versions = ["1.82.0"],
+    extra_rustc_flags = ["-Clinker=rust-lld"],
 )
 use_repo(rust, "rust_toolchains")
 
diff --git a/third_party/rules_rust/Add-extra_rustc_flags-to-module-extension.patch b/third_party/rules_rust/Add-extra_rustc_flags-to-module-extension.patch
new file mode 100644
index 0000000..ef71ce4
--- /dev/null
+++ b/third_party/rules_rust/Add-extra_rustc_flags-to-module-extension.patch
@@ -0,0 +1,38 @@
+From 0504caf6aa7cf920285ba68509db5d73ff9d64a7 Mon Sep 17 00:00:00 2001
+From: Tim Windelschmidt <tim@monogon.tech>
+Date: Tue, 1 Oct 2024 16:44:53 +0200
+Subject: [PATCH] Add extra_rustc_flags to module extension
+
+---
+ rust/extensions.bzl | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/rust/extensions.bzl b/rust/extensions.bzl
+index 683d11db..250d3ad1 100644
+--- a/rust/extensions.bzl
++++ b/rust/extensions.bzl
+@@ -69,6 +69,8 @@ def _rust_impl(module_ctx):
+                 urls = toolchain.urls,
+                 versions = toolchain.versions,
+                 register_toolchains = False,
++                extra_rustc_flags = toolchain.extra_rustc_flags,
++                extra_exec_rustc_flags = toolchain.extra_exec_rustc_flags,
+             )
+
+ _COMMON_TAG_KWARGS = dict(
+@@ -97,6 +99,12 @@ _COMMON_TAG_KWARGS = dict(
+         doc = "A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).",
+         default = DEFAULT_STATIC_RUST_URL_TEMPLATES,
+     ),
++    extra_rustc_flags = attr.string_list(
++        default = [],
++    ),
++    extra_exec_rustc_flags = attr.string_list(
++        default = [],
++    ),
+ )
+ 
+ _RUST_TOOLCHAIN_TAG = tag_class(
+-- 
+2.44.1
+