Skip to content

FreeBSD: No availability OS version #83601

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

Conversation

etcwilde
Copy link
Member

@etcwilde etcwilde commented Aug 7, 2025

Transparent and inlinable declarations had the OS version availability applied to them. This broke some declarations coming from the standard library, specifically _checkExpectedExecutor. Rather than crashing, SILGen silently omits the check, resulting in failing tests, and unchecked code. FreeBSD is not one of the platforms where availability is set up, so clear the availability version number like what is done for all non-Apple platforms.

@etcwilde etcwilde self-assigned this Aug 7, 2025
@etcwilde etcwilde added the FreeBSD Platform: FreeBSD label Aug 7, 2025
@etcwilde etcwilde force-pushed the ewilde/freebsd-blank-availability-versions branch from 3c7fa26 to 3098a6f Compare August 8, 2025 00:25
@etcwilde etcwilde requested a review from DougGregor as a code owner August 8, 2025 00:25
@etcwilde
Copy link
Member Author

etcwilde commented Aug 8, 2025

@swift-ci please test

@etcwilde
Copy link
Member Author

etcwilde commented Aug 8, 2025

[2025-08-08T02:46:09.884Z] /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/test/Parse/diagnose_availability_windows.swift:24:1: error: unexpected error produced: 'windows8()' is only available in Windows 8 or newer
[2025-08-08T02:46:09.884Z] windows8() // expected-no-target-error {{'windows8()' is only available in Windows 8 or newer}}
[2025-08-08T02:46:09.884Z] ^
[2025-08-08T02:46:09.884Z] /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/test/Parse/diagnose_availability_windows.swift:24:1: error: unexpected note produced: add 'if #available' version check
[2025-08-08T02:46:09.884Z] windows8() // expected-no-target-error {{'windows8()' is only available in Windows 8 or newer}}
[2025-08-08T02:46:09.884Z] ^

We're failing in this test because we're consistently dropping the version number on non-Apple platforms. The question now is, do we want to keep the triple version number for windows triples and make the test pass, or do we want to strip it and change the test?

@etcwilde
Copy link
Member Author

etcwilde commented Aug 8, 2025

CC @compnerd for input on how to proceed with getVersionForTriple returning a version for Windows or not.

@compnerd
Copy link
Member

compnerd commented Aug 8, 2025

I think that we want to keep the version tuple around for Windows if it is in the specific position. The problem is that there are two version numbers:

x86_64-unknown-windows10.0.22000.0-msvc14.42.34433

This is alternatively spelt: -target x86_64-unknown-windows-msvc -visualc-tools-version 14.42.34433 -windows-sdk-version 10.0.22621.0 -mmin-windows-version 10.0.22000.0.

@etcwilde
Copy link
Member Author

etcwilde commented Aug 8, 2025

I'm going to trust that LLVM is doing the right thing, since this ultimately falls back there. If it isn't, then that's an LLVM bug.

The definitions of how version numbers were extracted from target
triples split between the minimum platform version and for determining
the minimum inlining version.

This resulted in inlinable and transparent functions not being imported
correctly on non-Apple platforms where the version number is retained as
part of the target triple.
Specifically, `_checkExpectedExecutor` was found in the module, but
didn't have the appropriate availability version assigned, resulting in
it failing to import and the compiler silently omitting the check in
SILGen when compiling for FreeBSD.

This patch refactors the implementation of `getMinPlatformVersion` into
a separate function that is used in both places so that they cannot get
out of sync again.

Note: This changes how Windows is handled. getMinPlatformVersion
returned an empty version number for Windows, while the availability
implementation returned the OS version number. This makes both
consistently return the OS version number.
@etcwilde etcwilde force-pushed the ewilde/freebsd-blank-availability-versions branch from 3098a6f to 3fcca83 Compare August 8, 2025 22:12
@etcwilde
Copy link
Member Author

etcwilde commented Aug 8, 2025

@swift-ci please test

@etcwilde etcwilde merged commit f174185 into swiftlang:main Aug 11, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Merge to Done in Swift on FreeBSD Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FreeBSD Platform: FreeBSD
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants