Skip to content

Commit c543f7d

Browse files
authored
Rollup merge of #93864 - bjorn3:cleanup_archive_handling, r=petrochenkov
Remove ArchiveBuilder::update_symbols All paths to an ArchiveBuilder::build call update_symbols first.
2 parents 219fc8f + 6097847 commit c543f7d

File tree

5 files changed

+2
-29
lines changed

5 files changed

+2
-29
lines changed

compiler/rustc_codegen_cranelift/src/archive.rs

-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
105105
Ok(())
106106
}
107107

108-
fn update_symbols(&mut self) {}
109-
110108
fn build(mut self) {
111109
enum BuilderKind {
112110
Bsd(ar::Builder<File>),

compiler/rustc_codegen_gcc/src/archive.rs

-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
113113
Ok(())
114114
}
115115

116-
fn update_symbols(&mut self) {
117-
}
118-
119116
fn build(mut self) {
120117
use std::process::Command;
121118

compiler/rustc_codegen_llvm/src/back/archive.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub struct LlvmArchiveBuilder<'a> {
2727
config: ArchiveConfig<'a>,
2828
removals: Vec<String>,
2929
additions: Vec<Addition>,
30-
should_update_symbols: bool,
3130
src_archive: Option<Option<ArchiveRO>>,
3231
}
3332

@@ -75,7 +74,6 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
7574
config,
7675
removals: Vec::new(),
7776
additions: Vec::new(),
78-
should_update_symbols: false,
7977
src_archive: None,
8078
}
8179
}
@@ -129,12 +127,6 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
129127
.push(Addition::File { path: file.to_path_buf(), name_in_archive: name.to_owned() });
130128
}
131129

132-
/// Indicate that the next call to `build` should update all symbols in
133-
/// the archive (equivalent to running 'ar s' over it).
134-
fn update_symbols(&mut self) {
135-
self.should_update_symbols = true;
136-
}
137-
138130
/// Combine the provided files, rlibs, and native libraries into a single
139131
/// `Archive`.
140132
fn build(mut self) {
@@ -313,7 +305,6 @@ impl<'a> LlvmArchiveBuilder<'a> {
313305
let mut members = Vec::new();
314306

315307
let dst = CString::new(self.config.dst.to_str().unwrap())?;
316-
let should_update_symbols = self.should_update_symbols;
317308

318309
unsafe {
319310
if let Some(archive) = self.src_archive() {
@@ -385,7 +376,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
385376
dst.as_ptr(),
386377
members.len() as libc::size_t,
387378
members.as_ptr() as *const &_,
388-
should_update_symbols,
379+
true,
389380
kind,
390381
);
391382
let ret = if r.into_result().is_err() {

compiler/rustc_codegen_ssa/src/back/archive.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub trait ArchiveBuilder<'a> {
5151
fn add_archive<F>(&mut self, archive: &Path, skip: F) -> io::Result<()>
5252
where
5353
F: FnMut(&str) -> bool + 'static;
54-
fn update_symbols(&mut self);
5554

5655
fn build(self);
5756

compiler/rustc_codegen_ssa/src/back/link.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,6 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
333333
ab.inject_dll_import_lib(&raw_dylib_name, &raw_dylib_imports, tmpdir);
334334
}
335335

336-
// After adding all files to the archive, we need to update the
337-
// symbol table of the archive.
338-
ab.update_symbols();
339-
340336
// Note that it is important that we add all of our non-object "magical
341337
// files" *after* all of the object files in the archive. The reason for
342338
// this is as follows:
@@ -365,13 +361,6 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
365361
// normal linkers for the platform.
366362
let metadata = create_rmeta_file(sess, codegen_results.metadata.raw_data());
367363
ab.add_file(&emit_metadata(sess, &metadata, tmpdir));
368-
369-
// After adding all files to the archive, we need to update the
370-
// symbol table of the archive. This currently dies on macOS (see
371-
// #11162), and isn't necessary there anyway
372-
if !sess.target.is_like_osx {
373-
ab.update_symbols();
374-
}
375364
}
376365

377366
RlibFlavor::StaticlibBase => {
@@ -381,6 +370,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
381370
}
382371
}
383372
}
373+
384374
return Ok(ab);
385375
}
386376

@@ -509,7 +499,6 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
509499
sess.fatal(&e);
510500
}
511501

512-
ab.update_symbols();
513502
ab.build();
514503

515504
if !all_native_libs.is_empty() {
@@ -2310,7 +2299,6 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
23102299

23112300
sess.prof.generic_activity_with_arg("link_altering_rlib", name).run(|| {
23122301
let mut archive = <B as ArchiveBuilder>::new(sess, &dst, Some(cratepath));
2313-
archive.update_symbols();
23142302

23152303
let mut any_objects = false;
23162304
for f in archive.src_files() {

0 commit comments

Comments
 (0)