Bootstrap: Add argument for building llvm bitcode linker

This commit is contained in:
Kjetil Kjeka 2024-02-06 20:09:55 +01:00
parent 43f2055af5
commit 6a50d059a5
10 changed files with 34 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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`

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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);

View File

@ -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<String>,
pub llvm_cxxflags: Option<String>,
@ -1099,6 +1100,7 @@ struct Rust {
dist_src: Option<bool> = "dist-src",
save_toolstates: Option<String> = "save-toolstates",
codegen_backends: Option<Vec<String>> = "codegen-backends",
llvm_bitcode_linker: Option<bool> = "llvm-bitcode-linker",
lld: Option<bool> = "lld",
lld_mode: Option<LldMode> = "use-lld",
llvm_tools: Option<bool> = "llvm-tools",
@ -1571,6 +1573,7 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
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<TomlConfig, toml::de::Error> {
}
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

View File

@ -146,4 +146,9 @@ pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
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.",
},
];

View File

@ -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 \