From 422c264df93316d236e27a10535a858db0e6e7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sun, 20 Nov 2022 13:33:05 +0200 Subject: [PATCH] zig v0.10 compatibility --- README.md | 13 +++++++------ build.zig | 15 ++++++++------- docs/development.md | 2 ++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index deb23e7..ca904b8 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,18 @@ Project status The project is finished and is not recommended for production; just use nscd. Turbonss duly implements the full user/group API in `src/libnss.zig`: feel free -to copy that. +to copy that. turbonss is only 2-5 times faster than nscd, which usually does +not matter (including for my original use case). Yours truly (the author) worked on this for about 7 months. And when this was finished it turned out that just slapping nscd on top of the existing NSS -implementation is almost as fast as this. +implementation is fast enough. Dependencies ------------ -1. zig nightly compiler (0.10 should work when it comes out). +1. zig v0.10. turbonss uses stage1 (the C++ version) and is not compatible with + stage2. 2. [cmph][cmph]: bundled with this repository. Trying it out @@ -40,8 +42,8 @@ Trying it out Clone, compile and test first: $ git clone --recursive https://git.sr.ht/~motiejus/turbonss - $ zig build -fstage1 test - $ zig build -fstage1 -Dtarget=x86_64-linux-gnu.2.31 -Dcpu=x86_64_v3 -Drelease-safe=true + $ zig build test + $ zig build -Dtarget=x86_64-linux-gnu.2.31 -Dcpu=x86_64_v3 -Drelease-safe=true One may choose different options, depending on requirements. Here are some hints: @@ -152,7 +154,6 @@ Documentation Architecture is detailed in `docs/architecture.md` Development notes are in `docs/development.md` -[git-subtrac]: https://apenwarr.ca/log/20191109 [nsswitch]: https://linux.die.net/man/5/nsswitch.conf [id]: https://linux.die.net/man/1/id [cmph]: http://cmph.sourceforge.net/ diff --git a/build.zig b/build.zig index ca81e67..8396b61 100644 --- a/build.zig +++ b/build.zig @@ -5,6 +5,7 @@ const zbs = std.build; pub fn build(b: *zbs.Builder) void { const target = b.standardTargetOptions(.{}); const mode = b.standardReleaseOptions(); + b.use_stage1 = true; const strip = b.option(bool, "strip", "Omit debug information") orelse false; @@ -44,8 +45,8 @@ pub fn build(b: *zbs.Builder) void { cmph.strip = strip; cmph.compress_debug_sections = .zlib; cmph.omit_frame_pointer = true; - cmph.addIncludeDir("deps/cmph/src"); - cmph.addIncludeDir("include/deps/cmph"); + cmph.addIncludePath("deps/cmph/src"); + cmph.addIncludePath("include/deps/cmph"); const bdz = b.addStaticLibrary("bdz", null); bdz.setTarget(target); @@ -61,8 +62,8 @@ pub fn build(b: *zbs.Builder) void { //"-DDEBUG", }); bdz.omit_frame_pointer = true; - bdz.addIncludeDir("deps/cmph/src"); - bdz.addIncludeDir("include/deps/cmph"); + bdz.addIncludePath("deps/cmph/src"); + bdz.addIncludePath("include/deps/cmph"); { const exe = b.addExecutable("turbonss-unix2db", "src/turbonss-unix2db.zig"); @@ -98,7 +99,7 @@ pub fn build(b: *zbs.Builder) void { exe.strip = strip; exe.linkLibC(); exe.linkLibrary(bdz); - exe.addIncludeDir("deps/cmph/src"); + exe.addIncludePath("deps/cmph/src"); exe.setTarget(target); exe.setBuildMode(mode); exe.install(); @@ -116,7 +117,7 @@ pub fn build(b: *zbs.Builder) void { so.strip = strip; so.linkLibC(); so.linkLibrary(bdz); - so.addIncludeDir("deps/cmph/src"); + so.addIncludePath("deps/cmph/src"); so.setTarget(target); so.setBuildMode(mode); so.install(); @@ -133,5 +134,5 @@ pub fn build(b: *zbs.Builder) void { fn addCmphDeps(exe: *zbs.LibExeObjStep, cmph: *zbs.LibExeObjStep) void { exe.linkLibC(); exe.linkLibrary(cmph); - exe.addIncludeDir("deps/cmph/src"); + exe.addIncludePath("deps/cmph/src"); } diff --git a/docs/development.md b/docs/development.md index 21d4b51..c9f2082 100644 --- a/docs/development.md +++ b/docs/development.md @@ -35,3 +35,5 @@ This project uses [git subtrac][git-subtrac] for managing dependencies. They work just like regular submodules, except all the refs of the submodules are in this repository. Repeat after me: all the submodules are in this repository. So if you have a copy of this repo, dependencies will not disappear. + +[git-subtrac]: https://apenwarr.ca/log/20191109