-
-
Notifications
You must be signed in to change notification settings - Fork 711
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
Linux compilation fixes #1401
Linux compilation fixes #1401
Conversation
Hello @kustra! This is a very welcome PR, written with dedication 👍 I'll look into details in the next few days, please hold on :-) |
💝
Totally. It's hard for me to set Linux as an officially supported platform in the long run, because I lack the expertise for testing and debugging it. You address this need below. The risk is that future GRDB versions will break Linux support again.
The main problem is that Swift does not import the C
We also use compiler options for some specific needs. For example, the full-text engine FTS5 is enabled by default with Finally, we use I'm not sure the GRDB code base is 100% consistent in the way it targets one SQLite version or another, because this has grown in an "organic way", and I've learned techniques on the go. In the end, this is not very pretty, and I never took the time to think about a better way to handle this.
This makes Linux similar to SQLCipher, then. Not that this has to stay in that way, but it can help :-)
It certainly is. All
This point aside, the PR is perfect for me. But you may want to grab this opportunity.
👍 I'll have a more detailed look at this section. |
Hello @kustra, Maybe you missed my question about using |
Yep, as soon as the smoke tests succeed, I'll push a commit that removes the legacy logic. I was on holiday with the family, hence my lack of response for the last few days. :) |
👍 Take all the time you want! I was just wondering if I wasn't blocking the PR with my imprecise wording. Now that I know we're synced, I'm relieved! |
I think the cleanest possible solution is to create shims in a C header that's available for all setups, not just CSQLite variant. For all the affected API calls, something along the lines of: int sqlite3_prepare_shim(
sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
#if SQLITE_VERSION_NUMBER >= 3200000
return sqlite3_prepare_v3(...);
#else
return sqlite3_prepare_v2(...);
#endif
} In any case, I think this PR is good to go. :) |
This is a very good idea. I could even replace the existing
Let's merge, then. Thank you very much for your contribution! Would you accept an invitation that grants you a push access to GRDB? I do intend to keep the lead of the project, but it is good for everyone that people of various levels of expertise can improve the repository. Of course, your free time would remain just as free as it was before! |
I contribute to GRDB as part of my work. I may be inactive for long stretches of time. If that's okay, I'll accept. Thank you. :) |
Well, the invitation is sent, and it comes without any obligation of any kind :-) Contributing to this repo is a matter of pleasure, free will, and the desire to build a good companion for app developers. If you want to contribute more, whatever it means, or if your job has specific needs, please tell, and we'll figure out what's best for everybody :-) |
Hello,
I'd like to fix the compilation errors of GRDB 6.15.x on Linux. I've read that it's not officially supported, but that one-off PRs are welcome.
This PR gets the repo to the point where GRDB compiles on Linux with SQLite 3.20.0. Additionally, please find below some of my findings while working on this.
SQLite 3.20.0 conditional compilations
Several places in the code use the following pattern.
When compiling on Linux with SQLite 3.19.3 installed in the system, compilation chooses
new version of the code (2)
. I wonder how to fix this pattern to choose according to the actual SQLite version available.However, this is not a critical issue, as I can just choose to compile using SQLite 3.20.0.
Outdated code?
There's some
#if os(Linux)
blocks around this line:GRDB.swift/GRDB/Core/Database.swift
Line 871 in 284a4ee
I guess this logic assumes that any Linux builds will run SQLite < 3.14.0, but the docs state that the minimum supported SQLite version is 3.19.3, so this logic seems outdated.
Dockerfile for testing
With SQLite 3.19.3. (GRDB doesn't compile with this setup, see above.)
To test with SQLite 3.20.0, just set
ARG sqlite_version
to3200000
. (Which compiles for me.)Build the image - copy-paste the above Dockerfile somewhere, and run from the same folder:
docker rmi -f grdb-build && docker build . -t grdb-build
Then from the repo root, run:
docker run --rm -t -v ".:/src" -w "/src/" grdb-build bash -c "swift package clean && swift build"
Pull Request Checklist
development
branch.make smokeTest
terminal command runs without failure.