Skip to content

Dragonfly fixes#5116

Open
chitao1234 wants to merge 10 commits into
rust-lang:mainfrom
chitao1234:dragonfly-fixes
Open

Dragonfly fixes#5116
chitao1234 wants to merge 10 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

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

@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

@rustbot

This comment has been minimized.

@rustbot

rustbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment thread src/unix/bsd/mod.rs
Comment on lines 409 to -442
@@ -430,7 +427,6 @@ pub const REG_ESPACE: c_int = 12;
pub const REG_BADRPT: c_int = 13;
pub const REG_EMPTY: c_int = 14;
pub const REG_ASSERT: c_int = 15;
pub const REG_INVARG: c_int = 16;
pub const REG_ATOI: c_int = 255;
pub const REG_ITOA: c_int = 0o0400;

@@ -439,7 +435,6 @@ pub const REG_NOTEOL: c_int = 0o00002;
pub const REG_STARTEND: c_int = 0o00004;
pub const REG_TRACE: c_int = 0o00400;
pub const REG_LARGE: c_int = 0o01000;
pub const REG_BACKR: c_int = 0o02000;

@tgross35 tgross35 Jun 25, 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.

Commit "bsd: move target-specific regex and getrandom constants": could you just copy this whole block to each module? Means some duplicates but that keeps things easier to read.

View changes since the review

Comment on lines -1449 to 1448
pub const GRND_NONBLOCK: c_uint = 0x1;
pub const GRND_RANDOM: c_uint = 0x2;
pub const GRND_INSECURE: c_uint = 0x4;

@tgross35 tgross35 Jun 25, 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.

Comment on lines 698 to +1087
@@ -1080,7 +1082,9 @@ pub const DOWNTIME: c_short = 11;
// utmpx database types
pub const UTX_DB_UTMPX: c_uint = 0;
pub const UTX_DB_WTMPX: c_uint = 1;
pub const UTX_DB_LASTLOG: c_uint = 2;
pub const UTX_DB_LASTLOGX: c_uint = 2;
#[deprecated(since = "1.0", note = "Replaced on DragonFly by UTX_DB_LASTLOGX")]
pub const UTX_DB_LASTLOG: c_uint = UTX_DB_LASTLOGX;

@tgross35 tgross35 Jun 25, 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.

Commit "dragonfly: add compatibility aliases for renamed constants": change deprecated to 0.2.187, so it shows up in the next release. Or just remove these if they have been deleted on Dragonfly.

View changes since the review

Comment thread libc-test/build.rs
_ => false,
}
});
cfg.alias_is_c_enum(move |e| matches!(e, "lwpstat" | "procstat"));

@tgross35 tgross35 Jun 25, 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.

Commit "libc-test: expand DragonFly coverage": Nit: use match e { ... } rather than matches!, this is easier to keep in sync as there are additions or removals.

View changes since the review

Comment thread libc-test/build.rs Outdated
Comment on lines +1834 to +1844
cfg.skip_roundtrip(move |ty| {
matches!(
ty,
"kvm_t"
| "posix_spawnattr_t"
| "posix_spawn_file_actions_t"
| "umtx_t"
| "pmap"
| "ip_mreq_source"
)
});

@tgross35 tgross35 Jun 25, 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.

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.

Nevermind this one, looks like it goes away in the last commit

Comment thread libc-test/build.rs

@tgross35 tgross35 Jun 25, 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.

Commit "style: fix DragonFly CI checks": please squash this one, think it can just go into the previous commit

View changes since the review

@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

rustbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #5218) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants