@@ -446,7 +446,7 @@ def _generate_sysroot(
446446
447447 # Rustc
448448 sysroot_rustc = _symlink_sysroot_bin (ctx , name , "bin" , rustc )
449- direct_files .extend ([ sysroot_rustc ] )
449+ direct_files .append ( sysroot_rustc )
450450
451451 # Rustc dependencies
452452 sysroot_rustc_lib = None
@@ -456,43 +456,43 @@ def _generate_sysroot(
456456
457457 # Rustdoc
458458 sysroot_rustdoc = _symlink_sysroot_bin (ctx , name , "bin" , rustdoc )
459- direct_files .extend ([ sysroot_rustdoc ] )
459+ direct_files .append ( sysroot_rustdoc )
460460
461461 # Clippy
462462 sysroot_clippy = None
463463 if clippy :
464464 sysroot_clippy = _symlink_sysroot_bin (ctx , name , "bin" , clippy )
465- direct_files .extend ([ sysroot_clippy ] )
465+ direct_files .append ( sysroot_clippy )
466466
467467 # Cargo
468468 sysroot_cargo = None
469469 if cargo :
470470 sysroot_cargo = _symlink_sysroot_bin (ctx , name , "bin" , cargo )
471- direct_files .extend ([ sysroot_cargo ] )
471+ direct_files .append ( sysroot_cargo )
472472
473473 # Cargo-clippy
474474 sysroot_cargo_clippy = None
475475 if cargo_clippy :
476476 sysroot_cargo_clippy = _symlink_sysroot_bin (ctx , name , "bin" , cargo_clippy )
477- direct_files .extend ([ sysroot_cargo_clippy ] )
477+ direct_files .append ( sysroot_cargo_clippy )
478478
479479 # Rustfmt
480480 sysroot_rustfmt = None
481481 if rustfmt :
482482 sysroot_rustfmt = _symlink_sysroot_bin (ctx , name , "bin" , rustfmt )
483- direct_files .extend ([ sysroot_rustfmt ] )
483+ direct_files .append ( sysroot_rustfmt )
484484
485485 # Llvm tools
486486 sysroot_llvm_tools = None
487487 if llvm_tools :
488488 sysroot_llvm_tools = _symlink_sysroot_tree (ctx , name , llvm_tools )
489- transitive_file_sets .extend ([ sysroot_llvm_tools ] )
489+ transitive_file_sets .append ( sysroot_llvm_tools )
490490
491491 # Rust standard library
492492 sysroot_rust_std = None
493493 if rust_std :
494494 sysroot_rust_std = _symlink_sysroot_tree (ctx , name , rust_std )
495- transitive_file_sets .extend ([ sysroot_rust_std ] )
495+ transitive_file_sets .append ( sysroot_rust_std )
496496
497497 # Made available to support $(location) expansion in stdlib_linkflags and extra_rustc_flags.
498498 transitive_file_sets .append (depset (ctx .files .rust_std ))
@@ -617,14 +617,10 @@ def _rust_toolchain_impl(ctx):
617617 }
618618
619619 if sysroot .cargo :
620- make_variables .update ({
621- "CARGO" : sysroot .cargo .path ,
622- })
620+ make_variables ["CARGO" ] = sysroot .cargo .path
623621
624622 if sysroot .rustfmt :
625- make_variables .update ({
626- "RUSTFMT" : sysroot .rustfmt .path ,
627- })
623+ make_variables ["RUSTFMT" ] = sysroot .rustfmt .path
628624
629625 make_variable_info = platform_common .TemplateVariableInfo (make_variables )
630626
@@ -704,13 +700,18 @@ def _rust_toolchain_impl(ctx):
704700 )
705701
706702 # Include C++ toolchain files to ensure tools like 'ar' are available for cross-compilation
707- cc_toolchain , _ = find_cc_toolchain (ctx )
708- all_files_depsets = [sysroot .all_files ]
709- if cc_toolchain and cc_toolchain .all_files :
710- all_files_depsets .append (cc_toolchain .all_files )
703+ if ctx .attr ._incompatible_do_not_include_cc_toolchain_files_in_rust_toolchain_all_files [IncompatibleFlagInfo ].enabled :
704+ all_files = sysroot .all_files
705+ else :
706+ all_files_depsets = [sysroot .all_files ]
707+ cc_toolchain , _ = find_cc_toolchain (ctx )
708+ all_files_depsets = [sysroot .all_files ]
709+ if cc_toolchain and cc_toolchain .all_files :
710+ all_files_depsets .append (cc_toolchain .all_files )
711+ all_files = depset (transitive = all_files_depsets )
711712
712713 toolchain = platform_common .ToolchainInfo (
713- all_files = depset ( transitive = all_files_depsets ) ,
714+ all_files = all_files ,
714715 binary_ext = ctx .attr .binary_ext ,
715716 cargo = sysroot .cargo ,
716717 clippy_driver = sysroot .clippy ,
@@ -982,6 +983,9 @@ rust_toolchain = rule(
982983 "_incompatible_change_rust_test_compilation_output_directory" : attr .label (
983984 default = Label ("//rust/settings:incompatible_change_rust_test_compilation_output_directory" ),
984985 ),
986+ "_incompatible_do_not_include_cc_toolchain_files_in_rust_toolchain_all_files" : attr .label (
987+ default = Label ("//rust/settings:incompatible_do_not_include_cc_toolchain_files_in_rust_toolchain_all_files" ),
988+ ),
985989 "_incompatible_do_not_include_data_in_compile_data" : attr .label (
986990 default = Label ("//rust/settings:incompatible_do_not_include_data_in_compile_data" ),
987991 doc = "Label to a boolean build setting that controls whether to include data files in compile_data." ,
0 commit comments