@@ -20,6 +20,7 @@ def declare_rustc_toolchains(
2020 * ,
2121 version ,
2222 edition ,
23+ include_rustc_dev = False ,
2324 extra_rustc_flags = {},
2425 extra_exec_rustc_flags = {},
2526 execs = SUPPORTED_EXEC_TRIPLES ,
@@ -34,6 +35,7 @@ def declare_rustc_toolchains(
3435 triple_suffix = exec_triple .system + "_" + exec_triple .arch
3536
3637 rustc_repo_label = "@rustc_{}_{}//:" .format (triple_suffix , version_key )
38+ rustc_with_dev_repo_label = "@rustc_with_dev_{}_{}//:" .format (triple_suffix , version_key )
3739 cargo_repo_label = "@cargo_{}_{}//:" .format (triple_suffix , version_key )
3840 clippy_repo_label = "@clippy_{}_{}//:" .format (triple_suffix , version_key )
3941
@@ -42,6 +44,7 @@ def declare_rustc_toolchains(
4244 exec_triple .arch ,
4345 version_key ,
4446 )
47+ rust_toolchain_with_dev_name = rust_toolchain_name + "_with_dev"
4548
4649 rust_std_select = {}
4750 target_triple_select = {}
@@ -134,8 +137,44 @@ def declare_rustc_toolchains(
134137 ** rust_toolchain_kwargs
135138 )
136139
140+ if include_rustc_dev :
141+ # Keep the ordinary toolchains registered for the default path, and
142+ # expose parallel dev-enabled variants only to configurations that
143+ # explicitly request the merged rustc-dev sysroot.
144+ rust_toolchain_with_dev_kwargs = dict (rust_toolchain_kwargs )
145+ rust_toolchain_with_dev_kwargs .update (
146+ rust_doc = "{}rustdoc" .format (rustc_with_dev_repo_label ),
147+ rustc = "{}rustc" .format (rustc_with_dev_repo_label ),
148+ rust_objcopy = "{}rust-objcopy" .format (rustc_with_dev_repo_label ),
149+ rustc_lib = "{}rustc_lib" .format (rustc_with_dev_repo_label ),
150+ )
151+
152+ rust_toolchain (
153+ name = rust_toolchain_with_dev_name ,
154+ process_wrapper = "@rules_rust//util/process_wrapper" ,
155+ ** rust_toolchain_with_dev_kwargs
156+ )
157+
158+ rust_toolchain (
159+ name = rust_toolchain_with_dev_name + "_bootstrap" ,
160+ bootstrapping = True ,
161+ process_wrapper = "@rules_rust//util/process_wrapper:bootstrap_process_wrapper" ,
162+ ** rust_toolchain_with_dev_kwargs
163+ )
164+
137165 for target_triple in targets :
138166 target_key = sanitize_triple (target_triple )
167+ bootstrapped_target_settings = [
168+ "@rules_rust//rust/private:bootstrapped" ,
169+ "@rules_rust//rust/toolchain/channel:" + channel ,
170+ ]
171+ bootstrapping_target_settings = [
172+ "@rules_rust//rust/private:bootstrapping" ,
173+ "@rules_rust//rust/toolchain/channel:" + channel ,
174+ ]
175+ if include_rustc_dev :
176+ bootstrapped_target_settings .append ("@rules_rs//rs/toolchains/rustc_dev:disabled" )
177+ bootstrapping_target_settings .append ("@rules_rs//rs/toolchains/rustc_dev:disabled" )
139178
140179 native .toolchain (
141180 name = "{}_{}_to_{}_{}" .format (exec_triple .system , exec_triple .arch , target_key , version_key ),
@@ -144,10 +183,7 @@ def declare_rustc_toolchains(
144183 "@platforms//cpu:" + exec_triple .arch ,
145184 ],
146185 target_compatible_with = triple_to_constraint_set (target_triple ),
147- target_settings = [
148- "@rules_rust//rust/private:bootstrapped" ,
149- "@rules_rust//rust/toolchain/channel:" + channel ,
150- ],
186+ target_settings = bootstrapped_target_settings ,
151187 toolchain = rust_toolchain_name ,
152188 toolchain_type = "@rules_rust//rust:toolchain_type" ,
153189 visibility = ["//visibility:public" ],
@@ -160,11 +196,43 @@ def declare_rustc_toolchains(
160196 "@platforms//cpu:" + exec_triple .arch ,
161197 ],
162198 target_compatible_with = triple_to_constraint_set (target_triple ),
163- target_settings = [
164- "@rules_rust//rust/private:bootstrapping" ,
165- "@rules_rust//rust/toolchain/channel:" + channel ,
166- ],
199+ target_settings = bootstrapping_target_settings ,
167200 toolchain = rust_toolchain_name + "_bootstrap" ,
168201 toolchain_type = "@rules_rust//rust:toolchain_type" ,
169202 visibility = ["//visibility:public" ],
170203 )
204+
205+ if include_rustc_dev :
206+ native .toolchain (
207+ name = "{}_{}_to_{}_{}_with_dev" .format (exec_triple .system , exec_triple .arch , target_key , version_key ),
208+ exec_compatible_with = [
209+ "@platforms//os:" + exec_triple .system ,
210+ "@platforms//cpu:" + exec_triple .arch ,
211+ ],
212+ target_compatible_with = triple_to_constraint_set (target_triple ),
213+ target_settings = [
214+ "@rules_rust//rust/private:bootstrapped" ,
215+ "@rules_rust//rust/toolchain/channel:" + channel ,
216+ "@rules_rs//rs/toolchains/rustc_dev:enabled_setting" ,
217+ ],
218+ toolchain = rust_toolchain_with_dev_name ,
219+ toolchain_type = "@rules_rust//rust:toolchain_type" ,
220+ visibility = ["//visibility:public" ],
221+ )
222+
223+ native .toolchain (
224+ name = "{}_{}_to_{}_{}_bootstrap_with_dev" .format (exec_triple .system , exec_triple .arch , target_key , version_key ),
225+ exec_compatible_with = [
226+ "@platforms//os:" + exec_triple .system ,
227+ "@platforms//cpu:" + exec_triple .arch ,
228+ ],
229+ target_compatible_with = triple_to_constraint_set (target_triple ),
230+ target_settings = [
231+ "@rules_rust//rust/private:bootstrapping" ,
232+ "@rules_rust//rust/toolchain/channel:" + channel ,
233+ "@rules_rs//rs/toolchains/rustc_dev:enabled_setting" ,
234+ ],
235+ toolchain = rust_toolchain_with_dev_name + "_bootstrap" ,
236+ toolchain_type = "@rules_rust//rust:toolchain_type" ,
237+ visibility = ["//visibility:public" ],
238+ )
0 commit comments