Skip to content

Conversation

@tgross35
Copy link
Contributor

@tgross35 tgross35 commented Oct 27, 2025

The x86-64 NetBSD target is tier 2, so we can start testing it.

Closes: #3890

@rustbot rustbot added the A-CI Area: CI-related items label Oct 27, 2025
@tgross35 tgross35 force-pushed the netbsd-ci branch 7 times, most recently from b1dbf3d to 8b6fa4e Compare October 27, 2025 05:07
@tgross35
Copy link
Contributor Author

There seem to be quite a few failures here, @he32 @0323pin do these failures look accurate? The errors toward the bottom of the CI logs, e.g. POSIX_SPAWN_RESETIDS not being defined. If so, we'll just need to add some test skips until we can deprecate+remove them.

@tgross35
Copy link
Contributor Author

Also, is https://github.com/NetBSD/src/tree/aedc44b2ed927468d4f7bb37cddc443d9077f1de/include the correct location to find all of NetBSD's libc headers?

@tgross35 tgross35 force-pushed the netbsd-ci branch 3 times, most recently from 92e20dc to 6003aeb Compare October 28, 2025 00:47
@rustbot rustbot added the O-unix label Oct 28, 2025
@rustbot rustbot added the O-x86 label Oct 28, 2025
@tgross35 tgross35 force-pushed the netbsd-ci branch 3 times, most recently from 99cac2d to 586ce35 Compare October 28, 2025 02:55
@0323pin
Copy link
Contributor

0323pin commented Oct 28, 2025

@tgross35 wow, thanks for working on this, really appreciated 👍

As for your question, #4782 (comment)

I'm probably not the best person to ask, I think @he32 or, @0-wiz-0 might know this better than me. I usually just use grep to look for headers locally in /usr/include/sys.

@tgross35 tgross35 force-pushed the netbsd-ci branch 2 times, most recently from 5a32179 to 2ada99d Compare October 28, 2025 07:57
@rustbot rustbot added the ctest Issues relating to the ctest crate label Oct 28, 2025
@tgross35 tgross35 force-pushed the netbsd-ci branch 7 times, most recently from 782aaf5 to ca00d5d Compare October 28, 2025 23:16
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
This is not always present when we are building as `rustc-dep-of-std`.

