authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-07 16:02:58-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-07 16:02:58-05:00
loge2e9be5deac75e102bc5faaa94aa17308224f9f6
treeed6c69e1735acc2ee9615b86a9a12fb25b192eb4
parent437c6a4b7ef115208ae84a938f989b92fb282c39
parentaf390b75dbdb33f6ccf80c14d32ee5b89421c35b
signature Commit is signed but in an unrecognized format.

Merge branch 'dcao-master'

closes #3981

8 files changed, 29 insertions(+), 1 deletions(-)

lib/std/build.zig+6-1
......@@ -1175,6 +1175,8 @@ pub const LibExeObjStep = struct {
11751175
11761176 valgrind_support: ?bool = null,
11771177
1178 link_eh_frame_hdr: bool = false,
1179
11781180 /// Uses system Wine installation to run cross compiled Windows build artifacts.
11791181 enable_wine: bool = false,
11801182
......@@ -1910,7 +1912,10 @@ pub const LibExeObjStep = struct {
19101912 if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable;
19111913
19121914 if (self.strip) {
1913 zig_args.append("--strip") catch unreachable;
1915 try zig_args.append("--strip");
1916 }
1917 if (self.link_eh_frame_hdr) {
1918 try zig_args.append("--eh-frame-hdr");
19141919 }
19151920
19161921 if (self.single_threaded) {
src-self-hosted/compilation.zig+2
......@@ -170,6 +170,8 @@ pub const Compilation = struct {
170170 verbose_llvm_ir: bool = false,
171171 verbose_link: bool = false,
172172
173 link_eh_frame_hdr: bool = false,
174
173175 darwin_version_min: DarwinVersionMin = .None,
174176
175177 test_filters: []const []const u8 = &[_][]const u8{},
src-self-hosted/link.zig+3
......@@ -144,6 +144,9 @@ fn constructLinkerArgsElf(ctx: *Context) !void {
144144 // lj->args.append(g->linker_script);
145145 //}
146146 try ctx.args.append("--gc-sections");
147 if (ctx.comp.link_eh_frame_hdr) {
148 try ctx.args.append("--eh-frame-hdr");
149 }
147150
148151 //lj->args.append("-m");
149152 //lj->args.append(getLDMOption(&g->zig_target));
src-self-hosted/main.zig+6
......@@ -154,6 +154,7 @@ const usage_build_generic =
154154 \\ --static Output will be statically linked
155155 \\ --strip Exclude debug symbols
156156 \\ -target [name] <arch><sub>-<os>-<abi> see the targets command
157 \\ --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker
157158 \\ --verbose-tokenize Turn on compiler debug output for tokenization
158159 \\ --verbose-ast-tree Turn on compiler debug output for parsing into an AST (tree view)
159160 \\ --verbose-ast-fmt Turn on compiler debug output for parsing into an AST (render source)
......@@ -207,6 +208,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
207208 var verbose_llvm_ir = false;
208209 var verbose_cimport = false;
209210 var linker_rdynamic = false;
211 var link_eh_frame_hdr = false;
210212 var macosx_version_min: ?[]const u8 = null;
211213 var ios_version_min: ?[]const u8 = null;
212214
......@@ -369,6 +371,8 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
369371 verbose_ir = true;
370372 } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
371373 verbose_llvm_ir = true;
374 } else if (mem.eql(u8, arg, "--eh-frame-hdr")) {
375 link_eh_frame_hdr = true;
372376 } else if (mem.eql(u8, arg, "--verbose-cimport")) {
373377 verbose_cimport = true;
374378 } else if (mem.eql(u8, arg, "-rdynamic")) {
......@@ -498,6 +502,8 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
498502 comp.verbose_llvm_ir = verbose_llvm_ir;
499503 comp.verbose_cimport = verbose_cimport;
500504
505 comp.link_eh_frame_hdr = link_eh_frame_hdr;
506
501507 comp.err_color = color;
502508
503509 comp.linker_rdynamic = linker_rdynamic;
src/all_types.hpp+1
......@@ -2131,6 +2131,7 @@ struct CodeGen {
21312131 bool have_winmain_crt_startup;
21322132 bool have_dllmain_crt_startup;
21332133 bool have_err_ret_tracing;
2134 bool link_eh_frame_hdr;
21342135 bool c_want_stdint;
21352136 bool c_want_stdbool;
21362137 bool verbose_tokenize;
src/codegen.cpp+2
......@@ -8629,6 +8629,7 @@ static Error define_builtin_compile_vars(CodeGen *g) {
86298629 cache_bool(&cache_hash, g->have_err_ret_tracing);
86308630 cache_bool(&cache_hash, g->libc_link_lib != nullptr);
86318631 cache_bool(&cache_hash, g->valgrind_support);
8632 cache_bool(&cache_hash, g->link_eh_frame_hdr);
86328633 cache_int(&cache_hash, detect_subsystem(g));
86338634
86348635 Buf digest = BUF_INIT;
......@@ -10279,6 +10280,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
1027910280 cache_buf_opt(ch, g->test_filter);
1028010281 cache_buf_opt(ch, g->test_name_prefix);
1028110282 }
10283 cache_bool(ch, g->link_eh_frame_hdr);
1028210284 cache_bool(ch, g->is_single_threaded);
1028310285 cache_bool(ch, g->linker_rdynamic);
1028410286 cache_bool(ch, g->each_lib_rpath);
src/link.cpp+4
......@@ -1647,6 +1647,10 @@ static void construct_linker_job_elf(LinkJob *lj) {
16471647 lj->args.append("--gc-sections");
16481648 }
16491649
1650 if (g->link_eh_frame_hdr) {
1651 lj->args.append("--eh-frame-hdr");
1652 }
1653
16501654 lj->args.append("-m");
16511655 lj->args.append(getLDMOption(g->zig_target));
16521656
src/main.cpp+5
......@@ -55,6 +55,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
5555 " --color [auto|off|on] enable or disable colored error messages\n"
5656 " --disable-gen-h do not generate a C header file (.h)\n"
5757 " --disable-valgrind omit valgrind client requests in debug builds\n"
58 " --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n"
5859 " --enable-valgrind include valgrind client requests release builds\n"
5960 " -fstack-check enable stack probing in unsafe builds\n"
6061 " -fno-stack-check disable stack probing in safe builds\n"
......@@ -477,6 +478,7 @@ int main(int argc, char **argv) {
477478 bool verbose_llvm_ir = false;
478479 bool verbose_cimport = false;
479480 bool verbose_cc = false;
481 bool link_eh_frame_hdr = false;
480482 ErrColor color = ErrColorAuto;
481483 CacheOpt enable_cache = CacheOptAuto;
482484 Buf *dynamic_linker = nullptr;
......@@ -715,6 +717,8 @@ int main(int argc, char **argv) {
715717 valgrind_support = ValgrindSupportEnabled;
716718 } else if (strcmp(arg, "--disable-valgrind") == 0) {
717719 valgrind_support = ValgrindSupportDisabled;
720 } else if (strcmp(arg, "--eh-frame-hdr") == 0) {
721 link_eh_frame_hdr = true;
718722 } else if (strcmp(arg, "-fPIC") == 0) {
719723 want_pic = WantPICEnabled;
720724 } else if (strcmp(arg, "-fno-PIC") == 0) {
......@@ -1191,6 +1195,7 @@ int main(int argc, char **argv) {
11911195 override_lib_dir, libc, cache_dir_buf, cmd == CmdTest, root_progress_node);
11921196 if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2);
11931197 g->valgrind_support = valgrind_support;
1198 g->link_eh_frame_hdr = link_eh_frame_hdr;
11941199 g->want_pic = want_pic;
11951200 g->want_stack_check = want_stack_check;
11961201 g->want_sanitize_c = want_sanitize_c;