Skip to content

Commit d06be1e

Browse files
committed
test no-core targets
1 parent d7a1995 commit d06be1e

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed

build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn main() {
88
let rustc_dep_of_std =
99
std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
1010
let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
11+
let test_no_core_build = std::env::var("RUST_LIBC_NO_CORE_BUILD").is_ok();
1112

1213
// Rust >= 1.15 supports private module use:
1314
if rustc_minor_ver >= 15 || rustc_dep_of_std {
@@ -32,14 +33,18 @@ fn main() {
3233
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
3334
// Otherwise, it defines an incompatible type to retaining
3435
// backwards-compatibility.
35-
if rustc_minor_ver >= 30 || rustc_dep_of_std {
36+
if (rustc_minor_ver >= 30 || rustc_dep_of_std) && !test_no_core_build {
3637
println!("cargo:rustc-cfg=libc_core_cvoid");
3738
}
3839

3940
// Rust >= 1.33 supports repr(packed(N))
4041
if rustc_minor_ver >= 33 || rustc_dep_of_std {
4142
println!("cargo:rustc-cfg=libc_packedN");
4243
}
44+
45+
if test_no_core_build {
46+
println!("cargo:rustc-cfg=test_no_core_build");
47+
}
4348
}
4449

4550
fn rustc_minor_version() -> Option<u32> {

ci/build.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_target() {
2222
opt="--release"
2323
fi
2424

25-
NO_STD=
25+
NO_STD="${2}"
2626
case ${TARGET} in
2727
thumbv*)
2828
NO_STD=1
@@ -31,6 +31,10 @@ test_target() {
3131

3232
rustup target add "${TARGET}" --toolchain "${RUST}" || true
3333

34+
if [ "$NO_CORE" = 1 ]; then
35+
cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}"
36+
fi
37+
3438
# Test that libc builds without any default features (no libstd)
3539
cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}"
3640

@@ -51,6 +55,48 @@ test_target() {
5155
fi
5256
}
5357

58+
RUST_LINUX_NO_CORE_TARGETS="\
59+
x86_64-apple-darwin
60+
"
61+
62+
for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
63+
if [ "${RUST}" = "nightly" ]; then
64+
RUST_LIBC_NO_CORE_BUILD=1 test_target "$TARGET" 1
65+
fi
66+
done
67+
68+
exit 0
69+
70+
RUST_LINUX_NO_CORE_TARGETS="\
71+
aarch64-pc-windows-msvc \
72+
aarch64-unknown-cloudabi \
73+
armv7-unknown-cloudabi-eabihf \
74+
i586-pc-windows-msvc \
75+
i686-pc-windows-gnu \
76+
i686-pc-windows-msvc \
77+
i686-unknown-cloudabi \
78+
i686-unknown-haiku \
79+
i686-unknown-netbsd \
80+
mips-unknown-linux-uclib \
81+
mipsel-unknown-unknown-linux-uclib \
82+
nvptx64-nvidia-cuda \
83+
powerpc-unknown-linux-gnuspe \
84+
riscv32imac-unknown-none-elf \
85+
riscv32imc-unknown-none-elf \
86+
sparc-unknown-linux-gnu \
87+
sparc64-unknown-netbsd \
88+
thumbv8m.main-none-eabi \
89+
x86_64-pc-windows-gnu \
90+
x86_64-pc-windows-msvc
91+
x86_64-unknown-bitrig \
92+
x86_64-unknown-dragonfly \
93+
x86_64-unknown-haiku \
94+
x86_64-unknown-openbsd
95+
"
96+
97+
98+
exit 0
99+
54100
RUST_LINUX_TARGETS="\
55101
aarch64-linux-android \
56102
aarch64-unknown-linux-gnu \
@@ -103,6 +149,12 @@ x86_64-unknown-cloudabi \
103149

104150
RUST_NIGHTLY_LINUX_TARGETS="\
105151
aarch64-fuchsia \
152+
armv5te-unknown-linux-gnueabi \
153+
armv5te-unknown-linux-musleabi \
154+
armebv7r-none-eabi \
155+
armebv7r-none-eabihf \
156+
armv7r-none-eabi \
157+
armv7r-none-eabihf \
106158
thumbv6m-none-eabi \
107159
thumbv7em-none-eabi \
108160
thumbv7em-none-eabihf \

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
not(any(
2929
feature = "use_std",
3030
feature = "rustc-dep-of-std",
31-
cross_platform_docs
31+
cross_platform_docs,
32+
test_no_core_build
3233
)),
3334
no_std
3435
)]
36+
// Test no_core build
37+
#![cfg_attr(test_no_core_build, feature(no_core, lang_items))]
38+
#![cfg_attr(test_no_core_build, no_core)]
3539

3640
#[cfg(all(not(cross_platform_docs), feature = "use_std"))]
3741
extern crate std as core;
@@ -50,7 +54,7 @@ cfg_if! {
5054
}
5155

5256
cfg_if! {
53-
if #[cfg(not(cross_platform_docs))] {
57+
if #[cfg(not(any(cross_platform_docs, test_no_core_build)))] {
5458
cfg_if! {
5559
if #[cfg(libc_priv_mod_use)] {
5660
#[cfg(libc_core_cvoid)]

0 commit comments

Comments
 (0)