Skip to content

Commit

Permalink
Apply extra_rustc_flags list to all toolchains (#2693)
Browse files Browse the repository at this point in the history
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 <github@uebelandre.com>
  • Loading branch information
nmattia and UebelAndre committed Jun 14, 2024
1 parent bb73b64 commit 78c68d6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 78c68d6

Please sign in to comment.