Skip to content

Commit

Permalink
Add support for linux gnu build targets (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova authored Nov 11, 2024
2 parents 35ae7a2 + c561fa5 commit 3a767f5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ We use [`zig`][zig] to build Vere, which is packaged as a single binary,

## Supported Targets

Main (`-Dall`) targets:
- `aarch64-linux-musl`
- `x86_64-linux-musl`
- `aarch64-macos`
- `x86_64-macos`

Additional targets:
- `aarch64-linux-gnu`
- `x86_64-linux-gnu`

## Prerequisites

Install version 0.13.0 of `zig` with the package manager of your choosing, e.g., `brew install zig`, or download the binary from [here][zig-download].
Expand Down
11 changes: 9 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ const std = @import("std");

const VERSION = "3.2";

const targets: []const std.Target.Query = &.{
const main_targets = .{
.{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = null },
.{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = null },
.{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl },
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
};

const supported_targets: []const std.Target.Query = &(main_targets ++ .{
.{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .gnu },
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .gnu },
});

const targets: []const std.Target.Query = &main_targets;

const BuildCfg = struct {
version: []const u8,
pace: []const u8,
Expand All @@ -22,7 +29,7 @@ const BuildCfg = struct {
};

pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{ .whitelist = targets });
const target = b.standardTargetOptions(.{ .whitelist = supported_targets });
var optimize = b.standardOptimizeOption(.{});

//
Expand Down
3 changes: 2 additions & 1 deletion ext/avahi/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ pub fn build(b: *std.Build) void {
avahi.root_module.addCMacro("HAVE_DBUS_CONNECTION_CLOSE", "0");
avahi.root_module.addCMacro("HAVE_EXPAT_H", "1");
avahi.root_module.addCMacro("HAVE_CONFIG_H", "1");
avahi.root_module.addCMacro("HAVE_STRLCPY", "1");
if (!t.isGnu())
avahi.root_module.addCMacro("HAVE_STRLCPY", "1");

const avahi_config_h = b.addConfigHeader(.{
.style = .blank,
Expand Down
4 changes: 4 additions & 0 deletions ext/h2o/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ pub fn build(b: *std.Build) !void {
.files = &.{"cloexec.c"},
.flags = &.{
"-fno-sanitize=all",
if (t.isGnu())
"-D_GNU_SOURCE"
else
"",
},
});

Expand Down

0 comments on commit 3a767f5

Please sign in to comment.