zig v0.10 compatibility

This commit is contained in:
Motiejus Jakštys 2022-11-20 13:33:05 +02:00
parent ff814a474b
commit 422c264df9
3 changed files with 17 additions and 13 deletions

View File

@ -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/

View File

@ -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");
}

View File

@ -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