8000 When running a 32-bit rustup on an aarch64 CPU, select a 32-bit toolchain by alex · Pull Request #3490 · rust-lang/rustup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

When running a 32-bit rustup on an aarch64 CPU, select a 32-bit toolchain #3490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/dist/dist.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::collections::HashSet;
use std::env;
use std::fmt;
use std::io::Write;
use std::fs;
use std::io::{self, Read, Write};
use std::ops::Deref;
use std::path::Path;
use std::str::FromStr;
Expand Down Expand Up @@ -219,6 +220,26 @@ impl Deref for TargetTriple {
}
}

fn is_32bit_userspace() -> bool {
// Check if /bin/sh is a 32-bit binary. If it doesn't exist, fall back to
// checking if _we_ are a 32-bit binary.
// rustup-init.sh also relies on checking /bin/sh for bitness.

// inner function is to simplify error handling.
fn inner() -> io::Result<bool> {
let mut f = fs::File::open("/bin/sh")?;
let mut buf = [0; 5];
f.read_exact(&mut buf)?;

// ELF files start out "\x7fELF", and the following byte is
// 0x01 for 32-bit and
// 0x02 for 64-bit.
Ok(&buf == b"\x7fELF\x01")
}

inner().unwrap_or(cfg!(target_pointer_width = "32"))
}

impl TargetTriple {
pub fn new(name: &str) -> Self {
Self(name.to_string())
Expand Down Expand Up @@ -346,7 +367,11 @@ impl TargetTriple {
(b"Linux", b"arm") => Some("arm-unknown-linux-gnueabi"),
(b"Linux", b"armv7l") => Some("armv7-unknown-linux-gnueabihf"),
(b"Linux", b"armv8l") => Some("armv7-unknown-linux-gnueabihf"),
(b"Linux", b"aarch64") => Some(TRIPLE_AARCH64_UNKNOWN_LINUX),
(b"Linux", b"aarch64") => Some(if is_32bit_userspace() {
"armv7-unknown-linux-gnueabihf"
} else {
TRIPLE_AARCH64_UNKNOWN_LINUX
}),
(b"Darwin", b"x86_64") => Some("x86_64-apple-darwin"),
(b"Darwin", b"i686") => Some("i686-apple-darwin"),
(b"FreeBSD", b"x86_64") => Some("x86_64-unknown-freebsd"),
Expand Down
0