Skip to content

Add GRDB+Swift 5.7 #792

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 2 commits into from
Apr 13, 2023
Merged

Add GRDB+Swift 5.7 #792

merged 2 commits into from
Apr 13, 2023

Conversation

groue
Copy link
Contributor

@groue groue commented Mar 25, 2023

Pull Request Description

Hello, this pull request adds compatibility check for GRDB with Swift 5.0, 5.1, 5.3, and 5.7.

Compatibility with Swift 5.3 had been added by #574, but it was reverted for some reason (???). This PR restores the deleted compatibility checks.

Acceptance Criteria

To be accepted into the Swift source compatibility test suite, a project must:

  • be an Xcode or swift package manager project
  • support building on either Linux or macOS
  • target Linux, macOS, or iOS/tvOS/watchOS device
  • be contained in a publicly accessible git repository
  • maintain a project branch that builds against Swift 4.0 and passes any unit tests
  • have maintainers who will commit to resolve issues in a timely manner
  • be compatible with the latest GM/Beta versions of Xcode and swiftpm
  • add value not already included in the suite
  • be licensed with one of the following permissive licenses:
    • BSD
    • MIT
    • Apache License, version 2.0
    • Eclipse Public License
    • Mozilla Public License (MPL) 1.1
    • MPL 2.0
    • CDDL
  • pass ./project_precommit_check script run
$ ./project_precommit_check GRDB.swift --earliest-compatible-swift-version 5.7
** CHECK **
--- Validating GRDB.swift Swift version 5.7 compatibility ---
--- Project configured to be compatible with Swift 5.7 ---
--- Checking GRDB.swift platform compatibility with Darwin ---
--- Platform compatibility check succeeded ---
--- Locating swiftc executable ---
$ xcrun -f swiftc
--- Checking installed Swift version ---
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version
swift-driver version: 1.62.15 --- Version check failed ---
Expected version:
Apple Swift version 5.7.0 (swiftlang-5.7.0.123.8 clang-1400.0.29.50)
Target: x86_64-apple-darwin22.3.0

Current version:
Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0

warning: Unexpected swiftc version. Expected swiftc for Swift 5.7 can be found in Xcode 14.0 (contains Swift 5.7.0).
warning: Continuing to build with unexpected swiftc version.

--- Executing build actions ---
$ /Users/groue/Documents/git/groue/swift-source-compat-suite/runner.py --swift-branch swift-5.7-branch --swiftc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --projects /Users/groue/Documents/git/groue/swift-source-compat-suite/projects.json --include-repos 'path == "GRDB.swift"' --include-versions 'version == "5.7"' --include-actions 'action.startswith("Build")'
Building 1 projects across 10 parallel processes

PASS: GRDB.swift, 5.7, 2d19ca, Swift Package
========================================
Action Summary:
     Passed: 1
     Failed: 0
    XFailed: 0
    UPassed: 0
      Total: 1
========================================
Repository Summary:
      Total: 1
========================================
Result: PASS
========================================
--- GRDB.swift checked successfully against Swift 5.7 ---

Also, restore swiftlang#574 which had been reverted for some reason, leaving only support for Swift 4.2 compatibility :-(
@groue
Copy link
Contributor Author

groue commented Mar 25, 2023

@shahmishal, sorry for quoting you, but according to my experience from #574, the CI won't do anything until you trigger it as in this comment. This PR is useful in the context of [Pitch] Elide some in Swift 6 (see this comment). I'm somewhat worried by the fact that this repo has lost my previous contributions, so I'd be relieved to see GRDB well protected against breaking language changes. 😬

@groue
Copy link
Contributor Author

groue commented Mar 31, 2023

Hello @shahmishal, @justice-adams-apple. What can I do to have this PR merged?

@justice-adams-apple
Copy link
Collaborator

@groue Sorry for late response! I'll kick off the testing now and get this in soon. Could you elaborate on

