workspace: update rules_rust and add UEFI platform
This updates rules_rust from 0.16 to 0.26 and adds a patch sent upstream
for UEFI support.
Explicit toolchain definitions are needed for UEFI, so three toolchains
for all currently-supported host OSs (Linux and macOS) are added.
Rust UEFI support libraries will be added in a followup CL.
Change-Id: I52175f69f6a5c424f1f232748ff96dd6fcbbe92a
Reviewed-on: https://review.monogon.dev/c/monogon/+/2104
Reviewed-by: Serge Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
diff --git a/third_party/rust-uefi-platform.patch b/third_party/rust-uefi-platform.patch
new file mode 100644
index 0000000..e70f7f3
--- /dev/null
+++ b/third_party/rust-uefi-platform.patch
@@ -0,0 +1,72 @@
+From 28b8651b0ccba1f41802a2aff12643b51436b32b Mon Sep 17 00:00:00 2001
+From: Lorenz Brun <lorenz@monogon.tech>
+Date: Tue, 29 Aug 2023 19:02:45 +0200
+Subject: [PATCH] Add support for UEFI targets and OS
+
+---
+ rust/platform/triple_mappings.bzl | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/rust/platform/triple_mappings.bzl b/rust/platform/triple_mappings.bzl
+index 61a71c73..ce594522 100644
+--- a/rust/platform/triple_mappings.bzl
++++ b/rust/platform/triple_mappings.bzl
+@@ -27,6 +27,7 @@ SUPPORTED_T2_PLATFORM_TRIPLES = [
+ "aarch64-fuchsia",
+ "aarch64-linux-android",
+ "aarch64-pc-windows-msvc",
++ "aarch64-unknown-uefi",
+ "arm-unknown-linux-gnueabi",
+ "armv7-linux-androideabi",
+ "armv7-unknown-linux-gnueabi",
+@@ -45,6 +46,7 @@ SUPPORTED_T2_PLATFORM_TRIPLES = [
+ "x86_64-linux-android",
+ "x86_64-unknown-freebsd",
+ "x86_64-unknown-none",
++ "x86_64-unknown-uefi",
+ ]
+
+ SUPPORTED_PLATFORM_TRIPLES = SUPPORTED_T1_PLATFORM_TRIPLES + SUPPORTED_T2_PLATFORM_TRIPLES
+@@ -97,6 +99,7 @@ _SYSTEM_TO_BUILTIN_SYS_SUFFIX = {
+ "none": "none",
+ "openbsd": "openbsd",
+ "solaris": None,
++ "uefi": "uefi",
+ "unknown": None,
+ "wasi": None,
+ "windows": "windows",
+@@ -113,6 +116,7 @@ _SYSTEM_TO_BINARY_EXT = {
+ "ios": "",
+ "linux": "",
+ "none": "",
++ "uefi": ".efi",
+ # This is currently a hack allowing us to have the proper
+ # generated extension for the wasm target, similarly to the
+ # windows target
+@@ -132,6 +136,7 @@ _SYSTEM_TO_STATICLIB_EXT = {
+ "ios": ".a",
+ "linux": ".a",
+ "none": ".a",
++ "uefi": ".lib",
+ "unknown": "",
+ "wasi": "",
+ "windows": ".lib",
+@@ -148,6 +153,7 @@ _SYSTEM_TO_DYLIB_EXT = {
+ "ios": ".dylib",
+ "linux": ".so",
+ "none": ".so",
++ "uefi": "", # UEFI doesn't have dynamic linking
+ "unknown": ".wasm",
+ "wasi": ".wasm",
+ "windows": ".dll",
+@@ -191,6 +197,7 @@ _SYSTEM_TO_STDLIB_LINKFLAGS = {
+ "none": [],
+ "openbsd": ["-lpthread"],
+ "solaris": ["-lsocket", "-lposix4", "-lpthread", "-lresolv"],
++ "uefi": [],
+ "unknown": [],
+ "uwp": ["ws2_32.lib"],
+ "wasi": [],
+--
+2.41.0
+