Skip to content

Fix build failure when building with pre-6.2 toolchain due to unrecognized unsafe keyword#1093

Merged
stmontgomery merged 1 commit into
swiftlang:mainfrom
stmontgomery:fix-6.1-unsafe-keyword-usage
Apr 24, 2025
Merged

Fix build failure when building with pre-6.2 toolchain due to unrecognized unsafe keyword#1093
stmontgomery merged 1 commit into
swiftlang:mainfrom
stmontgomery:fix-6.1-unsafe-keyword-usage

Conversation

@stmontgomery

Copy link
Copy Markdown
Contributor

This fixes another bit of fallout from #1069 when building this project's test targets with a 6.1 (or any pre-6.2) toolchain.

The unsafe keyword was introduced in 6.2 as part of SE-0458: Opt-in Strict Memory Safety Checking. Older toolchains are not aware of it, so the fix is to avoid emitting expressions involving that keyword when the macro plugin has been built using an older toolchain.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

@stmontgomery stmontgomery added bug 🪲 Something isn't working workaround Workaround for an issue in another component (may need to revert later) build 🧱 Affects the project's build configuration or process labels Apr 23, 2025
@stmontgomery stmontgomery added this to the Swift 6.x milestone Apr 23, 2025
@stmontgomery stmontgomery self-assigned this Apr 23, 2025
@stmontgomery

Copy link
Copy Markdown
Contributor Author

@swift-ci please test 6.1

@stmontgomery

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@grynspan

Copy link
Copy Markdown
Contributor

When building from source locally with the release 6.1 toolchain, I'm seeing the compiler continue to complain that "Attribute requires '-enable-experimental-feature AllowUnsafeAttribute'" on __requiringUnsafe(). So I think we need to guard the @unsafe attribute there with:

#if hasFeature(AllowUnsafeAttribute)
@unsafe
#endif

@stmontgomery

Copy link
Copy Markdown
Contributor Author

When building from source locally with the release 6.1 toolchain, I'm seeing the compiler continue to complain that "Attribute requires '-enable-experimental-feature AllowUnsafeAttribute'" on __requiringUnsafe()

That should be fixed by #1084. Or, are you saying your local checkout has that fix but you're still seeing this error? With that fix plus this PR, I am able to build using the 6.1 release toolchain successfully.

@grynspan

grynspan commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

I have main checked out and I see the diagnostic with:

> swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
> Target: arm64-apple-macosx15.0

I see the diagnostic on this branch too.

Did a clean build and it's gone. Disregard!

@stmontgomery

Copy link
Copy Markdown
Contributor Author

The macOS and Linux CI failures are expected to be resolved by swiftlang/swift#80830, but the release of a new main snapshot toolchain is currently blocked for unrelated reasons. Proceeding to merge.

@stmontgomery stmontgomery added the macros 🔭 Related to Swift macros such as @Test or #expect label Apr 24, 2025
@stmontgomery stmontgomery merged commit cacb295 into swiftlang:main Apr 24, 2025
@stmontgomery stmontgomery deleted the fix-6.1-unsafe-keyword-usage branch April 24, 2025 03:29
@stmontgomery stmontgomery modified the milestones: Swift 6.x, Swift 6.2 Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working build 🧱 Affects the project's build configuration or process macros 🔭 Related to Swift macros such as @Test or #expect 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.

3 participants