mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
fix nix problem ld-linux-aarch64.so.1 (#7655)
* fix nix problem linux aarch64 * more reliable rust install Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * fix copy paste Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --------- Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
This commit is contained in:
parent
12a635d0d3
commit
8c87280ea7
2 changed files with 57 additions and 18 deletions
44
crates/compiler/build/src/link.rs
Normal file → Executable file
44
crates/compiler/build/src/link.rs
Normal file → Executable file
|
@ -752,11 +752,9 @@ fn nix_glibc_path_opt() -> Option<OsString> {
|
|||
env::var_os("NIX_GLIBC_PATH")
|
||||
}
|
||||
|
||||
fn build_path_or_panic<const N: usize>(segments: [&str; N]) -> PathBuf {
|
||||
let mut guess_path = PathBuf::new();
|
||||
for s in segments {
|
||||
guess_path.push(s);
|
||||
}
|
||||
fn check_path_or_panic(path_str: &str) -> PathBuf {
|
||||
let guess_path = PathBuf::from(path_str);
|
||||
|
||||
if guess_path.exists() {
|
||||
guess_path
|
||||
} else {
|
||||
|
@ -911,26 +909,40 @@ fn link_linux(
|
|||
scrt1_path.to_string_lossy(),
|
||||
);
|
||||
|
||||
fn get_ld_linux_path(
|
||||
nix_glibc_path_opt: Option<OsString>,
|
||||
native_lib_path: &str,
|
||||
ld_file_name: &str,
|
||||
) -> String {
|
||||
let mut full_path_str = String::new();
|
||||
|
||||
if let Some(nix_glibc_path) = nix_glibc_path_opt {
|
||||
full_path_str.push_str(&nix_glibc_path.to_string_lossy())
|
||||
} else {
|
||||
full_path_str.push_str(native_lib_path)
|
||||
};
|
||||
|
||||
full_path_str.push('/');
|
||||
full_path_str.push_str(ld_file_name);
|
||||
|
||||
check_path_or_panic(&full_path_str);
|
||||
full_path_str.to_string()
|
||||
}
|
||||
|
||||
let ld_linux_path = match target.architecture() {
|
||||
Architecture::X86_64 => {
|
||||
// give preference to nix_path if it's defined, this prevents bugs
|
||||
if let Some(nix_glibc_path) = nix_glibc_path_opt() {
|
||||
build_path_or_panic([
|
||||
&nix_glibc_path.into_string().unwrap(),
|
||||
"ld-linux-x86-64.so.2",
|
||||
])
|
||||
} else {
|
||||
build_path_or_panic(["/lib64", "ld-linux-x86-64.so.2"])
|
||||
}
|
||||
get_ld_linux_path(nix_glibc_path_opt(), "/lib64", "ld-linux-x86-64.so.2")
|
||||
}
|
||||
Architecture::Aarch64 => {
|
||||
get_ld_linux_path(nix_glibc_path_opt(), "/lib", "ld-linux-aarch64.so.1")
|
||||
}
|
||||
Architecture::Aarch64 => build_path_or_panic(["/lib", "ld-linux-aarch64.so.1"]),
|
||||
_ => internal_error!(
|
||||
"TODO gracefully handle unsupported linux architecture: {:?}",
|
||||
target.architecture()
|
||||
),
|
||||
};
|
||||
|
||||
let ld_linux_path_str = &ld_linux_path.to_string_lossy();
|
||||
let ld_linux_path_str = &ld_linux_path;
|
||||
|
||||
let (base_args, output_path) = match link_type {
|
||||
LinkType::Executable => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue