authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-28 12:03:35-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-03-28 12:03:35-04:00
logf9db21f03eaf0b800e531d12c2677d579eceaff0
tree278efcdade1c47d25e84e91dd9dbfb1faa5b6378
parent2028b4ce9127c3c6e439183f2f9313ec47eb7d62
parentcc7c670851a8186264eb63d4e0d6c8dcdfba8e4c
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4838 from squeek502/for-linker

zig cc: Add support for -Xlinker, --for-linker, --for-linker=, -z

5 files changed, 77 insertions(+), 8 deletions(-)

src-self-hosted/clang_options_data.zig+50-8
......@@ -80,7 +80,14 @@ sepd1("Xassembler"),
8080sepd1("Xclang"),
8181sepd1("Xcuda-fatbinary"),
8282sepd1("Xcuda-ptxas"),
83sepd1("Xlinker"),
83.{
84 .name = "Xlinker",
85 .syntax = .separate,
86 .zig_equivalent = .for_linker,
87 .pd1 = true,
88 .pd2 = false,
89 .psl = false,
90},
8491sepd1("Xopenmp-target"),
8592sepd1("Xpreprocessor"),
8693flagpd1("Z"),
......@@ -1563,7 +1570,7 @@ sepd1("Zlinker-input"),
15631570.{
15641571 .name = "for-linker",
15651572 .syntax = .separate,
1566 .zig_equivalent = .other,
1573 .zig_equivalent = .for_linker,
15671574 .pd1 = false,
15681575 .pd2 = true,
15691576 .psl = false,
......@@ -2547,7 +2554,14 @@ flagpd1("femulated-tls"),
25472554flagpd1("fencode-extended-block-signature"),
25482555sepd1("ferror-limit"),
25492556flagpd1("fescaping-block-tail-calls"),
2550flagpd1("fexceptions"),
2557.{
2558 .name = "fexceptions",
2559 .syntax = .flag,
2560 .zig_equivalent = .exceptions,
2561 .pd1 = true,
2562 .pd2 = false,
2563 .psl = false,
2564},
25512565flagpd1("fexperimental-isel"),
25522566flagpd1("fexperimental-new-constant-interpreter"),
25532567flagpd1("fexperimental-new-pass-manager"),
......@@ -2751,7 +2765,14 @@ flagpd1("fno-elide-type"),
27512765flagpd1("fno-eliminate-unused-debug-symbols"),
27522766flagpd1("fno-emulated-tls"),
27532767flagpd1("fno-escaping-block-tail-calls"),
2754flagpd1("fno-exceptions"),
2768.{
2769 .name = "fno-exceptions",
2770 .syntax = .flag,
2771 .zig_equivalent = .no_exceptions,
2772 .pd1 = true,
2773 .pd2 = false,
2774 .psl = false,
2775},
27552776flagpd1("fno-experimental-isel"),
27562777flagpd1("fno-experimental-new-pass-manager"),
27572778flagpd1("fno-fast-math"),
......@@ -2840,7 +2861,14 @@ flagpd1("fno-rewrite-includes"),
28402861flagpd1("fno-ropi"),
28412862flagpd1("fno-rounding-math"),
28422863flagpd1("fno-rtlib-add-rpath"),
2843flagpd1("fno-rtti"),
2864.{
2865 .name = "fno-rtti",
2866 .syntax = .flag,
2867 .zig_equivalent = .no_rtti,
2868 .pd1 = true,
2869 .pd2 = false,
2870 .psl = false,
2871},
28442872flagpd1("fno-rtti-data"),
28452873flagpd1("fno-rwpi"),
28462874flagpd1("fno-sanitize-address-poison-custom-array-cookie"),
......@@ -2988,7 +3016,14 @@ flagpd1("fno-frontend-optimize"),
29883016flagpd1("fropi"),
29893017flagpd1("frounding-math"),
29903018flagpd1("frtlib-add-rpath"),
2991flagpd1("frtti"),
3019.{
3020 .name = "frtti",
3021 .syntax = .flag,
3022 .zig_equivalent = .rtti,
3023 .pd1 = true,
3024 .pd2 = false,
3025 .psl = false,
3026},
29923027flagpd1("frwpi"),
29933028flagpd1("fsanitize-address-globals-dead-stripping"),
29943029flagpd1("fsanitize-address-poison-custom-array-cookie"),
......@@ -4248,7 +4283,14 @@ flagpd1("fno-whole-file"),
42484283flagpd1("fwhole-program"),
42494284flagpd1("fno-whole-program"),
42504285flagpd1("whyload"),
4251sepd1("z"),
4286.{
4287 .name = "z",
4288 .syntax = .separate,
4289 .zig_equivalent = .linker_input_z,
4290 .pd1 = true,
4291 .pd2 = false,
4292 .psl = false,
4293},
42524294joinpd1("fsanitize-undefined-strip-path-components="),
42534295joinpd1("fopenmp-cuda-teams-reduction-recs-num="),
42544296joinpd1("analyzer-config-compatibility-mode="),
......@@ -4887,7 +4929,7 @@ jspd1("sub_umbrella"),
48874929.{
48884930 .name = "for-linker=",
48894931 .syntax = .joined,
4890 .zig_equivalent = .other,
4932 .zig_equivalent = .for_linker,
48914933 .pd1 = false,
48924934 .pd2 = true,
48934935 .psl = false,
src-self-hosted/stage2.zig+2
......@@ -1289,6 +1289,8 @@ pub const ClangArgIterator = extern struct {
12891289 no_exceptions,
12901290 rtti,
12911291 no_rtti,
1292 for_linker,
1293 linker_input_z,
12921294 };
12931295
12941296 const Args = struct {
src/main.cpp+7
......@@ -734,6 +734,13 @@ static int main0(int argc, char **argv) {
734734 case Stage2ClangArgNoRtti:
735735 cpp_rtti = false;
736736 break;
737 case Stage2ClangArgForLinker:
738 linker_args.append(buf_create_from_str(it.only_arg));
739 break;
740 case Stage2ClangArgLinkerInputZ:
741 linker_args.append(buf_create_from_str("-z"));
742 linker_args.append(buf_create_from_str(it.only_arg));
743 break;
737744 }
738745 }
739746 // Parse linker args
src/stage2.h+2
......@@ -349,6 +349,8 @@ enum Stage2ClangArg {
349349 Stage2ClangArgNoExceptions,
350350 Stage2ClangArgRtti,
351351 Stage2ClangArgNoRtti,
352 Stage2ClangArgForLinker,
353 Stage2ClangArgLinkerInputZ,
352354};
353355
354356// ABI warning
tools/update_clang_options.zig+16
......@@ -78,6 +78,22 @@ const known_options = [_]KnownOpt{
7878 .name = "Wl,",
7979 .ident = "wl",
8080 },
81 .{
82 .name = "Xlinker",
83 .ident = "for_linker",
84 },
85 .{
86 .name = "for-linker",
87 .ident = "for_linker",
88 },
89 .{
90 .name = "for-linker=",
91 .ident = "for_linker",
92 },
93 .{
94 .name = "z",
95 .ident = "linker_input_z",
96 },
8197 .{
8298 .name = "E",
8399 .ident = "preprocess",