Skip to content

Commit

Permalink
allow memfd_create to be used with older glibc (<2.27)
Browse files Browse the repository at this point in the history
  • Loading branch information
LizardWizzard committed Oct 6, 2023
1 parent e7c877a commit 685d0cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).

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

### Changed

Expand Down
7 changes: 5 additions & 2 deletions src/sys/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag) -> Result<OwnedFd> {
// 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",
)))]
{
Expand Down

0 comments on commit 685d0cb

Please sign in to comment.