Skip to content

Commit a7095af

Browse files
Yannick Koehlerhpe-ykoehler
Yannick Koehler
authored andcommitted
Add new target armv7-unknown-linux-uclibceabihf
1 parent e9cdccc commit a7095af

File tree

10 files changed

+45
-12
lines changed

10 files changed

+45
-12
lines changed

compiler/rustc_codegen_llvm/src/callee.rs

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

compiler/rustc_middle/src/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ where
27432743
};
27442744

27452745
let target = &cx.tcx().sess.target;
2746-
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl");
2746+
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl" | "uclibc");
27472747
let win_x64_gnu = target.os == "windows" && target.arch == "x86_64" && target.env == "gnu";
27482748
let linux_s390x_gnu_like =
27492749
target.os == "linux" && target.arch == "s390x" && target_env_gnu_like;
@@ -2842,7 +2842,7 @@ where
28422842
if arg.layout.is_zst() {
28432843
// For some forsaken reason, x86_64-pc-windows-gnu
28442844
// doesn't ignore zero-sized struct arguments.
2845-
// The same is true for {s390x,sparc64,powerpc}-unknown-linux-{gnu,musl}.
2845+
// The same is true for {s390x,sparc64,powerpc}-unknown-linux-{gnu,musl,uclibc}.
28462846
if is_return
28472847
|| rust_abi
28482848
|| (!win_x64_gnu
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{Target, TargetOptions};
2+
3+
// This target is for glibc 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+
unsupported_abis: super::arm_base::unsupported_abis(),
20+
mcount: "_mcount".to_string(),
21+
..base
22+
},
23+
}
24+
}

compiler/rustc_target/src/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,8 @@ supported_targets! {
897897
("aarch64_be-unknown-linux-gnu", aarch64_be_unknown_linux_gnu),
898898
("aarch64-unknown-linux-gnu_ilp32", aarch64_unknown_linux_gnu_ilp32),
899899
("aarch64_be-unknown-linux-gnu_ilp32", aarch64_be_unknown_linux_gnu_ilp32),
900+
901+
("armv7-unknown-linux-uclibceabihf", armv7_unknown_linux_uclibceabihf),
900902
}
901903

902904
/// Everything `rustc` knows about how to compile for a specific target.

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,16 @@ mod imp {
100100
// On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize
101101
// `ARGC` and `ARGV`. But in Miri that does not actually happen so we
102102
// still initialize here.
103-
#[cfg(any(miri, not(all(target_os = "linux", target_env = "gnu"))))]
103+
#[cfg(any(
104+
miri,
105+
not(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))
106+
))]
104107
really_init(_argc, _argv);
105108
}
106109

107110
/// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.
108111
/// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows.
109-
#[cfg(all(target_os = "linux", target_env = "gnu"))]
112+
#[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]
110113
#[used]
111114
#[link_section = ".init_array.00099"]
112115
static ARGV_INIT_ARRAY: extern "C" fn(

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

+3
Original file line numberDiff line numberDiff line change
@@ -254,5 +254,8 @@ cfg_if::cfg_if! {
254254
#[link(name = "zircon")]
255255
#[link(name = "fdio")]
256256
extern "C" {}
257+
} else if #[cfg(all(target_os = "linux", target_env = "uclibc"))] {
258+
#[link(name = "dl")]
259+
extern "C" {}
257260
}
258261
}

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ impl Command {
265265
#[cfg(not(any(
266266
target_os = "macos",
267267
target_os = "freebsd",
268-
all(target_os = "linux", target_env = "gnu"),
269-
all(target_os = "linux", target_env = "musl"),
268+
all(target_os = "linux", any(target_env = "gnu", target_env = "musl")),
270269
)))]
271270
fn posix_spawn(
272271
&mut self,
@@ -281,8 +280,7 @@ impl Command {
281280
#[cfg(any(
282281
target_os = "macos",
283282
target_os = "freebsd",
284-
all(target_os = "linux", target_env = "gnu"),
285-
all(target_os = "linux", target_env = "musl"),
283+
all(target_os = "linux", any(target_env = "gnu", target_env = "musl")),
286284
))]
287285
fn posix_spawn(
288286
&mut self,
@@ -302,7 +300,7 @@ impl Command {
302300
}
303301

304302
// Only glibc 2.24+ posix_spawn() supports returning ENOENT directly.
305-
#[cfg(all(target_os = "linux", target_env = "gnu"))]
303+
#[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]
306304
{
307305
if let Some(version) = sys::os::glibc_version() {
308306
if version < (2, 24) {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ pub mod guard {
434434
Some(stackaddr - guardsize..stackaddr)
435435
} else if cfg!(all(target_os = "linux", target_env = "musl")) {
436436
Some(stackaddr - guardsize..stackaddr)
437-
} else if cfg!(all(target_os = "linux", target_env = "gnu")) {
437+
} else if cfg!(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))
438+
{
438439
// glibc used to include the guard area within the stack, as noted in the BUGS
439440
// section of `man pthread_attr_getguardsize`. This has been corrected starting
440441
// 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
@@ -46,7 +46,7 @@ extern "C" {}
4646
// don't want to duplicate it here.
4747
#[cfg(all(
4848
target_os = "linux",
49-
target_env = "gnu",
49+
any(target_env = "gnu", target_env = "uclibc"),
5050
not(feature = "llvm-libunwind"),
5151
not(feature = "system-llvm-libunwind")
5252
))]
@@ -55,7 +55,7 @@ extern "C" {}
5555

5656
#[cfg(all(
5757
target_os = "linux",
58-
target_env = "gnu",
58+
any(target_env = "gnu", target_env = "uclibc"),
5959
not(feature = "llvm-libunwind"),
6060
feature = "system-llvm-libunwind"
6161
))]

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

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ target | std | host | notes
169169
`armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD
170170
`armv6-unknown-netbsd-eabihf` | ? | |
171171
`armv7-apple-ios` | ✓ | | ARMv7 iOS, Cortex-a8
172+
`armv7-unknown-linux-uclibceabihf` | ✓ | ? | ARMv7 Linux uClibc
172173
`armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD
173174
`armv7-unknown-netbsd-eabihf` | ✓ | ✓ |
174175
`armv7-wrs-vxworks-eabihf` | ? | |

0 commit comments

Comments
 (0)