Skip to content

Commit a193e81

Browse files
committed
allow memfd_create to be used with older glibc (<2.27)
1 parent 582e773 commit a193e81

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

changelog/2146.fixed.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed `memfd_create` to not depend on glibc version being greater than 2.27.
2+
([#2146](https://github.com/nix-rust/nix/pull/2146))

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)