Skip to content

Commit

Permalink
fix: Ensure that const extern fn is always enabled
Browse files Browse the repository at this point in the history
In [1] this conditional was dropped in favor of a Cargo feature, which
was turned on by default in [2].

Fixes: rust-lang#4149

[1]: rust-lang#4105
[2]: rust-lang#4134
  • Loading branch information
tgross35 committed Nov 26, 2024
1 parent f553033 commit 093cf26
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"freebsd13",
"freebsd14",
"freebsd15",
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
"libc_const_extern_fn",
"libc_deny_warnings",
"libc_ctest",
];
@@ -74,6 +76,8 @@ fn main() {
set_cfg("libc_deny_warnings");
}

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.
3 changes: 2 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
@@ -199,7 +199,8 @@ macro_rules! e {
// cfg completely.
// FIXME(ctest): ctest can't handle `$(,)?` so we use `$(,)*` which isn't quite correct.
cfg_if! {
if #[cfg(feature = "const-extern-fn")] {
if #[cfg(libc_const_extern_fn)] {
// if #[cfg(feature = "const-extern-fn")] {
/// Define an `unsafe` function that is const as long as `const-extern-fn` is enabled.
macro_rules! f {
($(

0 comments on commit 093cf26

Please sign in to comment.