Skip to content

Dragonfly fixes#5116

Merged
tgross35 merged 9 commits into
rust-lang:mainfrom
chitao1234:dragonfly-fixes
Jun 30, 2026
Merged

Dragonfly fixes#5116
tgross35 merged 9 commits into
rust-lang:mainfrom
chitao1234:dragonfly-fixes

Conversation

@chitao1234

Copy link
Copy Markdown
Contributor

Description

Improve DragonFly BSD support by fixing existing ABI definitions, fix typo'd constant names, fix constant values, moving BSD constants that are not actually generic down into target modules, and adding missing DragonFly constants and libc declarations.

This also expands libc-test coverage for DragonFly and makes the tests handle older DragonFly headers with test-only version skips. The public libc API remains version-independent for DragonFly.

Sources

Primary API references are DragonFly BSD 6.4 release headers, using tag v6.4.0 (commit af5fb9a9e56f90cf51e48514d1874be61e9364e6). The same definitions and test behavior were cross-checked against DragonFly 6.2, 6.0, and 5.8 where older headers differ or omit newer symbols.

ABI/type definitions:

Constants and functions:

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

Tested on DragonFly 5.8.3, 6.0.1, 6.2.2, 6.4.2 with self-built Rust/Cargo 1.95.0, Rust 1.95.0 on DragonFly 5.8.3 needs patches.

There is actually a KERN_MAXID, but the same constant is also present and non-deprecated on both nto and apple.

@rustbot label +stable-nominated

@rustbot

rustbot commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in a NetBSD-like module

cc @semarie

@rustbot rustbot added ctest Issues relating to the ctest crate S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels May 26, 2026
@JohnTitor

Copy link
Copy Markdown
Member

Could you extract ctest changes as another PR? It's independent with dragonflyBSD changes.

@JohnTitor

Copy link
Copy Markdown
Member

@rustbot author

@rustbot

rustbot commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@chitao1234

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@JohnTitor JohnTitor removed the ctest Issues relating to the ctest crate label Jun 15, 2026
Comment thread libc-test/build.rs
Comment on lines +1690 to +1718
// Kernel-only symbols in DragonFly headers.
"DTYPE_VNODE" | "DTYPE_SOCKET" | "DTYPE_PIPE" | "DTYPE_FIFO" | "DTYPE_KQUEUE"
| "DTYPE_CRYPTO" | "DTYPE_MQUEUE" | "DTYPE_DMABUF" => true,

// Not exposed by current DragonFly userland headers.
"REG_DUMP"
| "REG_ASSERT"
| "REG_ATOI"
| "REG_ITOA"
| "REG_TRACE"
| "REG_LARGE"
| "IP_ADD_SOURCE_MEMBERSHIP"
| "IP_DROP_SOURCE_MEMBERSHIP"
| "IP_BLOCK_SOURCE"
| "IP_UNBLOCK_SOURCE"
| "MAP_RENAME"
| "MAP_NORESERVE"
| "CTL_UNSPEC"
| "KERN_PROF"
| "CTL_P1003_1B_UNUSED1"
| "CTL_P1003_1B_SEM_VALUE_MAX"
| "DOWNTIME"
| "SF_CACHE" => true,

// libc exposes the 6.0-compatible value for this version-dependent mask.
"KERN_PROC_FLAGMASK" => true,

// Renamed in current DragonFly headers.
"CPUCTL_RSMSR" | "UTX_DB_LASTLOG" => true,

@tgross35 tgross35 Jun 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since dragonfly is tier 3, you can make the relevant updates in the library (change or delete as needed) rather than adding test skips.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by moving the freebsd-only pieces.

Comment thread libc-test/build.rs Outdated
Comment thread libc-test/build.rs
if dragonfly_version < 600_000 =>
{
true
}

@tgross35 tgross35 Jun 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 5.x still in active enough use that this is worth worrying about? Per https://www.dragonflybsd.org/releases/ 5.8 is from 2020 and 6.0 was in 2021.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust seems to not have an exact support policy for dragonfly target, so I included 5.8 because dragonfly still has binaries packages for it, while binaries package repo for 5.6 is gone.

@tgross35

Copy link
Copy Markdown
Contributor

