zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f9db21f03eaf0b800e531d12c2677d579eceaff0 (tree)
parent 2028b4ce9127c3c6e439183f2f9313ec47eb7d62
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sat, 28 Mar 2020 12:03:35 -0400

Merge pull request #4838 from squeek502/for-linker

zig cc: Add support for -Xlinker, --for-linker, --for-linker=, -z
Diffstat:
Msrc-self-hosted/clang_options_data.zig | 58++++++++++++++++++++++++++++++++++++++++++++++++++--------
Msrc-self-hosted/stage2.zig | 2++
Msrc/main.cpp | 7+++++++
Msrc/stage2.h | 2++
Mtools/update_clang_options.zig | 16++++++++++++++++
5 files changed, 77 insertions(+), 8 deletions(-)

diff --git a/src-self-hosted/clang_options_data.zig b/src-self-hosted/clang_options_data.zig @@ -80,7 +80,14 @@ sepd1("Xassembler"), sepd1("Xclang"), sepd1("Xcuda-fatbinary"), sepd1("Xcuda-ptxas"), -sepd1("Xlinker"), +.{ + .name = "Xlinker", + .syntax = .separate, + .zig_equivalent = .for_linker, + .pd1 = true, + .pd2 = false, + .psl = false, +}, sepd1("Xopenmp-target"), sepd1("Xpreprocessor"), flagpd1("Z"), @@ -1563,7 +1570,7 @@ sepd1("Zlinker-input"), .{ .name = "for-linker", .syntax = .separate, - .zig_equivalent = .other, + .zig_equivalent = .for_linker, .pd1 = false, .pd2 = true, .psl = false, @@ -2547,7 +2554,14 @@ flagpd1("femulated-tls"), flagpd1("fencode-extended-block-signature"), sepd1("ferror-limit"), flagpd1("fescaping-block-tail-calls"), -flagpd1("fexceptions"), +.{ + .name = "fexceptions", + .syntax = .flag, + .zig_equivalent = .exceptions, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("fexperimental-isel"), flagpd1("fexperimental-new-constant-interpreter"), flagpd1("fexperimental-new-pass-manager"), @@ -2751,7 +2765,14 @@ flagpd1("fno-elide-type"), flagpd1("fno-eliminate-unused-debug-symbols"), flagpd1("fno-emulated-tls"), flagpd1("fno-escaping-block-tail-calls"), -flagpd1("fno-exceptions"), +.{ + .name = "fno-exceptions", + .syntax = .flag, + .zig_equivalent = .no_exceptions, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("fno-experimental-isel"), flagpd1("fno-experimental-new-pass-manager"), flagpd1("fno-fast-math"), @@ -2840,7 +2861,14 @@ flagpd1("fno-rewrite-includes"), flagpd1("fno-ropi"), flagpd1("fno-rounding-math"), flagpd1("fno-rtlib-add-rpath"), -flagpd1("fno-rtti"), +.{ + .name = "fno-rtti", + .syntax = .flag, + .zig_equivalent = .no_rtti, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("fno-rtti-data"), flagpd1("fno-rwpi"), flagpd1("fno-sanitize-address-poison-custom-array-cookie"), @@ -2988,7 +3016,14 @@ flagpd1("fno-frontend-optimize"), flagpd1("fropi"), flagpd1("frounding-math"), flagpd1("frtlib-add-rpath"), -flagpd1("frtti"), +.{ + .name = "frtti", + .syntax = .flag, + .zig_equivalent = .rtti, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("frwpi"), flagpd1("fsanitize-address-globals-dead-stripping"), flagpd1("fsanitize-address-poison-custom-array-cookie"), @@ -4248,7 +4283,14 @@ flagpd1("fno-whole-file"), flagpd1("fwhole-program"), flagpd1("fno-whole-program"), flagpd1("whyload"), -sepd1("z"), +.{ + .name = "z", + .syntax = .separate, + .zig_equivalent = .linker_input_z, + .pd1 = true, + .pd2 = false, + .psl = false, +}, joinpd1("fsanitize-undefined-strip-path-components="), joinpd1("fopenmp-cuda-teams-reduction-recs-num="), joinpd1("analyzer-config-compatibility-mode="), @@ -4887,7 +4929,7 @@ jspd1("sub_umbrella"), .{ .name = "for-linker=", .syntax = .joined, - .zig_equivalent = .other, + .zig_equivalent = .for_linker, .pd1 = false, .pd2 = true, .psl = false, diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig @@ -1289,6 +1289,8 @@ pub const ClangArgIterator = extern struct { no_exceptions, rtti, no_rtti, + for_linker, + linker_input_z, }; const Args = struct { diff --git a/src/main.cpp b/src/main.cpp @@ -734,6 +734,13 @@ static int main0(int argc, char **argv) { case Stage2ClangArgNoRtti: cpp_rtti = false; break; + case Stage2ClangArgForLinker: + linker_args.append(buf_create_from_str(it.only_arg)); + break; + case Stage2ClangArgLinkerInputZ: + linker_args.append(buf_create_from_str("-z")); + linker_args.append(buf_create_from_str(it.only_arg)); + break; } } // Parse linker args diff --git a/src/stage2.h b/src/stage2.h @@ -349,6 +349,8 @@ enum Stage2ClangArg { Stage2ClangArgNoExceptions, Stage2ClangArgRtti, Stage2ClangArgNoRtti, + Stage2ClangArgForLinker, + Stage2ClangArgLinkerInputZ, }; // ABI warning diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig @@ -79,6 +79,22 @@ const known_options = [_]KnownOpt{ .ident = "wl", }, .{ + .name = "Xlinker", + .ident = "for_linker", + }, + .{ + .name = "for-linker", + .ident = "for_linker", + }, + .{ + .name = "for-linker=", + .ident = "for_linker", + }, + .{ + .name = "z", + .ident = "linker_input_z", + }, + .{ .name = "E", .ident = "preprocess", },