Skip to content

Commit 10e5530

Browse files
author
Kjetil Kjeka
committed
Bootstrap: Add argument for building embedded linker
1 parent 8cdde02 commit 10e5530

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

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("embedded-linker", "rust.embedded-linker", "build embedded linker")
5758
o("clang", "llvm.clang", "build clang")
5859
o("missing-tools", "dist.missing-tools", "allow failures when building tools")
5960
o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++")
@@ -365,6 +366,7 @@ def apply_args(known_args, option_checking, config):
365366
set('rust.codegen-backends', ['llvm'], config)
366367
set('rust.lld', True, config)
367368
set('rust.llvm-tools', True, config)
369+
set('rust.embedded-linker', True, config)
368370
set('build.extended', True, config)
369371
elif option.name in ['option-checking', 'verbose-configure']:
370372
# this was handled above

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

+12
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,18 @@ impl Step for Assemble {
17221722
}
17231723
}
17241724

1725+
if builder.config.embedded_linker_enabled {
1726+
let src_path = builder
1727+
.ensure(crate::core::build_steps::tool::EmbeddedLinker {
1728+
compiler: build_compiler,
1729+
target: target_compiler.host,
1730+
extra_features: vec![],
1731+
})
1732+
.unwrap();
1733+
let tool_exe = exe("rust-embedded-linker", target_compiler.host);
1734+
builder.copy(&src_path, &libdir_bin.join(&tool_exe));
1735+
}
1736+
17251737
// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
17261738
// so that it can be found when the newly built `rustc` is run.
17271739
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
@@ -199,6 +199,7 @@ pub struct Config {
199199
pub use_lld: bool,
200200
pub lld_enabled: bool,
201201
pub llvm_tools_enabled: bool,
202+
pub embedded_linker_enabled: bool,
202203

203204
pub llvm_cflags: Option<String>,
204205
pub llvm_cxxflags: Option<String>,
@@ -1004,6 +1005,7 @@ define_config! {
10041005
dist_src: Option<bool> = "dist-src",
10051006
save_toolstates: Option<String> = "save-toolstates",
10061007
codegen_backends: Option<Vec<String>> = "codegen-backends",
1008+
embedded_linker: Option<bool> = "embedded-linker",
10071009
lld: Option<bool> = "lld",
10081010
use_lld: Option<bool> = "use-lld",
10091011
llvm_tools: Option<bool> = "llvm-tools",
@@ -1339,6 +1341,7 @@ impl Config {
13391341
set(&mut config.local_rebuild, build.local_rebuild);
13401342
set(&mut config.print_step_timings, build.print_step_timings);
13411343
set(&mut config.print_step_rusage, build.print_step_rusage);
1344+
set(&mut config.embedded_linker_enabled, Some(true));
13421345
config.patch_binaries_for_nix = build.patch_binaries_for_nix;
13431346

13441347
config.verbose = cmp::max(config.verbose, flags.verbose as usize);
@@ -1429,6 +1432,7 @@ impl Config {
14291432
set(&mut config.use_lld, rust.use_lld);
14301433
set(&mut config.lld_enabled, rust.lld);
14311434
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
1435+
set(&mut config.embedded_linker_enabled, rust.embedded_linker);
14321436
config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
14331437
config.rustc_default_linker = rust.default_linker;
14341438
config.musl_root = rust.musl_root.map(PathBuf::from);

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

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

143-
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
143+
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enabled-embedded-linker --disable-docs \
144144
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
145145
--set target.wasm32-wasi-preview1-threads.wasi-root=/wasm32-wasi-preview1-threads \
146146
--musl-root-armv7=/musl-armv7

0 commit comments

Comments
 (0)