I'm somewhat worried by the fact that this repo has lost my previous contributions

Did something you committed previously get removed?

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

projects.json Outdated
}
},
{
"version": "5.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@groue Ok I did some digging, I see that #613 removed the revisions for 5.0, 5.1, and 5.3 by mistake.

The source compat suite will pass the language major version to the compiler. So the swift build will use -swift-version 5 for each of these GRDB versions you listed, meaning each entry will be built the same way (although with different repository revisions), I'm not sure if that's what you intended. If you want to build all these various GRDB revisions the same way (with -swift-version 5), then leave it as is.

If you want to build just one revision of GRDB with -swift-version 5, I'd recommend just one entry with your most recent commit, namely

       {
         "version": "5.7",
         "commit": "2d19cab2b525f885ee8d7efec96093431f6b5f20"
       }

It's up to you, as I'm not sure about the nature of the commit revisions in question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @justice-adams-apple :-)

It's up to you, as I'm not sure about the nature of the commit revisions in question

Thanks for the precision :-) The version I care about is the latest, but the library has changed a lot in years, so I'd rather keep a few old versions here - for the sake of compatibility testing :-)

I have pushed a fix, e1e956a, with the latest commit supported by each language version.

with the latest commit supported by each language version
@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@groue
Copy link
Contributor Author

groue commented Apr 11, 2023

Is there anything I should change in the pull request?

@justice-adams-apple
Copy link
Collaborator

justice-adams-apple commented Apr 11, 2023

@groue the projet is currently failing to build with

wift-source-compat-suite/project_cache/GRDB.swift/GRDB/Core/DatabaseSnapshotPool.swift:137:24: error: cannot find 'sqlite3_snapshot_open' in scope
            let code = sqlite3_snapshot_open(db.sqliteConnection, "main", walSnapshot.sqliteSnapshot)
error: fatalError

I believe (correct me if I'm wrong) this is due to our need to update the SDK used in our open source CI system, which we are planning to do by the end of this week. So the plan is to update the SDK, then merge this :)

@groue
Copy link
Contributor Author

groue commented Apr 11, 2023

Thanks for the feedback, @justice-adams-apple :-)

I believe (correct me if I'm wrong) this is due to our need to update the SDK used in our open source CI system [...]

I think you're right.

sqlite3_snapshot_open is quite a special SQLite api. I remember asking for it in FB9793771 ;-)

It is guarded, in GRDB code, by this compiler condition:

#if SQLITE_ENABLE_SNAPSHOT || (!GRDBCUSTOMSQLITE && !GRDBCIPHER && (compiler(>=5.7.1) || !(os(macOS) || targetEnvironment(macCatalyst))))

The capitalized flags test for various flavors of SQLite (custom build or SQLCipher) that are unrelated to compatibility checking - we can forget about them.

Remains compiler(>=5.7.1) || !(os(macOS) || targetEnvironment(macCatalyst)).

This complex test is necessary for the macOS SDK that ships with Xcode 14.0 very specifically. Maybe you remember, but N.0 Xcode versions ship with weird sdks (new stuff, and old stuff at the same time). Things were fixed in Xcode 14.0.1.

I'm pretty sure this is the problem: the SDK used for compatibility testing misses sqlite3_snapshot_open, but is not detected by the above condition.

So the plan is to update the SDK, then merge this :)

☺️

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@shahmishal
Copy link
Member

  | PASS_GRDB.swift_4.2_BuildSwiftPackage.log 
  | PASS_GRDB.swift_5.1_BuildSwiftPackage.log
  | PASS_GRDB.swift_5.3_BuildSwiftPackage.log
  | PASS_GRDB.swift_5.7_BuildSwiftPackage.log

@shahmishal shahmishal merged commit a6eeca4 into swiftlang:main Apr 13, 2023
@groue
Copy link
Contributor Author

groue commented Apr 13, 2023

Thank you very much!

@groue groue mentioned this pull request Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants