Skip to content

Commit d3aa573

Browse files
committed
wip
1 parent 4e5ef22 commit d3aa573

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[package]
2-
32
name = "libc"
43
version = "0.2.43"
54
authors = ["The Rust Project Developers"]
@@ -19,10 +18,14 @@ exclude = ["/ci/*", "/.travis.yml", "/appveyor.yml"]
1918
travis-ci = { repository = "rust-lang/libc" }
2019
appveyor = { repository = "rust-lang/libc", project_name = "rust-lang-libs/libc" }
2120

21+
[dependencies]
22+
rustc-std-workspace-core = { version = "1.0.0", optional = true }
23+
2224
[features]
2325
default = ["use_std"]
2426
use_std = []
2527
align = []
28+
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
2629

2730
[workspace]
2831
members = ["libc-test"]

libc-test/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ fn main() {
444444
// which is absent in glibc, has to be defined.
445445
"__timeval" if linux => true,
446446

447-
// Fixed on stdbuild with repr(packed(4))
447+
// Fixed on feature=align with repr(packed(4))
448448
// Once repr_packed stabilizes we can fix this unconditionally
449449
// and remove this check.
450450
"kevent" | "shmid_ds" if apple && x86_64 => true,

src/lib.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,30 @@
8686
))]
8787

8888
// Attributes needed when building as part of the standard library
89-
#![cfg_attr(feature = "stdbuild", feature(staged_api, cfg_target_vendor))]
90-
#![cfg_attr(feature = "stdbuild", feature(link_cfg, repr_packed))]
91-
#![cfg_attr(feature = "stdbuild", allow(warnings))]
89+
#![cfg_attr(feature = "rustc-dep-of-std", feature(cfg_target_vendor))]
90+
#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg))]
91+
#![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))]
92+
#![cfg_attr(feature = "rustc-dep-of-std", feature(staged_api))]
93+
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
9294
#![cfg_attr(feature = "stdbuild", unstable(feature = "libc",
93-
reason = "use `libc` from crates.io",
94-
issue = "27783"))]
95+
reason = "use `libc` from crates.io",
96+
issue = "27783"))]
9597

96-
#![cfg_attr(not(feature = "use_std"), no_std)]
98+
99+
#![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)]
97100

98101
#[cfg(all(not(cross_platform_docs), feature = "use_std"))]
99102
extern crate std as core;
100103

104+
#[cfg(feature = "rustc-dep-of-std")]
105+
extern crate rustc_std_workspace_core as core;
106+
#[cfg(feature = "rustc-dep-of-std")]
107+
#[allow(unused_imports)]
108+
use core::iter;
109+
#[cfg(feature = "rustc-dep-of-std")]
110+
#[allow(unused_imports)]
111+
use core::option;
112+
101113
#[macro_use] mod macros;
102114
mod dox;
103115

src/unix/bsd/apple/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ s! {
245245
pub f_reserved: [::uint32_t; 8],
246246
}
247247

248-
#[cfg_attr(feature = "stdbuild", repr(packed(4)))]
248+
#[cfg_attr(feature = "align", repr(packed(4)))]
249249
pub struct kevent {
250250
pub ident: ::uintptr_t,
251251
pub filter: ::int16_t,
@@ -535,7 +535,7 @@ s! {
535535
pub _key: ::key_t,
536536
}
537537

538-
#[cfg_attr(feature = "stdbuild", repr(packed(4)))]
538+
#[cfg_attr(feature = "align", repr(packed(4)))]
539539
pub struct shmid_ds {
540540
pub shm_perm: ipc_perm,
541541
pub shm_segsz: ::size_t,

src/unix/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,17 @@ cfg_if! {
287287
// cargo build, don't pull in anything extra as the libstd dep
288288
// already pulls in all libs.
289289
} else if #[cfg(target_env = "musl")] {
290-
#[cfg_attr(feature = "stdbuild",
290+
#[cfg_attr(feature = "rustc-dep-of-std",
291291
link(name = "c", kind = "static",
292292
cfg(target_feature = "crt-static")))]
293-
#[cfg_attr(feature = "stdbuild",
293+
#[cfg_attr(feature = "rustc-dep-of-std",
294294
link(name = "c", cfg(not(target_feature = "crt-static"))))]
295295
extern {}
296296
} else if #[cfg(target_os = "emscripten")] {
297297
#[link(name = "c")]
298298
extern {}
299299
} else if #[cfg(all(target_os = "netbsd",
300-
feature = "stdbuild", target_vendor = "rumprun"))] {
300+
feature = "rustc-dep-of-std", target_vendor = "rumprun"))] {
301301
// Since we don't use -nodefaultlibs on Rumprun, libc is always pulled
302302
// in automatically by the linker. We avoid passing it explicitly, as it
303303
// causes some versions of binutils to crash with an assertion failure.

src/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub const EILSEQ: ::c_int = 42;
159159
pub const STRUNCATE: ::c_int = 80;
160160

161161
// inline comment below appeases style checker
162-
#[cfg(all(target_env = "msvc", feature = "stdbuild"))] // " if "
162+
#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
163163
#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
164164
#[link(name = "libcmt", cfg(target_feature = "crt-static"))]
165165
extern {}

0 commit comments

Comments
 (0)