(backport <rust-lang#4782>)
(cherry picked from commit 919d0d4)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
This pattern is currently used by the `freebsd-version` check but will
be used by more in the future.

(backport <rust-lang#4782>)
(cherry picked from commit 91f208c)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Some of these may have been removed. `NI_MAXHOST` is already specified
in the unix semver file.

(backport <rust-lang#4782>)
(cherry picked from commit 60d7ccc)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Currently this target fails to build.

(backport <rust-lang#4782>)
(cherry picked from commit 368df02)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Add headers required for the new constants we have, add skips for things
we can't easily fix, and remove skips for things that now work.

Additionally, check the NetBSD version via `uname` for configuring skips
based on the tested version.

(backport <rust-lang#4782>)
(cherry picked from commit 5634c88)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
These were previously packed, but this was changed in NetBSD10.

Link: NetBSD/src@1ca39e8

(backport <rust-lang#4782>)
(cherry picked from commit 277c0c5)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Upstream commit: NetBSD/src@091e152

(backport <rust-lang#4782>)
(cherry picked from commit 35d5592)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
These assorted constants may have existed at some point but I can't find
any reference to them in the source repo. Remove them now.

(backport <rust-lang#4782>)
(cherry picked from commit 17727db)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
As noted, this has been deprecated a long time and is no longer present
on x86_64. Remove the typedef.

(backport <rust-lang#4782>)
(cherry picked from commit 11d36ae)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
These are currently incorrect, so remove them for now. If desired, they
can be added back in the future using the `_IO*` functions.

(backport <rust-lang#4782>)
(cherry picked from commit 7de84bf)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Upstream commit: NetBSD/src@cc8bab3

(backport <rust-lang#4782>)
(cherry picked from commit b038f17)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
This changed in 10.0. The change is ABI-compatible so we can make it
now.

This is a minor break, but should allow users to remove some special
casing on NetBSD since this brings it in line with other BSDs.

Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/event.h#L72

(backport <rust-lang#4782>)
(cherry picked from commit 14f2bc5)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Our definition was correct for how it is defined internally, but in the
header where it is included it is an incomplete definition.

Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/sched.h#L99

(backport <rust-lang#4782>)
(cherry picked from commit 95e5cdb)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Deprecate the PT_LWPINFO and PL_EVENT* constants, as well as
`ptrace_lwpinfo`.

Upstream commit: NetBSD/src@4f79a48

(backport <rust-lang#4782>)
(cherry picked from commit c4a86e0)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
With NetBSD10 the type changes and fields get adjusted. Make the field
nonpublic now to prepare for this change in the future.

This is a minor breaking change but means that the NetBSD10 updates will
not be breaking.

Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/statvfs.h#L94

(backport <rust-lang#4782>)
(cherry picked from commit d5f4354)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
This went through an ABI change with a symbol version in NetBSD10. Our
version still works but tests don't pass.

Link: NetBSD/src@02cdd24

(backport <rust-lang#4782>)
(cherry picked from commit bf0f52c)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
The field order was incorrect. Update this and move it to `new`, along
with the rest of `utmp`.

As part of this, correct an incorrectly spelled `utpname` to `utmpname`.

Fixes: 42289eb "Implement utmp for NetBSD"

(backport <rust-lang#4782>)
(cherry picked from commit 6a01e2f)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Create a new module for `utmpx` and move definitions there, then correct
`_UTX_PADSIZE`. We can also just use `s!`, there is no need to manually
implement the traits.

NetBSD defines `_UTX_PADSIZE` manually but includes this comment in
their source:

    /*
     * This should be:
     * 40 - (sizeof(struct timeval) - sizeof(struct { long s; long u; })))
     * but g++ does not like it, to retain size compatibility with v1.00,
     * so we do it manually.
     */
    #ifdef _LP64
    #define _UTX_PADSIZE 36
    #else
    #define _UTX_PADSIZE 40
    #endif

I tried using the expression here:

    40 - (size_of::<crate::timeval>() - size_of::<(c_long, c_long)>());

But this returns a value of 8 which doesn't match the expected 36. So,
keep with their source and hardcode the values.

Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/include/utmpx.h#L91-L101

(backport <rust-lang#4782>)
(cherry picked from commit 4055637)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
This is currently defined as an `unsigned int` but should be `int32_t`.
Also move some related definitions `new`.

Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/types.h#L200

(backport <rust-lang#4782>)
(cherry picked from commit 2946483)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Move `timex.h` types to the `new/` module.

(backport <rust-lang#4782>)
(cherry picked from commit fb74b6f)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
The definition of `struct ifreq` didn't match up. Make a new module for
`net/if.h` and fix it there. Note that this drops some trait
implementations since the correct API involves unions.

(backport <rust-lang#4782>)
(cherry picked from commit 8cb1db9)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 4, 2025
Relevant source:

* `devname`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/stdlib.h#L296
* `getutent`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/utmp.h#L70
* `ntp_gettime`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/timex.h#L257
* `sched_rr_get_interval`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/sched.h#L50-L51
* `shmctl`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/shm.h#L2011
* `sig{action,suspend}`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/signal.h#L85-L95
* `{get,set}itimer`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/time.h#L331-L335
* `timer_{get,set}time`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/time.h#L158-L160
* `utmpx` symbols: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/utmpx.h#L135-L150
* `wait4`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/wait.h#L209

Excluded are `__statvfs90`, `__fstatvfs90`, `__sigaction_siginfo`,
`__getmntinfo90`, `__getvfsstat90`which are only present in 10.0+ (the
symbol version seems to be N-1). Source:

* https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/statvfs.h#L160-L168

There is also a deprecated aliases that used to be needed and is removed
here.

* `__getmntinfo13`:  https://github.com/NetBSD/src/blob/62c785e59d064070166dab5d2a4492055effba89/lib/libc/compat/gen/compat___getmntinfo13.c#L49-L50

(backport <rust-lang#4782>)
(cherry picked from commit 1816f60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: CI-related items ctest Issues relating to the ctest crate O-bsd O-riscv O-unix O-x86 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.

Add NetBSD to CI

7 participants