From b635317e2a426074fd28fbf954293efb4e124192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Mon, 20 Feb 2023 23:40:05 +0200 Subject: [PATCH] build: add PIE (Position Independent Executable) option (#1013) * build: add PIE (Position Independent Executable) option --- build.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 6f32e43..1e3d39f 100644 --- a/build.zig +++ b/build.zig @@ -26,6 +26,7 @@ pub fn build(b: *std.build.Builder) !void { const exe_options = b.addOptions(); exe.addOptions("build_options", exe_options); + const pie = b.option(bool, "pie", "Build a Position Independent Executable"); const enable_tracy = b.option(bool, "enable_tracy", "Whether tracy should be enabled.") orelse false; const coverage = b.option(bool, "generate_coverage", "Generate coverage data with kcov") orelse false; const coverage_output_dir = b.option([]const u8, "coverage_output_dir", "Output directory for coverage data") orelse b.pathJoin(&.{ b.install_prefix, "kcov" }); @@ -154,6 +155,7 @@ pub fn build(b: *std.build.Builder) !void { } } + exe.pie = pie; exe.install(); const gen_exe = b.addExecutable(.{ @@ -183,7 +185,7 @@ pub fn build(b: *std.build.Builder) !void { "test-filter", "Skip tests that do not match filter", ); - + var tests = b.addTest(.{ .root_source_file = .{ .path = "tests/tests.zig" }, .target = target,