Skip to content

Commit caf3992

Browse files
committed
Bump MSRV to 1.31
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 rust-lang#3407 and rust-lang#3914; see also google/zerocopy#557), which permits many uses of libc to no longer require `unsafe` code.
1 parent a515d07 commit caf3992

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+217
-1722
lines changed

.github/workflows/full_ci.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,7 @@ jobs:
154154
stable,
155155
beta,
156156
nightly,
157-
# FIXME: Disabled due to:
158-
# error: failed to parse registry's information for: serde
159-
#1.13.0,
160-
1.19.0,
161-
1.24.0,
162-
1.25.0,
163-
1.30.0,
157+
1.31.0,
164158
]
165159
steps:
166160
- uses: actions/checkout@v4
@@ -205,10 +199,6 @@ jobs:
205199
fail-fast: true
206200
matrix:
207201
toolchain: [
208-
1.19.0,
209-
1.24.0,
210-
1.25.0,
211-
1.30.0,
212202
stable,
213203
]
214204
steps:

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,13 @@ libc = "0.2"
5151

5252
## Rust version support
5353

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

5959
| Feature | Version |
6060
|----------------------|---------|
61-
| `union` | 1.19.0 |
62-
| `const mem::size_of` | 1.24.0 |
63-
| `repr(align)` | 1.25.0 |
64-
| `extra_traits` | 1.25.0 |
65-
| `core::ffi::c_void` | 1.30.0 |
6661
| `repr(packed(N))` | 1.33.0 |
6762
| `cfg(target_vendor)` | 1.33.0 |
6863
| `const-extern-fn` | 1.62.0 |

build-tmp.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,16 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1515
"freebsd13",
1616
"freebsd14",
1717
"freebsd15",
18-
"libc_align",
1918
"libc_cfg_target_vendor",
2019
"libc_const_extern_fn",
2120
"libc_const_extern_fn_unstable",
22-
"libc_const_size_of",
23-
"libc_core_cvoid",
2421
"libc_deny_warnings",
25-
"libc_int128",
2622
"libc_long_array",
2723
"libc_non_exhaustive",
2824
"libc_packedN",
29-
"libc_priv_mod_use",
3025
"libc_ptr_addr_of",
3126
"libc_thread_local",
3227
"libc_underscore_const_names",
33-
"libc_union",
3428
"libc_ctest",
3529
];
3630

@@ -95,38 +89,6 @@ fn main() {
9589
set_cfg("libc_deny_warnings");
9690
}
9791

98-
// Rust >= 1.15 supports private module use:
99-
if rustc_minor_ver >= 15 || rustc_dep_of_std {
100-
set_cfg("libc_priv_mod_use");
101-
}
102-
103-
// Rust >= 1.19 supports unions:
104-
if rustc_minor_ver >= 19 || rustc_dep_of_std {
105-
set_cfg("libc_union");
106-
}
107-
108-
// Rust >= 1.24 supports const mem::size_of:
109-
if rustc_minor_ver >= 24 || rustc_dep_of_std {
110-
set_cfg("libc_const_size_of");
111-
}
112-
113-
// Rust >= 1.25 supports repr(align):
114-
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
115-
set_cfg("libc_align");
116-
}
117-
118-
// Rust >= 1.26 supports i128 and u128:
119-
if rustc_minor_ver >= 26 || rustc_dep_of_std {
120-
set_cfg("libc_int128");
121-
}
122-
123-
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
124-
// Otherwise, it defines an incompatible type to retaining
125-
// backwards-compatibility.
126-
if rustc_minor_ver >= 30 || rustc_dep_of_std {
127-
set_cfg("libc_core_cvoid");
128-
}
129-
13092
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
13193
if rustc_minor_ver >= 33 || rustc_dep_of_std {
13294
set_cfg("libc_packedN");

build.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,16 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1414
"freebsd13",
1515
"freebsd14",
1616
"freebsd15",
17-
"libc_align",
1817
"libc_cfg_target_vendor",
1918
"libc_const_extern_fn",
2019
"libc_const_extern_fn_unstable",
21-
"libc_const_size_of",
22-
"libc_core_cvoid",
2320
"libc_deny_warnings",
24-
"libc_int128",
2521
"libc_long_array",
2622
"libc_non_exhaustive",
2723
"libc_packedN",
28-
"libc_priv_mod_use",
2924
"libc_ptr_addr_of",
3025
"libc_thread_local",
3126
"libc_underscore_const_names",
32-
"libc_union",
3327
"libc_ctest",
3428
];
3529

