Skip to content

Commit 685d0cb

Browse files
committed
allow memfd_create to be used with older glibc (<2.27)
1 parent e7c877a commit 685d0cb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
4141

4242
- Added `F_KINFO` FcntlFlags entry on FreeBSD for `::nix::fcntl`.
4343
([#2152](https://github.com/nix-rust/nix/pull/2152))
44+
- Fix `memfd_create` to not depend on glibc version being greater than 2.27.
45+
([#2146](https://github.com/nix-rust/nix/pull/2146))
4446

4547
### Changed
4648

src/sys/memfd.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag) -> Result<OwnedFd> {
4848
// Android does not have a memfd_create symbol
4949
not(target_os = "android"),
5050
any(
51+
// Note that memfd_create is available since release 13.0
52+
// See https://man.freebsd.org/cgi/man.cgi?query=memfd_create
5153
target_os = "freebsd",
52-
// If the OS is Linux, gnu and musl expose a memfd_create symbol but not uclibc
53-
target_env = "gnu",
54+
// If the OS is Linux, gnu and musl expose a memfd_create symbol but not uclibc.
55+
// But in glibc it is availible since 2.27. The oldest one officially supported by Rust is 2.17.
56+
// So it is reasonable to keep compatibility with it.
5457
target_env = "musl",
5558
)))]
5659
{

0 commit comments

Comments
 (0)