From 78c68d60d974a8fae420acc1cc6970f56d6c03f8 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Fri, 14 Jun 2024 15:23:55 +0200 Subject: [PATCH] Apply extra_rustc_flags list to all toolchains (#2693) Fixes #2692 This fixes `rust_register_toolchains` to correctly call `rust_toolchain_repository` with a list of `extra_rustc_flags`. Previously, the `extra_rustc_flags` argument of `rust_register_toolchains` was assumed (when set) to be a dict of toolchain triple to list. With this change, a `list` parameter is used for all toolchain triples. Co-authored-by: UebelAndre --- rust/repositories.bzl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 9552e8163d..b4d38b1b5c 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -1087,6 +1087,16 @@ def rust_repository_set( elif type(extra_target_triples) == "dict": target_compatible_with = extra_target_triples.get(toolchain.target_triple) + # Infer toolchain-specific rustc flags depending on the type (list, dict, optional) of extra_rustc_flags + if extra_rustc_flags == None: + toolchain_extra_rustc_flags = [] + elif type(extra_rustc_flags) == "list": + toolchain_extra_rustc_flags = extra_rustc_flags + elif type(extra_rustc_flags) == "dict": + toolchain_extra_rustc_flags = extra_rustc_flags.get(toolchain.target_triple) + else: + fail("extra_rustc_flags should be a list or a dict") + all_toolchain_names.append(rust_toolchain_repository( name = toolchain.name, allocator_library = allocator_library, @@ -1099,7 +1109,7 @@ def rust_repository_set( edition = edition, exec_triple = exec_triple, extra_exec_rustc_flags = extra_exec_rustc_flags, - extra_rustc_flags = extra_rustc_flags.get(toolchain.target_triple) if extra_rustc_flags != None else None, + extra_rustc_flags = toolchain_extra_rustc_flags, opt_level = opt_level.get(toolchain.target_triple) if opt_level != None else None, target_settings = target_settings, iso_date = toolchain.channel.iso_date,