From ef808e9172f2e4fc90cf741c1d872e77fbb7125e Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sat, 13 Mar 2021 21:33:39 +0100 Subject: build: fix building with glibc sqlite3 requires at least glibc 2.28 from my testing; prevent building the tests using anything below that. --- build.zig | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 2c958b9..a1af313 100644 --- a/build.zig +++ b/build.zig @@ -13,7 +13,27 @@ fn linkSqlite(b: *std.build.LibExeObjStep) void { } pub fn build(b: *std.build.Builder) void { - const target = b.standardTargetOptions(.{}); + const target = blk: { + var tmp = b.standardTargetOptions(.{}); + + if (tmp.isGnuLibC()) { + const min_glibc_version = std.builtin.Version{ + .major = 2, + .minor = 28, + .patch = 0, + }; + if (tmp.glibc_version) |ver| { + if (ver.order(min_glibc_version) == .lt) { + std.debug.panic("sqlite requires glibc version >= 2.28", .{}); + } + } else { + tmp.setGnuLibCVersion(2, 28, 0); + } + } + + break :blk tmp; + }; + const mode = b.standardReleaseOptions(); const in_memory = b.option(bool, "in_memory", "Should the tests run with sqlite in memory (default true)") orelse true; -- cgit v1.2.3 From ae1ccc1ebc1bd0b690bc9c1e2cdf5a4b1903eca8 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sat, 13 Mar 2021 21:38:07 +0100 Subject: readme: add a note about minimum glibc version --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 841adfe..aeeff31 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,20 @@ exe.linkLibrary(sqlite); exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" }); ``` +If you're building with glibc you must make sure that the version used is at least 2.28. + +You can do that in your `build.zig` file: +```zig +var target = b.standardTargetOptions(.{}); +target.setGnuLibCVersion(2, 28, 0); +exe.setTarget(target); +``` + +Or with `-Dtarget`: +``` +$ zig build -Dtarget=native-linux-gnu.2.28 +``` + # Usage Import `zig-sqlite` like this: -- cgit v1.2.3