It looks like Dragonfly doesn't have a target maintainer, do you have any interest in being added as one? It's pretty much no commitment, just means that people can ping you in the rare occasion that we stumble across Dragonfly-specific questions.

If so, all you need to do is PR rust-lang/rust adding a dragonfly page in https://github.com/rust-lang/rust/tree/f7da3c0d4b3a4cc291f8c800cc61549d27d14c49/src/doc/rustc/src/platform-support based on the template, and link it from the table at https://github.com/rust-lang/rust/blob/f7da3c0d4b3a4cc291f8c800cc61549d27d14c49/src/doc/rustc/src/platform-support.md.

We're trying to make sure every platform has 1-2 documented maintainers so this would be an awesome help if you are interested!

@tgross35

Copy link
Copy Markdown
Contributor

For the above,
@rustbot author

Comment thread libc-test/build.rs
Comment on lines +1840 to +1858
fn parse_dragonfly_version(version: &str) -> Option<u32> {
let version = version.trim();

if let Ok(version) = version.parse::<u32>() {
// DragonFly's __DragonFly_version uses major * 100_000 + minor * 100.
// Accept compact test override spellings like 58, 60, 62, and 602.
return Some(match version {
0..=9 => version * 100_000,
10..=99 => (version / 10) * 100_000 + (version % 10) * 100,
100..=999 => (version / 100) * 100_000 + (version % 100) * 100,
_ => version,
});
}

let mut pieces = version.split(['.', '-']);
let major = pieces.next()?.parse::<u32>().ok()?;
let minor = pieces.next()?.parse::<u32>().ok()?;
Some(major * 100_000 + minor * 100)
}

@tgross35 tgross35 Jun 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this constant available in a header? If so, once #5188 merges you'll be able to use that similar to __FreeBSD_version rather than needing uname, in the rare case that host and target differ.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, DragonFly does expose a __DragonFly_version macro in both <sys/param.h> and <osreldate.h>. On my DragonFly 5.8, 6.0, 6.2, and 6.4 machine it has value 500800, 600000, 600200, and 600401. so it should be able to use the same header-based version detection in #5188.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That PR landed so you can add a field to Versions and update init_from_cc, then drop which_dragonfly

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

Comment thread src/unix/bsd/mod.rs Outdated
Comment thread src/unix/bsd/freebsdlike/mod.rs Outdated
Comment thread src/unix/bsd/freebsdlike/dragonfly/mod.rs Outdated
Comment thread libc-test/build.rs Outdated
Comment thread libc-test/build.rs Outdated
Comment thread libc-test/build.rs
@tgross35

Copy link
Copy Markdown
Contributor

I found some style things that I'd appreciate addressing in this PR, but feel free to address the changes/removal in #5116 (comment) in a followup if that's easier since this is pretty much already done.

Also: we can't run CI here since DragonFly is Tier 3, but if you're interested in running CI yourself we have #5209 now to make that a bit easier. (Possibly via https://github.com/vmactions, should be easy to set up similar to our existing test_tier2_vm jobs)

@rustbot

This comment has been minimized.

Fix DragonFly type aliases and struct layouts to match current headers, including regex offsets, ifaddrs, pthread barriers, process sizing fields, and mcontext alignment.
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 8e1069b)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit fab9366)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 6a87bac)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 7483748)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
Fix DragonFly type aliases and struct layouts to match current headers, including regex offsets, ifaddrs, pthread barriers, process sizing fields, and mcontext alignment.

(backport <rust-lang#5116>)
(cherry picked from commit 8f8ce99)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 8e1069b)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit fab9366)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
[ dropped `fexecve` skip that is redundant on this branch (skipped
  above) - Trevor ]

(backport <rust-lang#5116>)
(cherry picked from commit 6a87bac)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 7483748)
This was referenced Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
Fix DragonFly type aliases and struct layouts to match current headers, including regex offsets, ifaddrs, pthread barriers, process sizing fields, and mcontext alignment.

(backport <rust-lang#5116>)
(cherry picked from commit 8f8ce99)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 8e1069b)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit fab9366)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
[ dropped `fexecve` skip that is redundant on this branch (skipped
  above) - Trevor ]

(backport <rust-lang#5116>)
(cherry picked from commit 6a87bac)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5116>)
(cherry picked from commit 7483748)
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants