fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
e765719e
0.6.0
1"""The rust_toolchain rule definition and implementation.""" 2 3load ( "@bazel_skylib//rules:common_settings.bzl" , "BuildSettingInfo" ) 4load ( "//rust/private:common.bzl" , "rust_common" ) 5load ( "//rust/private:utils.bzl" , "dedent" , "find_cc_toolchain" , "make_static_lib_symlink" ) 6 7def _rust_stdlib_filegroup_impl ( ctx ): 8rust_std = ctx . files . srcs 9dot_a_files = [] 10between_alloc_and_core_files = [] 11core_files = [] 12between_core_and_std_files = [] 13std_files = [] 14memchr_files = [] 15alloc_files = [] 16self_contained_files = [ 17file 18for file in rust_std 19if file . basename . endswith ( ".o" ) and "self-contained" in file . path 20] 21 22std_rlibs = [ f for f in rust_std if f . basename . endswith ( ".rlib" )] 23if std_rlibs : 24# std depends on everything 25# 26# core only depends on alloc, but we poke adler in there 27# because that needs to be before miniz_oxide 28# 29# alloc depends on the allocator_library if it's configured, but we 30# do that later. 31dot_a_files = [ make_static_lib_symlink ( ctx . actions , f ) for f in std_rlibs ] 32 33alloc_files = [ f for f in dot_a_files if "alloc" in f . basename and "std" not in f . basename ] 34between_alloc_and_core_files = [ f for f in dot_a_files if "compiler_builtins" in f . basename ] 35core_files = [ f for f in dot_a_files if ( "core" in f . basename or "adler" in f . basename ) and "std" not in f . basename ] 36between_core_and_std_files = [ 37f 38for f in dot_a_files 39if "alloc" not in f . basename and "compiler_builtins" not in f . basename and "core" not in f . basename and "adler" not in f . basename and "std" not in f . basename and "memchr" not in f . basename 40] 41memchr_files = [ f for f in dot_a_files if "memchr" in f . basename ] 42std_files = [ f for f in dot_a_files if "std" in f . basename ] 43 44partitioned_files_len = len ( alloc_files ) + len ( between_alloc_and_core_files ) + len ( core_files ) + len ( between_core_and_std_files ) + len ( memchr_files ) + len ( std_files ) 45if partitioned_files_len != len ( dot_a_files ): 46partitioned = alloc_files + between_alloc_and_core_files + core_files + between_core_and_std_files + memchr_files + std_files 47for f in sorted ( partitioned ): 48# buildifier: disable=print 49( "File partitioned: {}" . format ( f . basename )) 50fail ( "rust_toolchain couldn't properly partition rlibs in rust_std. Partitioned {} out of {} files. This is probably a bug in the rule implementation." . format ( partitioned_files_len , len ( dot_a_files ))) 51 52return [ 53DefaultInfo ( 54files = depset ( ctx . files . srcs ), 55), 56rust_common . stdlib_info ( 57std_rlibs = std_rlibs , 58dot_a_files = dot_a_files , 59between_alloc_and_core_files = between_alloc_and_core_files , 60core_files = core_files , 61between_core_and_std_files = between_core_and_std_files , 62std_files = std_files , 63memchr_files = memchr_files , 64alloc_files = alloc_files , 65self_contained_files = self_contained_files , 66srcs = ctx . attr . srcs , 67), 68] 69 70rust_stdlib_filegroup = rule ( 71doc = "A dedicated filegroup-like rule for Rust stdlib artifacts." , 72implementation = _rust_stdlib_filegroup_impl , 73attrs = { 74"srcs" : attr . label_list ( 75allow_files = True , 76doc = "The list of targets/files that are components of the rust-stdlib file group" , 77mandatory = True , 78), 79}, 80) 81 82def _ltl ( library , ctx , cc_toolchain , feature_configuration ): 83"""A helper to generate `LibraryToLink` objects 84 85Args: 86library (File): A rust library file to link. 87ctx (ctx): The rule's context object. 88cc_toolchain (CcToolchainInfo): A cc toolchain provider to be used. 89feature_configuration (feature_configuration): feature_configuration to be queried. 90 91Returns: 92LibraryToLink: A provider containing information about libraries to link. 93""" 94return cc_common . create_library_to_link ( 95actions = ctx . actions , 96feature_configuration = feature_configuration , 97cc_toolchain = cc_toolchain , 98static_library = library , 99pic_static_library = library , 100) 101 102def _make_libstd_and_allocator_ccinfo ( ctx , rust_std , allocator_library ): 103"""Make the CcInfo (if possible) for libstd and allocator libraries. 104 105Args: 106ctx (ctx): The rule's context object. 107rust_std: The Rust standard library. 108allocator_library: The target to use for providing allocator functions. 109 110 111Returns: 112A CcInfo object for the required libraries, or None if no such libraries are available. 113""" 114cc_toolchain , feature_configuration = find_cc_toolchain ( ctx ) 115cc_infos = [] 116 117if not rust_common . stdlib_info in rust_std : 118fail ( dedent ( """\ 119{} -- 120The `rust_lib` ({}) must be a target providing `rust_common.stdlib_info` 121(typically `rust_stdlib_filegroup` rule from @rules_rust//rust:defs.bzl). 122See https://github.com/bazelbuild/rules_rust/pull/802 for more information. 123""" ). format ( ctx . label , rust_std )) 124rust_stdlib_info = rust_std [ rust_common . stdlib_info ] 125 126if rust_stdlib_info . self_contained_files : 127compilation_outputs = cc_common . create_compilation_outputs ( 128objects = depset ( rust_stdlib_info . self_contained_files ), 129) 130 131linking_context , _linking_outputs = cc_common . create_linking_context_from_compilation_outputs ( 132name = ctx . label . name , 133actions = ctx . actions , 134feature_configuration = feature_configuration , 135cc_toolchain = cc_toolchain , 136compilation_outputs = compilation_outputs , 137) 138 139cc_infos . append ( CcInfo ( 140linking_context = linking_context , 141)) 142 143if rust_stdlib_info . std_rlibs : 144alloc_inputs = depset ( 145[ _ltl ( f , ctx , cc_toolchain , feature_configuration ) for f in rust_stdlib_info . alloc_files ], 146) 147between_alloc_and_core_inputs = depset ( 148[ _ltl ( f , ctx , cc_toolchain , feature_configuration ) for f in rust_stdlib_info . between_alloc_and_core_files ], 149transitive = [ alloc_inputs ], 150order = "topological" , 151) 152core_inputs = depset ( 153[ _ltl ( f , ctx , cc_toolchain , feature_configuration ) for f in rust_stdlib_info . core_files ], 154transitive = [ between_alloc_and_core_inputs ], 155order = "topological" , 156) 157 158# The libraries panic_abort and panic_unwind are alternatives. 159# The std by default requires panic_unwind. 160# Exclude panic_abort if panic_unwind is present. 161# TODO: Provide a setting to choose between panic_abort and panic_unwind. 162filtered_between_core_and_std_files = rust_stdlib_info . between_core_and_std_files 163has_panic_unwind = [ 164f 165for f in filtered_between_core_and_std_files 166if "panic_unwind" in f . basename 167] 168if has_panic_unwind : 169filtered_between_core_and_std_files = [ 170f 171for f in filtered_between_core_and_std_files 172if "panic_abort" not in f . basename 173] 174memchr_inputs = depset ( 175[ 176_ltl ( f , ctx , cc_toolchain , feature_configuration ) 177for f in rust_stdlib_info . memchr_files 178], 179transitive = [ core_inputs ], 180order = "topological" , 181) 182between_core_and_std_inputs = depset ( 183[ 184_ltl ( f , ctx , cc_toolchain , feature_configuration ) 185for f in filtered_between_core_and_std_files 186], 187transitive = [ memchr_inputs ], 188order = "topological" , 189) 190std_inputs = depset ( 191[ 192_ltl ( f , ctx , cc_toolchain , feature_configuration ) 193for f in rust_stdlib_info . std_files 194], 195transitive = [ between_core_and_std_inputs ], 196order = "topological" , 197) 198 199link_inputs = cc_common . create_linker_input ( 200owner = rust_std . label , 201libraries = std_inputs , 202) 203 204allocator_inputs = None 205if allocator_library : 206allocator_inputs = [ allocator_library [ CcInfo ]. linking_context . linker_inputs ] 207 208cc_infos . append ( CcInfo ( 209linking_context = cc_common . create_linking_context ( 210linker_inputs = depset ( 211[ link_inputs ], 212transitive = allocator_inputs , 213order = "topological" , 214), 215), 216)) 217 218if cc_infos : 219return cc_common . merge_cc_infos ( 220direct_cc_infos = cc_infos , 221) 222return None 223 224def _symlink_sysroot_tree ( ctx , name , target ): 225"""Generate a set of symlinks to files from another target 226 227Args: 228ctx (ctx): The toolchain's context object 229name (str): The name of the sysroot directory (typically `ctx.label.name`) 230target (Target): A target owning files to symlink 231 232Returns: 233depset[File]: A depset of the generated symlink files 234""" 235tree_files = [] 236for file in target . files . to_list (): 237# Parse the path to the file relative to the workspace root so a 238# symlink matching this path can be created within the sysroot. 239 240# The code blow attempts to parse any workspace names out of the 241# path. For local targets, this code is a noop. 242if target . label . workspace_root : 243file_path = file . path . split ( target . label . workspace_root , 1 )[ - 1 ] 244else : 245file_path = file . path 246 247symlink = ctx . actions . declare_file ( "{}/{}" . format ( name , file_path . lstrip ( "/" ))) 248 249ctx . actions . symlink ( 250output = symlink , 251target_file = file , 252) 253 254tree_files . append ( symlink ) 255 256return depset ( tree_files ) 257 258def _symlink_sysroot_bin ( ctx , name , directory , target ): 259"""Crete a symlink to a target file. 260 261Args: 262ctx (ctx): The rule's context object 263name (str): A common name for the output directory 264directory (str): The directory under `name` to put the file in 265target (File): A File object to symlink to 266 267Returns: 268File: A newly generated symlink file 269""" 270symlink = ctx . actions . declare_file ( "{}/{}/{}" . format ( 271name , 272directory , 273target . basename , 274)) 275 276ctx . actions . symlink ( 277output = symlink , 278target_file = target , 279is_executable = True , 280) 281 282return symlink 283 284def _generate_sysroot ( 285ctx , 286rustc , 287rustdoc , 288rustc_lib , 289cargo = None , 290clippy = None , 291llvm_tools = None , 292rust_std = None , 293rustfmt = None ): 294"""Generate a rust sysroot from collection of toolchain components 295 296Args: 297ctx (ctx): A context object from a `rust_toolchain` rule. 298rustc (File): The path to a `rustc` executable. 299rustdoc (File): The path to a `rustdoc` executable. 300rustc_lib (Target): A collection of Files containing dependencies of `rustc`. 301cargo (File, optional): The path to a `cargo` executable. 302clippy (File, optional): The path to a `clippy-driver` executable. 303llvm_tools (Target, optional): A collection of llvm tools used by `rustc`. 304rust_std (Target, optional): A collection of Files containing Rust standard library components. 305rustfmt (File, optional): The path to a `rustfmt` executable. 306 307Returns: 308struct: A struct of generated files representing the new sysroot 309""" 310name = ctx . label . name 311 312# Define runfiles 313direct_files = [] 314transitive_file_sets = [] 315 316# Rustc 317sysroot_rustc = _symlink_sysroot_bin ( ctx , name , "bin" , rustc ) 318direct_files . extend ([ sysroot_rustc ]) 319 320# Rustc dependencies 321sysroot_rustc_lib = None 322if rustc_lib : 323sysroot_rustc_lib = _symlink_sysroot_tree ( ctx , name , rustc_lib ) 324transitive_file_sets . extend ([ sysroot_rustc_lib ]) 325 326# Rustdoc 327sysroot_rustdoc = _symlink_sysroot_bin ( ctx , name , "bin" , rustdoc ) 328direct_files . extend ([ sysroot_rustdoc ]) 329 330# Clippy 331sysroot_clippy = None 332if clippy : 333sysroot_clippy = _symlink_sysroot_bin ( ctx , name , "bin" , clippy ) 334direct_files . extend ([ sysroot_clippy ]) 335 336# Cargo 337sysroot_cargo = None 338if cargo : 339sysroot_cargo = _symlink_sysroot_bin ( ctx , name , "bin" , cargo ) 340direct_files . extend ([ sysroot_cargo ]) 341 342# Rustfmt 343sysroot_rustfmt = None 344if rustfmt : 345sysroot_rustfmt = _symlink_sysroot_bin ( ctx , name , "bin" , rustfmt ) 346direct_files . extend ([ sysroot_rustfmt ]) 347 348# Llvm tools 349sysroot_llvm_tools = None 350if llvm_tools : 351sysroot_llvm_tools = _symlink_sysroot_tree ( ctx , name , llvm_tools ) 352transitive_file_sets . extend ([ sysroot_llvm_tools ]) 353 354# Rust standard library 355sysroot_rust_std = None 356if rust_std : 357sysroot_rust_std = _symlink_sysroot_tree ( ctx , name , rust_std ) 358transitive_file_sets . extend ([ sysroot_rust_std ]) 359 360# Declare a file in the root of the sysroot to make locating the sysroot easy 361sysroot_anchor = ctx . actions . declare_file ( "{}/rust.sysroot" . format ( name )) 362ctx . actions . write ( 363output = sysroot_anchor , 364content = "\n ". join ([ 365"cargo: {}" . format ( cargo ), 366"clippy: {}" . format ( clippy ), 367"llvm_tools: {}" . format ( llvm_tools ), 368"rust_std: {}" . format ( rust_std ), 369"rustc_lib: {}" . format ( rustc_lib ), 370"rustc: {}" . format ( rustc ), 371"rustdoc: {}" . format ( rustdoc ), 372"rustfmt: {}" . format ( rustfmt ), 373]), 374) 375 376# Create a depset of all sysroot files (symlinks and their real paths) 377all_files = depset ( direct_files , transitive = transitive_file_sets ) 378 379return struct ( 380all_files = all_files , 381cargo = sysroot_cargo , 382clippy = sysroot_clippy , 383rust_std = sysroot_rust_std , 384rustc = sysroot_rustc , 385rustc_lib = sysroot_rustc_lib , 386rustdoc = sysroot_rustdoc , 387rustfmt = sysroot_rustfmt , 388sysroot_anchor = sysroot_anchor , 389) 390 391def _rust_toolchain_impl ( ctx ): 392"""The rust_toolchain implementation 393 394Args: 395ctx (ctx): The rule's context object 396 397Returns: 398list: A list containing the target's toolchain Provider info 399""" 400compilation_mode_opts = {} 401for k , v in ctx . attr . opt_level . items (): 402if not k in ctx . attr . debug_info : 403fail ( "Compilation mode {} is not defined in debug_info but is defined opt_level" . format ( k )) 404compilation_mode_opts [ k ] = struct ( debug_info = ctx . attr . debug_info [ k ], opt_level = v ) 405for k , v in ctx . attr . debug_info . items (): 406if not k in ctx . attr . opt_level : 407fail ( "Compilation mode {} is not defined in opt_level but is defined debug_info" . format ( k )) 408 409if ctx . attr . target_triple and ctx . file . target_json : 410fail ( "Do not specify both target_triple and target_json, either use a builtin triple or provide a custom specification file." ) 411 412rename_first_party_crates = ctx . attr . _rename_first_party_crates [ BuildSettingInfo ]. value 413third_party_dir = ctx . attr . _third_party_dir [ BuildSettingInfo ]. value 414 415if ctx . attr . rust_lib : 416# buildifier: disable=print 417( "`rust_toolchain.rust_lib` is deprecated. Please update {} to use `rust_toolchain.rust_std`" . format ( 418ctx . label , 419)) 420rust_std = ctx . attr . rust_lib 421else : 422rust_std = ctx . attr . rust_std 423 424sysroot = _generate_sysroot ( 425ctx = ctx , 426rustc = ctx . file . rustc , 427rustdoc = ctx . file . rust_doc , 428rustc_lib = ctx . attr . rustc_lib , 429rust_std = rust_std , 430rustfmt = ctx . file . rustfmt , 431clippy = ctx . file . clippy_driver , 432cargo = ctx . file . cargo , 433llvm_tools = ctx . attr . llvm_tools , 434) 435 436expanded_stdlib_linkflags = [] 437for flag in ctx . attr . stdlib_linkflags : 438expanded_stdlib_linkflags . append ( 439ctx . expand_location ( 440flag , 441targets = rust_std [ rust_common . stdlib_info ]. srcs , 442), 443) 444 445linking_context = cc_common . create_linking_context ( 446linker_inputs = depset ([ 447cc_common . create_linker_input ( 448owner = ctx . label , 449user_link_flags = depset ( expanded_stdlib_linkflags ), 450), 451]), 452) 453 454# Contains linker flags needed to link Rust standard library. 455# These need to be added to linker command lines when the linker is not rustc 456# (rustc does this automatically). Linker flags wrapped in an otherwise empty 457# `CcInfo` to provide the flags in a way that doesn't duplicate them per target 458# providing a `CcInfo`. 459stdlib_linkflags_cc_info = CcInfo ( 460compilation_context = cc_common . create_compilation_context (), 461linking_context = linking_context , 462) 463 464# Determine the path and short_path of the sysroot 465sysroot_path = sysroot . sysroot_anchor . dirname 466sysroot_short_path , _ , _ = sysroot . sysroot_anchor . short_path . rpartition ( "/" ) 467 468# Variables for make variable expansion 469make_variables = { 470"RUSTC" : sysroot . rustc . path , 471"RUSTDOC" : sysroot . rustdoc . path , 472"RUST_DEFAULT_EDITION" : ctx . attr . default_edition or "" , 473"RUST_SYSROOT" : sysroot_path , 474} 475 476if sysroot . cargo : 477make_variables . update ({ 478"CARGO" : sysroot . cargo . path , 479}) 480 481if sysroot . rustfmt : 482make_variables . update ({ 483"RUSTFMT" : sysroot . rustfmt . path , 484}) 485 486toolchain = platform_common . ToolchainInfo ( 487all_files = sysroot . all_files , 488binary_ext = ctx . attr . binary_ext , 489cargo = sysroot . cargo , 490clippy_driver = sysroot . clippy , 491compilation_mode_opts = compilation_mode_opts , 492crosstool_files = ctx . files . _cc_toolchain , 493default_edition = ctx . attr . default_edition , 494dylib_ext = ctx . attr . dylib_ext , 495env = ctx . attr . env , 496exec_triple = ctx . attr . exec_triple , 497libstd_and_allocator_ccinfo = _make_libstd_and_allocator_ccinfo ( ctx , rust_std , ctx . attr . allocator_library ), 498make_variables = platform_common . TemplateVariableInfo ( make_variables ), 499os = ctx . attr . os , 500rust_doc = sysroot . rustdoc , 501rust_lib = sysroot . rust_std , #`rust_lib` is deprecated and only exists for legacy support . 502rust_std = sysroot . rust_std , 503rust_std_paths = depset ([ file . dirname for file in sysroot . rust_std . to_list ()]), 504rustc = sysroot . rustc , 505rustc_lib = sysroot . rustc_lib , 506rustc_srcs = ctx . attr . rustc_srcs , 507rustfmt = sysroot . rustfmt , 508staticlib_ext = ctx . attr . staticlib_ext , 509stdlib_linkflags = stdlib_linkflags_cc_info , 510sysroot = sysroot_path , 511sysroot_short_path = sysroot_short_path , 512target_arch = ctx . attr . target_triple . split ( "-" )[ 0 ], 513target_flag_value = ctx . file . target_json . path if ctx . file . target_json else ctx . attr . target_triple , 514target_json = ctx . file . target_json , 515target_triple = ctx . attr . target_triple , 516 517# Experimental and incompatible flags 518_rename_first_party_crates = rename_first_party_crates , 519_third_party_dir = third_party_dir , 520) 521return [ toolchain ] 522 523rust_toolchain = rule ( 524implementation = _rust_toolchain_impl , 525fragments = [ "cpp" ], 526attrs = { 527"allocator_library" : attr . label ( 528doc = "Target that provides allocator functions when rust_library targets are embedded in a cc_binary." , 529), 530"binary_ext" : attr . string ( 531doc = "The extension for binaries created from rustc." , 532mandatory = True , 533), 534"cargo" : attr . label ( 535doc = "The location of the `cargo` binary. Can be a direct source or a filegroup containing one item." , 536allow_single_file = True , 537cfg = "exec" , 538), 539"clippy_driver" : attr . label ( 540doc = "The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item." , 541allow_single_file = True , 542cfg = "exec" , 543), 544"debug_info" : attr . string_dict ( 545doc = "Rustc debug info levels per opt level" , 546default = { 547"dbg" : "2" , 548"fastbuild" : "0" , 549"opt" : "0" , 550}, 551), 552"default_edition" : attr . string ( 553doc = ( 554"The edition to use for rust_* rules that don't specify an edition. " + 555"If absent, every rule is required to specify its `edition` attribute." 556), 557), 558"dylib_ext" : attr . string ( 559doc = "The extension for dynamic libraries created from rustc." , 560mandatory = True , 561), 562"env" : attr . string_dict ( 563doc = "Environment variables to set in actions." , 564), 565"exec_triple" : attr . string ( 566doc = ( 567"The platform triple for the toolchains execution environment. " + 568"For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations" 569), 570mandatory = True , 571), 572"llvm_tools" : attr . label ( 573doc = "LLVM tools that are shipped with the Rust toolchain." , 574allow_files = True , 575), 576"opt_level" : attr . string_dict ( 577doc = "Rustc optimization levels." , 578default = { 579"dbg" : "0" , 580"fastbuild" : "0" , 581"opt" : "3" , 582}, 583), 584"os" : attr . string ( 585doc = "The operating system for the current toolchain" , 586mandatory = True , 587), 588"rust_doc" : attr . label ( 589doc = "The location of the `rustdoc` binary. Can be a direct source or a filegroup containing one item." , 590allow_single_file = True , 591cfg = "exec" , 592mandatory = True , 593), 594"rust_lib" : attr . label ( 595doc = "**Deprecated**: Use `rust_std`" , 596), 597"rust_std" : attr . label ( 598doc = "The Rust standard library." , 599), 600"rustc" : attr . label ( 601doc = "The location of the `rustc` binary. Can be a direct source or a filegroup containing one item." , 602allow_single_file = True , 603cfg = "exec" , 604mandatory = True , 605), 606"rustc_lib" : attr . label ( 607doc = "The libraries used by rustc during compilation." , 608cfg = "exec" , 609), 610"rustc_srcs" : attr . label ( 611doc = "The source code of rustc." , 612), 613"rustfmt" : attr . label ( 614doc = "The location of the `rustfmt` binary. Can be a direct source or a filegroup containing one item." , 615allow_single_file = True , 616cfg = "exec" , 617), 618"staticlib_ext" : attr . string ( 619doc = "The extension for static libraries created from rustc." , 620mandatory = True , 621), 622"stdlib_linkflags" : attr . string_list ( 623doc = ( 624"Additional linker flags to use when Rust standard library is linked by a C++ linker " + 625"(rustc will deal with these automatically). Subject to location expansion with respect " + 626"to the srcs of the `rust_std` attribute." 627), 628mandatory = True , 629), 630"target_json" : attr . label ( 631doc = ( "Override the target_triple with a custom target specification. " + 632"For more details see: https://doc.rust-lang.org/rustc/targets/custom.html" ), 633allow_single_file = True , 634), 635"target_triple" : attr . string ( 636doc = ( 637"The platform triple for the toolchains target environment. " + 638"For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations" 639), 640), 641"_cc_toolchain" : attr . label ( 642default = "@bazel_tools//tools/cpp:current_cc_toolchain" , 643), 644"_rename_first_party_crates" : attr . label ( 645default = "@rules_rust//rust/settings:rename_first_party_crates" , 646), 647"_third_party_dir" : attr . label ( 648default = "@rules_rust//rust/settings:third_party_dir" , 649), 650}, 651toolchains = [ 652"@bazel_tools//tools/cpp:toolchain_type" , 653], 654incompatible_use_toolchain_transition = True , 655doc = """Declares a Rust toolchain for use. 656 657This is for declaring a custom toolchain, eg. for configuring a particular version of rust or supporting a new platform. 658 659Example: 660 661Suppose the core rust team has ported the compiler to a new target CPU, called `cpuX`. This \ 662support can be used in Bazel by defining a new toolchain definition and declaration: 663 664```python 665load('@rules_rust//rust:toolchain.bzl', 'rust_toolchain') 666 667rust_toolchain( 668name = "rust_cpuX_impl", 669rustc = "@rust_cpuX//:rustc", 670rustc_lib = "@rust_cpuX//:rustc_lib", 671rust_std = "@rust_cpuX//:rust_std", 672rust_doc = "@rust_cpuX//:rustdoc", 673binary_ext = "", 674staticlib_ext = ".a", 675dylib_ext = ".so", 676stdlib_linkflags = ["-lpthread", "-ldl"], 677os = "linux", 678) 679 680toolchain( 681name = "rust_cpuX", 682exec_compatible_with = [ 683"@platforms//cpu:cpuX", 684], 685target_compatible_with = [ 686"@platforms//cpu:cpuX", 687], 688toolchain = ":rust_cpuX_impl", 689) 690``` 691 692Then, either add the label of the toolchain rule to `register_toolchains` in the WORKSPACE, or pass \ 693it to the `"--extra_toolchains"` flag for Bazel, and it will be used. 694 695See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX repository \ 696with the actual binaries and libraries. 697""" , 698)