Skip to content

Commit 6a50d05

Browse files
author
Kjetil Kjeka
committed
Bootstrap: Add argument for building llvm bitcode linker
1 parent 43f2055 commit 6a50d05

File tree

10 files changed

+34
-1
lines changed

10 files changed

+34
-1
lines changed

config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,10 @@
679679
# sysroot.
680680
#llvm-tools = true
681681

682+
# Indicates whether the `self-contained` llvm-bitcode-linker, will be made available
683+
# in the sysroot
684+
#llvm-bitcode-linker = false
685+
682686
# Whether to deny warnings in crates
683687
#deny-warnings = true
684688

src/bootstrap/configure.py

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def v(*args):
5454
o("profiler", "build.profiler", "build the profiler runtime")
5555
o("full-tools", None, "enable all tools")
5656
o("lld", "rust.lld", "build lld")
57+
o("llvm-bitcode-linker", "rust.llvm-bitcode-linker", "build llvm bitcode linker")
5758
o("clang", "llvm.clang", "build clang")
5859
o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++")
5960
o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard")
@@ -366,6 +367,7 @@ def apply_args(known_args, option_checking, config):
366367
set('rust.codegen-backends', ['llvm'], config)
367368
set('rust.lld', True, config)
368369
set('rust.llvm-tools', True, config)
370+
set('rust.llvm-bitcode-linker', True, config)
369371
set('build.extended', True, config)
370372
elif option.name in ['option-checking', 'verbose-configure']:
371373
# this was handled above

src/bootstrap/defaults/config.compiler.toml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ lto = "off"
1717
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
1818
# This can be helpful for profiling at a small performance cost.
1919
frame-pointers = true
20+
# Build the llvm-bitcode-linker as it is required for running nvptx tests
21+
llvm-bitcode-linker = true
2022

2123
[llvm]
2224
# Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true`

src/bootstrap/defaults/config.dist.toml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ download-ci-llvm = false
1616
# Make sure they don't get set when installing from source.
1717
channel = "nightly"
1818
download-rustc = false
19+
# Build the llvm-bitcode-linker as it is required for running nvptx tests
20+
llvm-bitcode-linker = true
1921

2022
[dist]
2123
# Use better compression when preparing tarballs.

src/bootstrap/defaults/config.library.toml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ bench-stage = 0
1010
incremental = true
1111
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
1212
lto = "off"
13+
# Build the llvm-bitcode-linker as it is required for running nvptx tests
14+
llvm-bitcode-linker = true
1315

1416
[llvm]
1517
# Will download LLVM from CI if available on your platform.

src/bootstrap/defaults/config.tools.toml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ incremental = true
1212
# Using these defaults will download the stage2 compiler (see `download-rustc`
1313
# setting) and the stage2 toolchain should therefore be used for these defaults.
1414
download-rustc = "if-unchanged"
15+
# Build the llvm-bitcode-linker as it is required for running nvptx tests
16+
llvm-bitcode-linker = true
1517

1618
[build]
1719
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.

src/bootstrap/src/core/build_steps/compile.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,16 @@ impl Step for Assemble {
18431843
}
18441844
}
18451845

1846+
if builder.config.llvm_bitcode_linker_enabled {
1847+
let src_path = builder.ensure(crate::core::build_steps::tool::LlvmBitcodeLinker {
1848+
compiler: build_compiler,
1849+
target: target_compiler.host,
1850+
extra_features: vec![],
1851+
});
1852+
let tool_exe = exe("llvm-bitcode-linker", target_compiler.host);
1853+
builder.copy(&src_path, &libdir_bin.join(&tool_exe));
1854+
}
1855+
18461856
// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
18471857
// so that it can be found when the newly built `rustc` is run.
18481858
dist::maybe_install_llvm_runtime(builder, target_compiler.host, &sysroot);

src/bootstrap/src/core/config/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ pub struct Config {
236236
pub lld_mode: LldMode,
237237
pub lld_enabled: bool,
238238
pub llvm_tools_enabled: bool,
239+
pub llvm_bitcode_linker_enabled: bool,
239240

240241
pub llvm_cflags: Option<String>,
241242
pub llvm_cxxflags: Option<String>,
@@ -1099,6 +1100,7 @@ define_config! {
10991100
dist_src: Option<bool> = "dist-src",
11001101
save_toolstates: Option<String> = "save-toolstates",
11011102
codegen_backends: Option<Vec<String>> = "codegen-backends",
1103+
llvm_bitcode_linker: Option<bool> = "llvm-bitcode-linker",
11021104
lld: Option<bool> = "lld",
11031105
lld_mode: Option<LldMode> = "use-lld",
11041106
llvm_tools: Option<bool> = "llvm-tools",
@@ -1571,6 +1573,7 @@ impl Config {
15711573
codegen_backends,
15721574
lld,
15731575
llvm_tools,
1576+
llvm_bitcode_linker,
15741577
deny_warnings,
15751578
backtrace_on_ice,
15761579
verify_llvm_ir,
@@ -1650,6 +1653,7 @@ impl Config {
16501653
}
16511654
set(&mut config.lld_mode, lld_mode);
16521655
set(&mut config.lld_enabled, lld);
1656+
set(&mut config.llvm_bitcode_linker_enabled, llvm_bitcode_linker);
16531657

16541658
if matches!(config.lld_mode, LldMode::SelfContained)
16551659
&& !config.lld_enabled

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
146146
severity: ChangeSeverity::Info,
147147
summary: "a new `target.*.runner` option is available to specify a wrapper executable required to run tests for a target",
148148
},
149+
ChangeInfo {
150+
change_id: 117458,
151+
severity: ChangeSeverity::Info,
152+
summary: "New option `rust.llvm-bitcode-linker` that will build the llvm-bitcode-linker.",
153+
},
149154
];

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi
135135
# Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there
136136
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm
137137

138-
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
138+
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enable-llvm-bitcode-linker --disable-docs \
139139
--set target.wasm32-wasi.wasi-root=/wasm32-wasip1 \
140140
--set target.wasm32-wasip1.wasi-root=/wasm32-wasip1 \
141141
--set target.wasm32-wasi-preview1-threads.wasi-root=/wasm32-wasi-preview1-threads \

0 commit comments

Comments
 (0)