diff options
| author | Henry Jiang <henry.jiang1@ibm.com> | 2024-11-25 11:15:50 -0500 |
|---|---|---|
| committer | Henry Jiang <henry.jiang1@ibm.com> | 2024-11-25 11:15:50 -0500 |
| commit | 9f1cfec299a1060bdd8382d3e6a6ebd8dc64d3ab (patch) | |
| tree | dd80cb429b9ea3d76de86a9f474b2fa16752af2b /src/bootstrap | |
| parent | 7db7489f9bc274cb60c4956bfa56de0185eb1b9b (diff) | |
| download | rust-9f1cfec299a1060bdd8382d3e6a6ebd8dc64d3ab.tar.gz rust-9f1cfec299a1060bdd8382d3e6a6ebd8dc64d3ab.zip | |
use ReadCache for archive loading
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/helpers.rs | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 1aa49fa39ff..fcd97b7b589 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -47,7 +47,7 @@ fd-lock = "4.0" home = "0.5" ignore = "0.4" libc = "0.2" -object = { version = "0.36.3", default-features = false, features = ["archive", "coff", "read_core", "unaligned"] } +object = { version = "0.36.3", default-features = false, features = ["archive", "coff", "read_core", "std", "unaligned"] } opener = "0.5" semver = "1.0" serde = "1.0" diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 9ca036a2afd..079213e8c3d 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -61,18 +61,18 @@ pub fn is_dylib(path: &Path) -> bool { } fn is_aix_shared_archive(path: &Path) -> bool { - // FIXME(#133268): reading the entire file as &[u8] into memory seems excessive - // look into either mmap it or use the ReadCache - let data = match fs::read(path) { - Ok(data) => data, + let file = match fs::File::open(path) { + Ok(file) => file, Err(_) => return false, }; - let file = match ArchiveFile::parse(&*data) { - Ok(file) => file, + let reader = object::ReadCache::new(file); + let archive = match ArchiveFile::parse(&reader) { + Ok(result) => result, Err(_) => return false, }; - file.members() + archive + .members() .filter_map(Result::ok) .any(|entry| String::from_utf8_lossy(entry.name()).contains(".so")) } |
