Skip to content

Conversation

@etcwilde
Copy link
Member

The FreeBSD builds are currently using the GlibC modulemap to import the C runtimes. FreeBSD does not have gnu_get_libc_version resulting in build failures.

The use of this API was introduced in #1147

Copy link
Contributor

@grynspan grynspan left a comment

Choose a reason for hiding this comment

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

I thought the module was supposed to be named FreeBSD since they don't use Glibc? Ah well.

@grynspan grynspan added bug 🪲 Something isn't working workaround Workaround for an issue in another component (may need to revert later) exit-tests ☠️ Work related to exit tests freebsd 😈 FreeBSD support attachments/activities 🖇️ Work related to attachments and/or activities labels Jun 27, 2025
@grynspan grynspan added this to the Swift 6.x (main) milestone Jun 27, 2025
@grynspan
Copy link
Contributor

@swift-ci test

@etcwilde
Copy link
Member Author

I thought the module was supposed to be named FreeBSD since they don't use Glibc? Ah well.

Yes, we should create a new module and module map for FreeBSD and call it something else, but since everything piggybacks on the Glibc module map, it was convenient to avoid re-writing the #if canImport(<insert libc here>) chains across the project.

@grynspan
Copy link
Contributor

Holding off on merging until we know if we need to make OpenBSD changes too.

FreeBSD and OpenBSD currently use the Glibc modulemap to import the C
runtimes so `canImport(Glibc)` returns true. These systems are not
actually glibc though and do not have the `gnu_get_libc_version`
extension, resulting in build failures.

Gating the use of the API on more than glibc to allow these platforms to
compile.
// and https://www.austingroupbugs.net/view.php?id=411).
_ = posix_spawn_file_actions_adddup2(fileActions, fd, fd)
#if canImport(Glibc)
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of some DeMorgan? && !(os(FreeBSD) || os(OpenBSD))

Copy link
Member Author

Choose a reason for hiding this comment

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

It's equivalent. ¯\_(ツ)_/¯
I don't have a preference for or against it. I'm not sure it substantially helps readability here though.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's here is how I would have typed it. Although now it's annoying me and I'd probably rewrite the whole line as #if SWT_USES_GLIBC and define that in CMake and SPM as "the target is Linux". At least until we fix the name of the module elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Then you might have issues for musl platforms :)

In any event: given the 6.2 branch has this problem as well, I'd suggest improving the form of the conditional in a separate pr may be more pragmatic, however.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't win!

Copy link
Member Author

Choose a reason for hiding this comment

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

With CMake, we can ask it to tell us if the symbol is available and define the macro that way. https://cmake.org/cmake/help/v4.1/module/CheckSymbolExists.html

Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably not worth the effort—this is mostly me griping about the module name.

// and https://www.austingroupbugs.net/view.php?id=411).
_ = posix_spawn_file_actions_adddup2(fileActions, fd, fd)
#if canImport(Glibc)
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
Copy link
Member

Choose a reason for hiding this comment

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

Then you might have issues for musl platforms :)

In any event: given the 6.2 branch has this problem as well, I'd suggest improving the form of the conditional in a separate pr may be more pragmatic, however.

@grynspan grynspan added the openbsd 🐡 OpenBSD support label Jul 2, 2025
@grynspan
Copy link
Contributor

grynspan commented Jul 2, 2025

@swift-ci test

@grynspan
Copy link
Contributor

grynspan commented Jul 2, 2025

@etcwilde Thus is ready to squashmerge, yes?

@etcwilde etcwilde merged commit 79c22ad into swiftlang:main Jul 2, 2025
3 checks passed
@etcwilde
Copy link
Member Author

etcwilde commented Jul 2, 2025

Merged, now to pick some cherries.

etcwilde added a commit to etcwilde/swift-testing that referenced this pull request Jul 2, 2025
The FreeBSD builds are currently using the GlibC modulemap to import the
C runtimes. FreeBSD does not have `gnu_get_libc_version` resulting in
build failures.

The use of this API was introduced in
swiftlang#1147

(cherry picked from commit 79c22ad)

- **Explanation**:
  The FreeBSD builds are currently using the GlibC modulemap to import the
  C runtimes. FreeBSD does not have `gnu_get_libc_version` resulting in
  build failures.
- **Scope**: Build failure on platforms using Glibc modulemap that don't
  have GNU extensions. (FreeBSD, OpenBSD)
- **Issues**: swiftlang#1193
- **Original PRs**: swiftlang#1183
- **Risk**: Low risk. Removes use of unavailable API.
- **Testing**: Built swift-testing on FreeBSD and Linux.
- **Reviewers**: @grynspan @3405691582

Fixes: swiftlang#1193
etcwilde added a commit that referenced this pull request Jul 2, 2025
The FreeBSD builds are currently using the GlibC modulemap to import the
C runtimes. FreeBSD does not have `gnu_get_libc_version` resulting in
build failures.

The use of this API was introduced in
#1147

(cherry picked from commit 79c22ad)

- **Explanation**: The FreeBSD builds are currently using the GlibC
modulemap to import the C runtimes. FreeBSD does not have
`gnu_get_libc_version` resulting in build failures.
- **Scope**: Build failure on platforms using Glibc modulemap that don't
have GNU extensions. (FreeBSD, OpenBSD)
- **Issues**: #1193
- **Original PRs**: #1183
- **Risk**: Low risk. Removes use of unavailable API.
- **Testing**: Built swift-testing on FreeBSD and Linux.
- **Reviewers**: @grynspan @3405691582

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

Labels

attachments/activities 🖇️ Work related to attachments and/or activities bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests freebsd 😈 FreeBSD support openbsd 🐡 OpenBSD support workaround Workaround for an issue in another component (may need to revert later)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants