-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
51 lines (46 loc) · 1.97 KB
/
build.zig
File metadata and controls
51 lines (46 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSafe });
const exe = b.addExecutable(.{
.name = "main",
.target = target,
.optimize = optimize,
});
exe.addCSourceFile(.{
.file = b.path("main.cpp"),
.flags = &[_][]const u8{
"-std=c++17",
"-O3", // Explicit O3 optimization
"-ffast-math",
"-fomit-frame-pointer",
"-funroll-loops",
"-ftree-vectorize",
"-fno-signed-zeros",
"-fno-trapping-math",
"-fno-math-errno",
"-fno-rtti", // Disable runtime type information
"-fno-exceptions", // Disable exception handling
"-fstrict-aliasing", // Enable strict aliasing optimization
"-fno-plt", // Avoid PLT
"-fdata-sections", // Each data in its own section
"-ffunction-sections", // Each function in its own section
"-falign-functions=32", // More reasonable alignment
"-falign-loops=32", // More reasonable alignment
"-fprefetch-loop-arrays", // Enable prefetching in loops
// LLVM-specific optimizations using your working syntax
"-mllvm", "--inline-threshold=500", // Reduced from 1000 for faster build
"-mllvm", "--unroll-threshold=100", // Reduced for faster build
"-mllvm", "--vectorize-loops",
"-mllvm", "--vectorize-slp",
"-mllvm", "--asan-opt", // As per your working flags
"-mllvm", "--keep-loops", // As per your working flags
"-mllvm", "--enable-gvn-hoist",
"-mllvm", "--slp-vectorize-hor=1", // As per your working flags
},
});
exe.linkLibCpp();
exe.want_lto = true; // Enable LTO regardless of build mode
exe.root_module.strip = true;
b.installArtifact(exe);
}