@@ -94,38 +88,6 @@ fn main() {
9488
set_cfg("libc_deny_warnings");
9589
}
9690

97-
// Rust >= 1.15 supports private module use:
98-
if rustc_minor_ver >= 15 || rustc_dep_of_std {
99-
set_cfg("libc_priv_mod_use");
100-
}
101-
102-
// Rust >= 1.19 supports unions:
103-
if rustc_minor_ver >= 19 || rustc_dep_of_std {
104-
set_cfg("libc_union");
105-
}
106-
107-
// Rust >= 1.24 supports const mem::size_of:
108-
if rustc_minor_ver >= 24 || rustc_dep_of_std {
109-
set_cfg("libc_const_size_of");
110-
}
111-
112-
// Rust >= 1.25 supports repr(align):
113-
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
114-
set_cfg("libc_align");
115-
}
116-
117-
// Rust >= 1.26 supports i128 and u128:
118-
if rustc_minor_ver >= 26 || rustc_dep_of_std {
119-
set_cfg("libc_int128");
120-
}
121-
122-
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
123-
// Otherwise, it defines an incompatible type to retaining
124-
// backwards-compatibility.
125-
if rustc_minor_ver >= 30 || rustc_dep_of_std {
126-
set_cfg("libc_core_cvoid");
127-
}
128-
12991
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
13092
if rustc_minor_ver >= 33 || rustc_dep_of_std {
13193
set_cfg("libc_packedN");

ci/build.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,9 @@ case "${OS}" in
169169
linux*)
170170
TARGETS="${RUST_LINUX_TARGETS}"
171171

172-
if [ "${RUST}" != "1.13.0" ]; then
173-
TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
174-
if [ "${RUST}" != "1.19.0" ]; then
175-
TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
176-
if [ "${RUST}" != "1.24.0" ]; then
177-
TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"
178-
fi
179-
fi
180-
fi
172+
TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
173+
TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
174+
TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"
181175

182176
if [ "${RUST}" = "nightly" ]; then
183177
TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}"

libc-test/build.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ fn do_ctest() {
6969
fn ctest_cfg() -> ctest::TestGenerator {
7070
let mut cfg = ctest::TestGenerator::new();
7171
let libc_cfgs = [
72-
"libc_priv_mod_use",
73-
"libc_union",
74-
"libc_const_size_of",
75-
"libc_align",
76-
"libc_core_cvoid",
7772
"libc_packedN",
7873
"libc_thread_local",
7974
];

src/fixed_width_ints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub type uint32_t = u32;
2020
pub type uint64_t = u64;
2121

2222
cfg_if! {
23-
if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] {
23+
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
2424
// This introduces partial support for FFI with __int128 and
2525
// equivalent types on platforms where Rust's definition is validated
2626
// to match the standard C ABI of that platform.

src/fuchsia/mod.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4362,33 +4362,8 @@ cfg_if! {
43624362
}
43634363
}
43644364

4365-
cfg_if! {
4366-
if #[cfg(libc_align)] {
4367-
#[macro_use]
4368-
mod align;
4369-
} else {
4370-
#[macro_use]
4371-
mod no_align;
4372-
}
4373-
}
4365+
#[macro_use]
4366+
mod align;
43744367
expand_align!();
43754368

4376-
cfg_if! {
4377-
if #[cfg(libc_core_cvoid)] {
4378-
pub use ::ffi::c_void;
4379-
} else {
4380-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
4381-
// enable more optimization opportunities around it recognizing things
4382-
// like malloc/free.
4383-
#[repr(u8)]
4384-
#[allow(missing_copy_implementations)]
4385-
#[allow(missing_debug_implementations)]
4386-
pub enum c_void {
4387-
// Two dummy variants so the #[repr] attribute can be used.
4388-
#[doc(hidden)]
4389-
__variant1,
4390-
#[doc(hidden)]
4391-
__variant2,
4392-
}
4393-
}
4394-
}
4369+
pub use ::ffi::c_void;

src/fuchsia/no_align.rs

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)