Skip to content

Commit

Permalink
Bump MSRV to 1.31
Browse files Browse the repository at this point in the history
This permits `Cargo.toml` to include optional dependencies. On
toolchains earlier than 1.31, the optional dependency syntax is not
supported. With the MSRV at 1.31, any optional dependency may be
supported even if *its* MSRV is higher than *our* MSRV since only users
using a more recent toolchain will enable that dependency.

In particular, this paves the way for adding an optional `zerocopy`
dependency (prototyped in #3407 and #3914; see also google/zerocopy#557),
which permits many uses of libc to no longer require `unsafe` code.
  • Loading branch information
joshlf committed Sep 14, 2024
1 parent a515d07 commit 5089ac1
Show file tree
Hide file tree
Showing 101 changed files with 213 additions and 1,726 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/full_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ jobs:
stable,
beta,
nightly,
# FIXME: Disabled due to:
# error: failed to parse registry's information for: serde
#1.13.0,
1.19.0,
1.24.0,
1.25.0,
1.30.0,
1.31.0,
]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -205,10 +199,6 @@ jobs:
fail-fast: true
matrix:
toolchain: [
1.19.0,
1.24.0,
1.25.0,
1.30.0,
stable,
]
steps:
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,13 @@ libc = "0.2"

## Rust version support

The minimum supported Rust toolchain version is currently **Rust 1.13.0**.
The minimum supported Rust toolchain version is currently **Rust 1.31.0**.
(libc does not currently have any policy regarding changes to the minimum
supported Rust version; such policy is a work in progress.) APIs requiring
newer Rust features are only available on newer Rust toolchains:

| Feature | Version |
|----------------------|---------|
| `union` | 1.19.0 |
| `const mem::size_of` | 1.24.0 |
| `repr(align)` | 1.25.0 |
| `extra_traits` | 1.25.0 |
| `core::ffi::c_void` | 1.30.0 |
| `repr(packed(N))` | 1.33.0 |
| `cfg(target_vendor)` | 1.33.0 |
| `const-extern-fn` | 1.62.0 |
Expand Down
38 changes: 0 additions & 38 deletions build-tmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"freebsd13",
"freebsd14",
"freebsd15",
"libc_align",
"libc_cfg_target_vendor",
"libc_const_extern_fn",
"libc_const_extern_fn_unstable",
"libc_const_size_of",
"libc_core_cvoid",
"libc_deny_warnings",
"libc_int128",
"libc_long_array",
"libc_non_exhaustive",
"libc_packedN",
"libc_priv_mod_use",
"libc_ptr_addr_of",
"libc_thread_local",
"libc_underscore_const_names",
"libc_union",
"libc_ctest",
];

Expand Down Expand Up @@ -95,38 +89,6 @@ fn main() {
set_cfg("libc_deny_warnings");
}

// Rust >= 1.15 supports private module use:
if rustc_minor_ver >= 15 || rustc_dep_of_std {
set_cfg("libc_priv_mod_use");
}

// Rust >= 1.19 supports unions:
if rustc_minor_ver >= 19 || rustc_dep_of_std {
set_cfg("libc_union");
}

// Rust >= 1.24 supports const mem::size_of:
if rustc_minor_ver >= 24 || rustc_dep_of_std {
set_cfg("libc_const_size_of");
}

// Rust >= 1.25 supports repr(align):
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
set_cfg("libc_align");
}

// Rust >= 1.26 supports i128 and u128:
if rustc_minor_ver >= 26 || rustc_dep_of_std {
set_cfg("libc_int128");
}

// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
// Otherwise, it defines an incompatible type to retaining
// backwards-compatibility.
if rustc_minor_ver >= 30 || rustc_dep_of_std {
set_cfg("libc_core_cvoid");
}

// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
if rustc_minor_ver >= 33 || rustc_dep_of_std {
set_cfg("libc_packedN");
Expand Down
38 changes: 0 additions & 38 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"freebsd13",
"freebsd14",
"freebsd15",
"libc_align",
"libc_cfg_target_vendor",
"libc_const_extern_fn",
"libc_const_extern_fn_unstable",
"libc_const_size_of",
"libc_core_cvoid",
"libc_deny_warnings",
"libc_int128",
"libc_long_array",
"libc_non_exhaustive",
"libc_packedN",
"libc_priv_mod_use",
"libc_ptr_addr_of",
"libc_thread_local",
"libc_underscore_const_names",
"libc_union",
"libc_ctest",
];

Expand Down Expand Up @@ -94,38 +88,6 @@ fn main() {
set_cfg("libc_deny_warnings");
}

// Rust >= 1.15 supports private module use:
if rustc_minor_ver >= 15 || rustc_dep_of_std {
set_cfg("libc_priv_mod_use");
}

// Rust >= 1.19 supports unions:
if rustc_minor_ver >= 19 || rustc_dep_of_std {
set_cfg("libc_union");
}

// Rust >= 1.24 supports const mem::size_of:
if rustc_minor_ver >= 24 || rustc_dep_of_std {
set_cfg("libc_const_size_of");
}

// Rust >= 1.25 supports repr(align):
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
set_cfg("libc_align");
}

// Rust >= 1.26 supports i128 and u128:
if rustc_minor_ver >= 26 || rustc_dep_of_std {
set_cfg("libc_int128");
}

// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
// Otherwise, it defines an incompatible type to retaining
// backwards-compatibility.
if rustc_minor_ver >= 30 || rustc_dep_of_std {
set_cfg("libc_core_cvoid");
}

// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
if rustc_minor_ver >= 33 || rustc_dep_of_std {
set_cfg("libc_packedN");
Expand Down
12 changes: 3 additions & 9 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,9 @@ case "${OS}" in
linux*)
TARGETS="${RUST_LINUX_TARGETS}"

if [ "${RUST}" != "1.13.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
if [ "${RUST}" != "1.19.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
if [ "${RUST}" != "1.24.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"
fi
fi
fi
TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"

if [ "${RUST}" = "nightly" ]; then
TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}"
Expand Down
10 changes: 1 addition & 9 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,7 @@ fn do_ctest() {

fn ctest_cfg() -> ctest::TestGenerator {
let mut cfg = ctest::TestGenerator::new();
let libc_cfgs = [
"libc_priv_mod_use",
"libc_union",
"libc_const_size_of",
"libc_align",
"libc_core_cvoid",
"libc_packedN",
"libc_thread_local",
];
let libc_cfgs = ["libc_packedN", "libc_thread_local"];
for f in &libc_cfgs {
cfg.cfg(f, None);
}
Expand Down
2 changes: 1 addition & 1 deletion src/fixed_width_ints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type uint32_t = u32;
pub type uint64_t = u64;

cfg_if! {
if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] {
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
// This introduces partial support for FFI with __int128 and
// equivalent types on platforms where Rust's definition is validated
// to match the standard C ABI of that platform.
Expand Down
31 changes: 3 additions & 28 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4362,33 +4362,8 @@ cfg_if! {
}
}

cfg_if! {
if #[cfg(libc_align)] {
#[macro_use]
mod align;
} else {
#[macro_use]
mod no_align;
}
}
#[macro_use]
mod align;
expand_align!();

cfg_if! {
if #[cfg(libc_core_cvoid)] {
pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
}
pub use ffi::c_void;
129 changes: 0 additions & 129 deletions src/fuchsia/no_align.rs

This file was deleted.

Loading

0 comments on commit 5089ac1

Please sign in to comment.