Skip to content

Commit 656ea9b

Browse files
committed
allow memfd_create to be used with older glibc (<2.27)
1 parent 2f4861f commit 656ea9b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1616
descriptor.
1717
([#2141](https://github.com/nix-rust/nix/pull/2141))
1818

19+
- Fix `memfd_create` to not depend on glibc version being greater than 2.27.
20+
([#2146](https://github.com/nix-rust/nix/pull/2146))
21+
1922
### Changed
2023

2124
- The MSRV is now 1.69

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)