Skip to content

Commit 8461632

Browse files
committed
address comments
1 parent fd921f8 commit 8461632

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,10 @@ fn link_natively(
778778
let (linker_path, flavor) = linker_and_flavor(sess);
779779
let self_contained_components = self_contained_components(sess, crate_type);
780780

781+
// On AIX, we ship all libraries as .a big_af archive
782+
// the expected format is lib<name>.a(libname.so) for the actual
783+
// dynamic library. So we link to a temporary .so file to be archived
784+
// at the final out_filename location
781785
let should_archive = crate_type != CrateType::Executable && sess.target.is_like_aix;
782786
let archive_member =
783787
should_archive.then(|| tmpdir.join(out_filename.file_name().unwrap()).with_extension("so"));

compiler/rustc_metadata/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9+
libc = "0.2"
910
libloading = "0.8.0"
1011
odht = { version = "0.3.1", features = ["nightly"] }
1112
rustc_abi = { path = "../rustc_abi" }

compiler/rustc_metadata/src/creader.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::error::Error;
44
use std::ops::Fn;
55
use std::path::Path;
6+
use std::ffi::OsString;
67
use std::str::FromStr;
78
use std::time::Duration;
89
use std::{cmp, env, iter};
@@ -1178,9 +1179,7 @@ fn attempt_load_dylib(path: &Path) -> Result<libloading::Library, libloading::Er
11781179
let new_path = path.with_extension(archive_member);
11791180

11801181
// On AIX, we need RTLD_MEMBER to dlopen an archived shared
1181-
// flags = RTLD_LAZY | RTLD_LOCAL | RTLD_MEMBER
1182-
// these are not yet in libc https://github.com/rust-lang/libc/pull/4044
1183-
let flags = 0x4 | 0x80000 | 0x40000;
1182+
let flags = libc::RTLD_LAZY | libc::RTLD_LOCAL | libc::RTLD_MEMBER;
11841183
return unsafe { libloading::os::unix::Library::open(Some(&new_path), flags) }
11851184
.map(|lib| lib.into());
11861185
}

src/bootstrap/src/utils/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ pub fn is_dylib(path: &Path) -> bool {
6161
}
6262

6363
fn is_aix_shared_archive(path: &Path) -> bool {
64-
// todo: reading the entire file as &[u8] into memory seems excessive
65-
// look into either mmap it or use the &CacheReader
64+
// FIXME(#133268): reading the entire file as &[u8] into memory seems excessive
65+
// look into either mmap it or use the ReadCache
6666
let data = match fs::read(path) {
6767
Ok(data) => data,
6868
Err(_) => return false,

0 commit comments

Comments
 (0)