Skip to content

Commit

Permalink
Merge pull request #4105 from tgross35/remove-cfg-const-extern-fn-main
Browse files Browse the repository at this point in the history
[main] Drop the `libc_const_extern_fn` conditional
  • Loading branch information
tgross35 authored Nov 18, 2024
2 parents 564cc5d + fa554bc commit 22d4318
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rust-version = "1.63"
description = "Raw FFI bindings to platform libraries like libc."

[package.metadata.docs.rs]
features = ["const-extern-fn", "extra_traits"]
features = ["extra_traits"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"aarch64-apple-darwin",
Expand Down Expand Up @@ -139,6 +139,9 @@ default = ["std"]
std = []
rustc-dep-of-std = ["rustc-std-workspace-core"]
extra_traits = []

# `const-extern-function` is deprecated and no longer does anything
# FIXME(1.0): remove this completely
const-extern-fn = []

[workspace]
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ libc = "0.2"
* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`.
This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`.

* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s. If you
use Rust >= 1.62, this feature is implicitly enabled. Otherwise it requires a
nightly rustc.

## Rust version support

The minimum supported Rust toolchain version is currently **Rust 1.63**.
Expand Down
19 changes: 1 addition & 18 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"freebsd13",
"freebsd14",
"freebsd15",
"libc_const_extern_fn",
"libc_const_extern_fn_unstable",
"libc_deny_warnings",
"libc_ctest",
];
Expand All @@ -39,11 +37,10 @@ fn main() {
// Avoid unnecessary re-building.
println!("cargo:rerun-if-changed=build.rs");

let (rustc_minor_ver, is_nightly) = rustc_minor_nightly();
let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly();
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
let libc_ci = env::var("LIBC_CI").is_ok();
let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80;
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();

// The ABI of libc used by std is backward compatible with FreeBSD 12.
// The ABI of libc from crates.io is backward compatible with FreeBSD 11.
Expand Down Expand Up @@ -78,20 +75,6 @@ fn main() {
set_cfg("libc_deny_warnings");
}

// Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C".
if rustc_minor_ver >= 62 {
set_cfg("libc_const_extern_fn");
} else {
// Rust < 1.62.0 requires a crate feature and feature gate.
if const_extern_fn_cargo_feature {
if !is_nightly || rustc_minor_ver < 40 {
panic!("const-extern-fn requires a nightly compiler >= 1.40");
}
set_cfg("libc_const_extern_fn_unstable");
set_cfg("libc_const_extern_fn");
}
}

// check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the
// codebase. libc can configure it if the appropriate environment variable is passed. Since
// rust-lang/rust enforces it, this is useful when using a custom libc fork there.
Expand Down

0 comments on commit 22d4318

Please sign in to comment.