Auto merge of #125463 - GuillaumeGomez:rollup-287wx4y, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #125263 (rust-lld: fallback to rustc's sysroot if there's no path to the linker in the target sysroot) - #125345 (rustc_codegen_llvm: add support for writing summary bitcode) - #125362 (Actually use TAIT instead of emulating it) - #125412 (Don't suggest adding the unexpected cfgs to the build-script it-self) - #125445 (Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs`) - #125452 (Cleanup check-cfg handling in core and std) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
@@ -3141,13 +3141,21 @@ fn add_lld_args(
|
||||
|
||||
let self_contained_linker = self_contained_cli || self_contained_target;
|
||||
if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() {
|
||||
let mut linker_path_exists = false;
|
||||
for path in sess.get_tools_search_paths(false) {
|
||||
let linker_path = path.join("gcc-ld");
|
||||
linker_path_exists |= linker_path.exists();
|
||||
cmd.arg({
|
||||
let mut arg = OsString::from("-B");
|
||||
arg.push(path.join("gcc-ld"));
|
||||
arg.push(linker_path);
|
||||
arg
|
||||
});
|
||||
}
|
||||
if !linker_path_exists {
|
||||
// As a sanity check, we emit an error if none of these paths exist: we want
|
||||
// self-contained linking and have no linker.
|
||||
sess.dcx().emit_fatal(errors::SelfContainedLinkerMissing);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Implement the "linker flavor" part of this feature by asking `cc` to use some kind of
|
||||
|
||||
@@ -108,6 +108,7 @@ pub struct ModuleConfig {
|
||||
pub emit_asm: bool,
|
||||
pub emit_obj: EmitObj,
|
||||
pub emit_thin_lto: bool,
|
||||
pub emit_thin_lto_summary: bool,
|
||||
pub bc_cmdline: String,
|
||||
|
||||
// Miscellaneous flags. These are mostly copied from command-line
|
||||
@@ -232,6 +233,10 @@ impl ModuleConfig {
|
||||
),
|
||||
emit_obj,
|
||||
emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto,
|
||||
emit_thin_lto_summary: if_regular!(
|
||||
sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode),
|
||||
false
|
||||
),
|
||||
bc_cmdline: sess.target.bitcode_llvm_cmdline.to_string(),
|
||||
|
||||
verify_llvm_ir: sess.verify_llvm_ir(),
|
||||
@@ -283,6 +288,7 @@ impl ModuleConfig {
|
||||
|
||||
pub fn bitcode_needed(&self) -> bool {
|
||||
self.emit_bc
|
||||
|| self.emit_thin_lto_summary
|
||||
|| self.emit_obj == EmitObj::Bitcode
|
||||
|| self.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full)
|
||||
}
|
||||
@@ -630,6 +636,9 @@ fn produce_final_output_artifacts(
|
||||
// them for making an rlib.
|
||||
copy_if_one_unit(OutputType::Bitcode, true);
|
||||
}
|
||||
OutputType::ThinLinkBitcode => {
|
||||
copy_if_one_unit(OutputType::ThinLinkBitcode, false);
|
||||
}
|
||||
OutputType::LlvmAssembly => {
|
||||
copy_if_one_unit(OutputType::LlvmAssembly, false);
|
||||
}
|
||||
@@ -883,7 +892,7 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
|
||||
match lto_type {
|
||||
ComputedLtoType::No => finish_intra_module_work(cgcx, module, module_config),
|
||||
ComputedLtoType::Thin => {
|
||||
let (name, thin_buffer) = B::prepare_thin(module);
|
||||
let (name, thin_buffer) = B::prepare_thin(module, false);
|
||||
if let Some(path) = bitcode {
|
||||
fs::write(&path, thin_buffer.data()).unwrap_or_else(|e| {
|
||||
panic!("Error writing pre-lto-bitcode file `{}`: {}", path.display(), e);
|
||||
|
||||
Reference in New Issue
Block a user