Skip to content

Unbreak FreeBSD cross-build on MacOS broken in 051460b8b #16167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2024

Conversation

mmatuska
Copy link
Contributor

@mmatuska mmatuska commented May 5, 2024

Motivation and Context

Fix FreeBSD cross-build on MacOS broken in 051460b
Minimizing code diff between OpenZFS and FreeBSD

Description

MacOS used FreeBSD-compatible getprogname() and pthread_getname_np(). But pthread_getthreadid_np() does not exist on MacOS. This implements libspl_gettid() using pthread_threadid_np() to get the thread id of the current thread.

How Has This Been Tested?

Tested with FreeBSD GitHub actions
freebsd/freebsd-src@3c1be0b
https://github.com/freebsd/freebsd-src/actions/runs/8946387771/job/24576944970
https://github.com/freebsd/freebsd-src/actions/runs/8946387771/job/24576945408

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

MacOS used FreeBSD-compatible getprogname() and pthread_getname_np().
But pthread_getthreadid_np() does not exist on MacOS. This implements
libspl_gettid() using pthread_threadid_np() to get the thread id
of the current thread.

Tested with FreeBSD GitHub actions
freebsd-src/.github/workflows/cross-bootstrap-tools.yml

Signed-off-by: Martin Matuska <[email protected]>
@mmatuska
Copy link
Contributor Author

mmatuska commented May 5, 2024

@robn if you have a better solution, I am of course open for it

Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

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

Interesting. If this gets things moving, I'm ok with it, so approved.

I'm interested in what you're actually doing though. Are you compiling for FreeBSD on macOS? "cross-build" sounds like yes, but if that's true, I don't understand why __APPLE__ would be defined if you're targetting FreeBSD userspace. But maybe you're compiling FreeBSD userspace on macOS for macOS, and macOS defines __FreeBSD__ as well? Or, something else entirely?

It won't make a difference to this PR, but it might change how I approach a couple of things in the future if __FreeBSD__ is not enough of an indicator of a platform target.

@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label May 7, 2024
@mmatuska
Copy link
Contributor Author

mmatuska commented May 7, 2024

Interesting. If this gets things moving, I'm ok with it, so approved.

I'm interested in what you're actually doing though. Are you compiling for FreeBSD on macOS? "cross-build" sounds like yes, but if that's true, I don't understand why __APPLE__ would be defined if you're targetting FreeBSD userspace. But maybe you're compiling FreeBSD userspace on macOS for macOS, and macOS defines __FreeBSD__ as well? Or, something else entirely?

It won't make a difference to this PR, but it might change how I approach a couple of things in the future if __FreeBSD__ is not enough of an indicator of a platform target.

The kernel-toolchain is compiled as MacOS binaries and libspl is part of it.

@behlendorf behlendorf merged commit 414acbd into openzfs:master May 9, 2024
robn pushed a commit to robn/zfs that referenced this pull request Jul 17, 2024
MacOS used FreeBSD-compatible getprogname() and pthread_getname_np().
But pthread_getthreadid_np() does not exist on MacOS. This implements
libspl_gettid() using pthread_threadid_np() to get the thread id
of the current thread.

Tested with FreeBSD GitHub actions
freebsd-src/.github/workflows/cross-bootstrap-tools.yml

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Signed-off-by: Martin Matuska <[email protected]>
Closes openzfs#16167
(cherry picked from commit 414acbd)
robn pushed a commit to robn/zfs that referenced this pull request Jul 17, 2024
MacOS used FreeBSD-compatible getprogname() and pthread_getname_np().
But pthread_getthreadid_np() does not exist on MacOS. This implements
libspl_gettid() using pthread_threadid_np() to get the thread id
of the current thread.

Tested with FreeBSD GitHub actions
freebsd-src/.github/workflows/cross-bootstrap-tools.yml

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Signed-off-by: Martin Matuska <[email protected]>
Closes openzfs#16167
(cherry picked from commit 414acbd)
@robn robn mentioned this pull request Jul 17, 2024
13 tasks
robn pushed a commit to robn/zfs that referenced this pull request Jul 17, 2024
MacOS used FreeBSD-compatible getprogname() and pthread_getname_np().
But pthread_getthreadid_np() does not exist on MacOS. This implements
libspl_gettid() using pthread_threadid_np() to get the thread id
of the current thread.

Tested with FreeBSD GitHub actions
freebsd-src/.github/workflows/cross-bootstrap-tools.yml

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Signed-off-by: Martin Matuska <[email protected]>
Closes openzfs#16167
(cherry picked from commit 414acbd)
robn pushed a commit to robn/zfs that referenced this pull request Jul 18, 2024
MacOS used FreeBSD-compatible getprogname() and pthread_getname_np().
But pthread_getthreadid_np() does not exist on MacOS. This implements
libspl_gettid() using pthread_threadid_np() to get the thread id
of the current thread.

Tested with FreeBSD GitHub actions
freebsd-src/.github/workflows/cross-bootstrap-tools.yml

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Signed-off-by: Martin Matuska <[email protected]>
Closes openzfs#16167
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
MacOS used FreeBSD-compatible getprogname() and pthread_getname_np().
But pthread_getthreadid_np() does not exist on MacOS. This implements
libspl_gettid() using pthread_threadid_np() to get the thread id
of the current thread.

Tested with FreeBSD GitHub actions
freebsd-src/.github/workflows/cross-bootstrap-tools.yml

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Signed-off-by: Martin Matuska <[email protected]>
Closes openzfs#16167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants