1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(bool_to_option)]
#![feature(const_panic)]
#![feature(nll)]
#![feature(never_type)]
#![feature(associated_type_bounds)]
#![feature(exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(trusted_step)]
use std::path::{Path, PathBuf};
#[macro_use]
extern crate rustc_macros;
#[macro_use]
extern crate tracing;
pub mod abi;
pub mod asm;
pub mod spec;
pub trait HashStableContext {}
const RUST_LIB_DIR: &str = "rustlib";
pub fn target_rustlib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
let libdir = find_libdir(sysroot);
std::array::IntoIter::new([
Path::new(libdir.as_ref()),
Path::new(RUST_LIB_DIR),
Path::new(target_triple),
])
.collect::<PathBuf>()
}
fn find_libdir(sysroot: &Path) -> std::borrow::Cow<'static, str> {
#[cfg(target_pointer_width = "64")]
const PRIMARY_LIB_DIR: &str = "lib64";
#[cfg(target_pointer_width = "32")]
const PRIMARY_LIB_DIR: &str = "lib32";
const SECONDARY_LIB_DIR: &str = "lib";
match option_env!("CFG_LIBDIR_RELATIVE") {
None | Some("lib") => {
if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
PRIMARY_LIB_DIR.into()
} else {
SECONDARY_LIB_DIR.into()
}
}
Some(libdir) => libdir.into(),
}
}