diff options
| author | xavier <xavierb@gmail.com> | 2020-10-07 20:27:35 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-10-07 18:43:05 -0400 |
| commit | eb33394d14e29600d36280b6797de0d8f40076c1 (patch) | |
| tree | b80904044e8207f2c9deaa00c5fd092867611255 /src | |
| parent | a0a834a2f292eb7f4170d590833b5d56084c0468 (diff) | |
| download | zig-eb33394d14e29600d36280b6797de0d8f40076c1.tar.gz zig-eb33394d14e29600d36280b6797de0d8f40076c1.zip | |
notice more kinds of optimization flags and debug flags
Closes #6091
Diffstat (limited to 'src')
| -rw-r--r-- | src/clang_options_data.zig | 40 | ||||
| -rw-r--r-- | src/main.zig | 24 |
2 files changed, 51 insertions, 13 deletions
diff --git a/src/clang_options_data.zig b/src/clang_options_data.zig index bd1237bc00..632857920b 100644 --- a/src/clang_options_data.zig +++ b/src/clang_options_data.zig @@ -75,8 +75,22 @@ flagpd1("M"), .psl = false, }, flagpd1("Mach"), -flagpd1("O0"), -flagpd1("O4"), +.{ + .name = "O0", + .syntax = .flag, + .zig_equivalent = .optimize, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "O4", + .syntax = .flag, + .zig_equivalent = .optimize, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "O", .syntax = .flag, @@ -2163,7 +2177,7 @@ flagpd1("fno-ident"), .{ .name = "Os", .syntax = .flag, - .zig_equivalent = .other, + .zig_equivalent = .optimize, .pd1 = true, .pd2 = false, .psl = true, @@ -3148,7 +3162,14 @@ flagpd1("fxray-link-deps"), flagpd1("fzero-initialized-in-bss"), flagpd1("fzvector"), flagpd1("g0"), -flagpd1("g1"), +.{ + .name = "g1", + .syntax = .flag, + .zig_equivalent = .debug, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("g2"), flagpd1("g3"), .{ @@ -3189,7 +3210,14 @@ flagpd1("ggdb3"), flagpd1("ggnu-pubnames"), flagpd1("ginline-line-tables"), flagpd1("gline-directives-only"), -flagpd1("gline-tables-only"), +.{ + .name = "gline-tables-only", + .syntax = .flag, + .zig_equivalent = .debug, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("glldb"), flagpd1("gmlt"), flagpd1("gmodules"), @@ -5363,7 +5391,7 @@ jspd1("iquote"), joinpd1("weak-l"), .{ .name = "Ofast", - .syntax = .joined, + .syntax = .flag, .zig_equivalent = .optimize, .pd1 = true, .pd2 = false, diff --git a/src/main.zig b/src/main.zig index b89ac3768e..8a3fb72102 100644 --- a/src/main.zig +++ b/src/main.zig @@ -992,15 +992,20 @@ fn buildOutputType( }, .optimize => { // Alright, what release mode do they want? - if (mem.eql(u8, it.only_arg, "Os")) { + const level = if (it.only_arg.len >= 1 and it.only_arg[0] == 'O') it.only_arg[1..] else it.only_arg; + if (mem.eql(u8, level, "s") or + mem.eql(u8, level, "z")) + { optimize_mode = .ReleaseSmall; - } else if (mem.eql(u8, it.only_arg, "O2") or - mem.eql(u8, it.only_arg, "O3") or - mem.eql(u8, it.only_arg, "O4")) + } else if (mem.eql(u8, level, "1") or + mem.eql(u8, level, "2") or + mem.eql(u8, level, "3") or + mem.eql(u8, level, "4") or + mem.eql(u8, level, "fast")) { optimize_mode = .ReleaseFast; - } else if (mem.eql(u8, it.only_arg, "Og") or - mem.eql(u8, it.only_arg, "O0")) + } else if (mem.eql(u8, level, "g") or + mem.eql(u8, level, "0")) { optimize_mode = .Debug; } else { @@ -1009,8 +1014,13 @@ fn buildOutputType( }, .debug => { strip = false; - if (mem.eql(u8, it.only_arg, "-g")) { + if (mem.eql(u8, it.only_arg, "g")) { // We handled with strip = false above. + } else if (mem.eql(u8, it.only_arg, "g1") or + mem.eql(u8, it.only_arg, "gline-tables-only")) + { + // We handled with strip = false above. but we also want reduced debug info. + try clang_argv.append("-gline-tables-only"); } else { try clang_argv.appendSlice(it.other_args); } |
