add lto and fpic

learning about linkers. Thanks, Drepper
This commit is contained in:
Motiejus Jakštys 2022-11-30 11:56:02 +02:00
parent 0df7d8b722
commit 312e510eff

View File

@ -43,6 +43,7 @@ pub fn build(b: *zbs.Builder) void {
//"-DDEBUG", //"-DDEBUG",
}); });
cmph.strip = strip; cmph.strip = strip;
cmph.want_lto = true;
cmph.compress_debug_sections = .zlib; cmph.compress_debug_sections = .zlib;
cmph.omit_frame_pointer = true; cmph.omit_frame_pointer = true;
cmph.addIncludePath("deps/cmph/src"); cmph.addIncludePath("deps/cmph/src");
@ -60,16 +61,19 @@ pub fn build(b: *zbs.Builder) void {
"-W", "-W",
"-Wno-unused-function", "-Wno-unused-function",
"-fvisibility=hidden", "-fvisibility=hidden",
"-fpic",
//"-DDEBUG", //"-DDEBUG",
}); });
bdz.omit_frame_pointer = true; bdz.omit_frame_pointer = true;
bdz.addIncludePath("deps/cmph/src"); bdz.addIncludePath("deps/cmph/src");
bdz.addIncludePath("include/deps/cmph"); bdz.addIncludePath("include/deps/cmph");
bdz.want_lto = true;
{ {
const exe = b.addExecutable("turbonss-unix2db", "src/turbonss-unix2db.zig"); const exe = b.addExecutable("turbonss-unix2db", "src/turbonss-unix2db.zig");
exe.compress_debug_sections = .zlib; exe.compress_debug_sections = .zlib;
exe.strip = strip; exe.strip = strip;
exe.want_lto = true;
exe.setTarget(target); exe.setTarget(target);
exe.setBuildMode(mode); exe.setBuildMode(mode);
addCmphDeps(exe, cmph); addCmphDeps(exe, cmph);
@ -80,6 +84,7 @@ pub fn build(b: *zbs.Builder) void {
const exe = b.addExecutable("turbonss-analyze", "src/turbonss-analyze.zig"); const exe = b.addExecutable("turbonss-analyze", "src/turbonss-analyze.zig");
exe.compress_debug_sections = .zlib; exe.compress_debug_sections = .zlib;
exe.strip = strip; exe.strip = strip;
exe.want_lto = true;
exe.setTarget(target); exe.setTarget(target);
exe.setBuildMode(mode); exe.setBuildMode(mode);
exe.install(); exe.install();
@ -89,6 +94,7 @@ pub fn build(b: *zbs.Builder) void {
const exe = b.addExecutable("turbonss-makecorpus", "src/turbonss-makecorpus.zig"); const exe = b.addExecutable("turbonss-makecorpus", "src/turbonss-makecorpus.zig");
exe.compress_debug_sections = .zlib; exe.compress_debug_sections = .zlib;
exe.strip = strip; exe.strip = strip;
exe.want_lto = true;
exe.setTarget(target); exe.setTarget(target);
exe.setBuildMode(mode); exe.setBuildMode(mode);
exe.install(); exe.install();
@ -98,6 +104,7 @@ pub fn build(b: *zbs.Builder) void {
const exe = b.addExecutable("turbonss-getent", "src/turbonss-getent.zig"); const exe = b.addExecutable("turbonss-getent", "src/turbonss-getent.zig");
exe.compress_debug_sections = .zlib; exe.compress_debug_sections = .zlib;
exe.strip = strip; exe.strip = strip;
exe.want_lto = true;
exe.linkLibC(); exe.linkLibC();
exe.linkLibrary(bdz); exe.linkLibrary(bdz);
exe.addIncludePath("deps/cmph/src"); exe.addIncludePath("deps/cmph/src");
@ -116,6 +123,7 @@ pub fn build(b: *zbs.Builder) void {
}); });
so.compress_debug_sections = .zlib; so.compress_debug_sections = .zlib;
so.strip = strip; so.strip = strip;
so.want_lto = true;
so.linkLibC(); so.linkLibC();
so.linkLibrary(bdz); so.linkLibrary(bdz);
so.addIncludePath("deps/cmph/src"); so.addIncludePath("deps/cmph/src");