From 656ea9b9dd2cd764e3374db70aba34d47bd71d7f Mon Sep 17 00:00:00 2001 From: Dmitry Rodionov Date: Mon, 25 Sep 2023 21:56:01 +0300 Subject: [PATCH] allow memfd_create to be used with older glibc (<2.27) --- CHANGELOG.md | 3 +++ src/sys/memfd.rs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2406958e0f..cf9bfbdd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). descriptor. ([#2141](https://github.com/nix-rust/nix/pull/2141)) +- Fix `memfd_create` to not depend on glibc version being greater than 2.27. + ([#2146](https://github.com/nix-rust/nix/pull/2146)) + ### Changed - The MSRV is now 1.69 diff --git a/src/sys/memfd.rs b/src/sys/memfd.rs index 516ffd3262..32fec2f5a7 100644 --- a/src/sys/memfd.rs +++ b/src/sys/memfd.rs @@ -48,9 +48,12 @@ pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag) -> Result { // Android does not have a memfd_create symbol not(target_os = "android"), any( + // Note that memfd_create is available since release 13.0 + // See https://man.freebsd.org/cgi/man.cgi?query=memfd_create target_os = "freebsd", - // If the OS is Linux, gnu and musl expose a memfd_create symbol but not uclibc - target_env = "gnu", + // If the OS is Linux, gnu and musl expose a memfd_create symbol but not uclibc. + // But in glibc it is availible since 2.27. The oldest one officially supported by Rust is 2.17. + // So it is reasonable to keep compatibility with it. target_env = "musl", )))] {