diff --git a/config.example.toml b/config.example.toml index 4fbdccba911..ddcd0ec02e0 100644 --- a/config.example.toml +++ b/config.example.toml @@ -679,6 +679,10 @@ # sysroot. #llvm-tools = true +# Indicates whether the `self-contained` llvm-bitcode-linker, will be made available +# in the sysroot +#llvm-bitcode-linker = false + # Whether to deny warnings in crates #deny-warnings = true diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 4257c0f7991..9c43160d455 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -54,6 +54,7 @@ o("cargo-native-static", "build.cargo-native-static", "static native libraries i o("profiler", "build.profiler", "build the profiler runtime") o("full-tools", None, "enable all tools") o("lld", "rust.lld", "build lld") +o("llvm-bitcode-linker", "rust.llvm-bitcode-linker", "build llvm bitcode linker") o("clang", "llvm.clang", "build clang") o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++") o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard") @@ -366,6 +367,7 @@ def apply_args(known_args, option_checking, config): set('rust.codegen-backends', ['llvm'], config) set('rust.lld', True, config) set('rust.llvm-tools', True, config) + set('rust.llvm-bitcode-linker', True, config) set('build.extended', True, config) elif option.name in ['option-checking', 'verbose-configure']: # this was handled above diff --git a/src/bootstrap/defaults/config.compiler.toml b/src/bootstrap/defaults/config.compiler.toml index e276f126211..d93c5fd25a1 100644 --- a/src/bootstrap/defaults/config.compiler.toml +++ b/src/bootstrap/defaults/config.compiler.toml @@ -17,6 +17,8 @@ lto = "off" # Forces frame pointers to be used with `-Cforce-frame-pointers`. # This can be helpful for profiling at a small performance cost. frame-pointers = true +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [llvm] # Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true` diff --git a/src/bootstrap/defaults/config.dist.toml b/src/bootstrap/defaults/config.dist.toml index 44efdf50b96..f3c6ffc9bd5 100644 --- a/src/bootstrap/defaults/config.dist.toml +++ b/src/bootstrap/defaults/config.dist.toml @@ -16,6 +16,8 @@ download-ci-llvm = false # Make sure they don't get set when installing from source. channel = "nightly" download-rustc = false +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [dist] # Use better compression when preparing tarballs. diff --git a/src/bootstrap/defaults/config.library.toml b/src/bootstrap/defaults/config.library.toml index 087544397f5..4a1a49b7275 100644 --- a/src/bootstrap/defaults/config.library.toml +++ b/src/bootstrap/defaults/config.library.toml @@ -10,6 +10,8 @@ bench-stage = 0 incremental = true # Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown. lto = "off" +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [llvm] # Will download LLVM from CI if available on your platform. diff --git a/src/bootstrap/defaults/config.tools.toml b/src/bootstrap/defaults/config.tools.toml index 6e6c3660027..94c8b724cbf 100644 --- a/src/bootstrap/defaults/config.tools.toml +++ b/src/bootstrap/defaults/config.tools.toml @@ -12,6 +12,8 @@ incremental = true # Using these defaults will download the stage2 compiler (see `download-rustc` # setting) and the stage2 toolchain should therefore be used for these defaults. download-rustc = "if-unchanged" +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [build] # Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile. diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 6a2bff5970f..242fe3c12b9 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1843,6 +1843,16 @@ fn run(self, builder: &Builder<'_>) -> Compiler { } } + if builder.config.llvm_bitcode_linker_enabled { + let src_path = builder.ensure(crate::core::build_steps::tool::LlvmBitcodeLinker { + compiler: build_compiler, + target: target_compiler.host, + extra_features: vec![], + }); + let tool_exe = exe("llvm-bitcode-linker", target_compiler.host); + builder.copy(&src_path, &libdir_bin.join(&tool_exe)); + } + // Ensure that `libLLVM.so` ends up in the newly build compiler directory, // so that it can be found when the newly built `rustc` is run. dist::maybe_install_llvm_runtime(builder, target_compiler.host, &sysroot); diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 683e0a4302f..ae5169e9383 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -236,6 +236,7 @@ pub struct Config { pub lld_mode: LldMode, pub lld_enabled: bool, pub llvm_tools_enabled: bool, + pub llvm_bitcode_linker_enabled: bool, pub llvm_cflags: Option, pub llvm_cxxflags: Option, @@ -1099,6 +1100,7 @@ struct Rust { dist_src: Option = "dist-src", save_toolstates: Option = "save-toolstates", codegen_backends: Option> = "codegen-backends", + llvm_bitcode_linker: Option = "llvm-bitcode-linker", lld: Option = "lld", lld_mode: Option = "use-lld", llvm_tools: Option = "llvm-tools", @@ -1571,6 +1573,7 @@ fn get_table(option: &str) -> Result { codegen_backends, lld, llvm_tools, + llvm_bitcode_linker, deny_warnings, backtrace_on_ice, verify_llvm_ir, @@ -1650,6 +1653,7 @@ fn get_table(option: &str) -> Result { } set(&mut config.lld_mode, lld_mode); set(&mut config.lld_enabled, lld); + set(&mut config.llvm_bitcode_linker_enabled, llvm_bitcode_linker); if matches!(config.lld_mode, LldMode::SelfContained) && !config.lld_enabled diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index a348fa35841..85dfe45111f 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -146,4 +146,9 @@ pub fn find_recent_config_change_ids(current_id: usize) -> Vec { severity: ChangeSeverity::Info, summary: "a new `target.*.runner` option is available to specify a wrapper executable required to run tests for a target", }, + ChangeInfo { + change_id: 117458, + severity: ChangeSeverity::Info, + summary: "New option `rust.llvm-bitcode-linker` that will build the llvm-bitcode-linker.", + }, ]; diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index e90141bb9a9..abd109a6ea3 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -135,7 +135,7 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi # Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm -ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \ +ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enable-llvm-bitcode-linker --disable-docs \ --set target.wasm32-wasi.wasi-root=/wasm32-wasip1 \ --set target.wasm32-wasip1.wasi-root=/wasm32-wasip1 \ --set target.wasm32-wasi-preview1-threads.wasi-root=/wasm32-wasi-preview1-threads \