Skip to content

Commit 11381a5

Browse files
Yannick Koehlerskrap
Yannick Koehler
andcommitted
Add new target armv7-unknown-linux-uclibceabihf
Co-authored-by: Jonah Petri <[email protected]>
1 parent d7539a6 commit 11381a5

File tree

9 files changed

+37
-6
lines changed

9 files changed

+37
-6
lines changed

compiler/rustc_codegen_llvm/src/callee.rs

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
176176
if cx.use_dll_storage_attrs
177177
&& tcx.is_dllimport_foreign_item(instance_def_id)
178178
&& tcx.sess.target.env != "gnu"
179+
&& tcx.sess.target.env != "uclibc"
179180
{
180181
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
181182
}

compiler/rustc_middle/src/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
30093009
};
30103010

30113011
let target = &self.tcx.sess.target;
3012-
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl");
3012+
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl" | "uclibc");
30133013
let win_x64_gnu = target.os == "windows" && target.arch == "x86_64" && target.env == "gnu";
30143014
let linux_s390x_gnu_like =
30153015
target.os == "linux" && target.arch == "s390x" && target_env_gnu_like;
@@ -3107,7 +3107,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
31073107
if arg.layout.is_zst() {
31083108
// For some forsaken reason, x86_64-pc-windows-gnu
31093109
// doesn't ignore zero-sized struct arguments.
3110-
// The same is true for {s390x,sparc64,powerpc}-unknown-linux-{gnu,musl}.
3110+
// The same is true for {s390x,sparc64,powerpc}-unknown-linux-{gnu,musl,uclibc}.
31113111
if is_return
31123112
|| rust_abi
31133113
|| (!win_x64_gnu
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::spec::{Target, TargetOptions};
2+
3+
// This target is for uclibc Linux on ARMv7 without NEON or
4+
// thumb-mode. See the thumbv7neon variant for enabling both.
5+
6+
pub fn target() -> Target {
7+
let base = super::linux_uclibc_base::opts();
8+
Target {
9+
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
10+
pointer_width: 32,
11+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
12+
arch: "arm".to_string(),
13+
14+
options: TargetOptions {
15+
// Info about features at https://wiki.debian.org/ArmHardFloatPort
16+
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
17+
cpu: "generic".to_string(),
18+
max_atomic_width: Some(64),
19+
mcount: "_mcount".to_string(),
20+
..base
21+
},
22+
}
23+
}

compiler/rustc_target/src/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ supported_targets! {
952952
("bpfel-unknown-none", bpfel_unknown_none),
953953

954954
("armv6k-nintendo-3ds", armv6k_nintendo_3ds),
955+
956+
("armv7-unknown-linux-uclibceabihf", armv7_unknown_linux_uclibceabihf),
955957
}
956958

957959
/// Warnings encountered when parsing the target `json`.

library/std/src/sys/unix/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ cfg_if::cfg_if! {
307307
#[link(name = "zircon")]
308308
#[link(name = "fdio")]
309309
extern "C" {}
310+
} else if #[cfg(all(target_os = "linux", target_env = "uclibc"))] {
311+
#[link(name = "dl")]
312+
extern "C" {}
310313
}
311314
}
312315

library/std/src/sys/unix/process/process_unix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl Command {
419419
}
420420

421421
// Only glibc 2.24+ posix_spawn() supports returning ENOENT directly.
422-
#[cfg(all(target_os = "linux", target_env = "gnu"))]
422+
#[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]
423423
{
424424
if let Some(version) = sys::os::glibc_version() {
425425
if version < (2, 24) {

library/std/src/sys/unix/thread.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ pub mod guard {
594594
Some(stackaddr - guardsize..stackaddr)
595595
} else if cfg!(all(target_os = "linux", target_env = "musl")) {
596596
Some(stackaddr - guardsize..stackaddr)
597-
} else if cfg!(all(target_os = "linux", target_env = "gnu")) {
597+
} else if cfg!(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))
598+
{
598599
// glibc used to include the guard area within the stack, as noted in the BUGS
599600
// section of `man pthread_attr_getguardsize`. This has been corrected starting
600601
// with glibc 2.27, and in some distro backports, so the guard is now placed at the

library/unwind/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cfg_if::cfg_if! {
6363
// don't want to duplicate it here.
6464
#[cfg(all(
6565
target_os = "linux",
66-
target_env = "gnu",
66+
any(target_env = "gnu", target_env = "uclibc"),
6767
not(feature = "llvm-libunwind"),
6868
not(feature = "system-llvm-libunwind")
6969
))]
@@ -72,7 +72,7 @@ extern "C" {}
7272

7373
#[cfg(all(
7474
target_os = "linux",
75-
target_env = "gnu",
75+
any(target_env = "gnu", target_env = "uclibc"),
7676
not(feature = "llvm-libunwind"),
7777
feature = "system-llvm-libunwind"
7878
))]

src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ target | std | host | notes
220220
`armv6-unknown-netbsd-eabihf` | ? | |
221221
`armv6k-nintendo-3ds` | * | | ARMv6K Nintendo 3DS, Horizon (Requires devkitARM toolchain)
222222
`armv7-apple-ios` | ✓ | | ARMv7 iOS, Cortex-a8
223+
`armv7-unknown-linux-uclibceabihf` | ✓ | ? | ARMv7 Linux uClibc
223224
`armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD
224225
`armv7-unknown-netbsd-eabihf` | ✓ | ✓ |
225226
`armv7-wrs-vxworks-eabihf` | ? | |

0 commit comments

Comments
 (0)