@@ -1115,6 +1115,17 @@ def _get_toolchain_repositories(
11151115
11161116 return toolchain_repos .values ()
11171117
1118+ def _get_flags_for_triple (name , flags , target_triple ):
1119+ """Infer toolchain-specific flags depending on the type (list, dict, optional)."""
1120+ if flags == None :
1121+ return None
1122+ elif type (flags ) == "list" :
1123+ return flags
1124+ elif type (flags ) == "dict" :
1125+ return flags .get (target_triple )
1126+ else :
1127+ fail (name + " should be a list or a dict" )
1128+
11181129def rust_repository_set (
11191130 * ,
11201131 name ,
@@ -1162,7 +1173,7 @@ def rust_repository_set(
11621173 dev_components (bool, optional): Whether to download the rustc-dev components.
11631174 Requires version to be "nightly".
11641175 extra_rustc_flags (dict, list, optional): Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration.
1165- extra_exec_rustc_flags (list, optional): Extra flags to pass to rustc in exec configuration.
1176+ extra_exec_rustc_flags (dict, list, optional): Dictionary of target triples to list of extra flags to pass to rustc in exec configuration.
11661177 opt_level (dict, dict, optional): Dictionary of target triples to optimization config.
11671178 strip_level (dict, dict, optional): Dictionary of target triples to strip config.
11681179 sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. See
@@ -1196,15 +1207,16 @@ def rust_repository_set(
11961207 aliases = aliases ,
11971208 compact_windows_names = compact_windows_names ,
11981209 ):
1199- # Infer toolchain-specific rustc flags depending on the type (list, dict, optional) of extra_rustc_flags
1200- if extra_rustc_flags == None :
1201- toolchain_extra_rustc_flags = []
1202- elif type (extra_rustc_flags ) == "list" :
1203- toolchain_extra_rustc_flags = extra_rustc_flags
1204- elif type (extra_rustc_flags ) == "dict" :
1205- toolchain_extra_rustc_flags = extra_rustc_flags .get (toolchain .target_triple )
1206- else :
1207- fail ("extra_rustc_flags should be a list or a dict" )
1210+ toolchain_extra_exec_rustc_flags = _get_flags_for_triple (
1211+ "extra_exec_rustc_flags" ,
1212+ extra_exec_rustc_flags ,
1213+ toolchain .target_triple ,
1214+ )
1215+ toolchain_extra_rustc_flags = _get_flags_for_triple (
1216+ "extra_rustc_flags" ,
1217+ extra_rustc_flags ,
1218+ toolchain .target_triple ,
1219+ )
12081220
12091221 toolchain_info = rust_toolchain_repository (
12101222 name = toolchain .name ,
@@ -1217,7 +1229,7 @@ def rust_repository_set(
12171229 dev_components = dev_components ,
12181230 edition = edition ,
12191231 exec_triple = exec_triple ,
1220- extra_exec_rustc_flags = extra_exec_rustc_flags ,
1232+ extra_exec_rustc_flags = toolchain_extra_exec_rustc_flags ,
12211233 extra_rustc_flags = toolchain_extra_rustc_flags ,
12221234 opt_level = opt_level .get (toolchain .target_triple ) if opt_level != None else None ,
12231235 strip_level = strip_level .get (toolchain .target_triple ) if strip_level != None else None ,
0 commit comments