diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-06-10 11:25:33 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-06-11 13:23:00 -0400 |
| commit | b6277a4b1c2be27701d594bc1465ac72fc226260 (patch) | |
| tree | 6a422059457c92c6baeaba53e6e95a2195cc0d43 /src/main.zig | |
| parent | 6cc88458029759bbedcb4d949deb887d464cdd60 (diff) | |
| download | zig-b6277a4b1c2be27701d594bc1465ac72fc226260.tar.gz zig-b6277a4b1c2be27701d594bc1465ac72fc226260.zip | |
better awareness of unwind tables
* stage1 backend allows configuring the uwtables function attr
via a flag rather than its own logic.
* stage2 defaults to enabling uwtable attr when
linking libunwind, or always on windows
* stage2 makes link_eh_frame_hdr true automatically if uwtable
attr is set to be on for zig functions
* CLI: add -funwind-tables and -fno-unwind-tables to allow the user to
override the defaults.
* hook it up to `zig cc`
closes #9046
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index 631d4ef460..081b9ac335 100644 --- a/src/main.zig +++ b/src/main.zig @@ -264,22 +264,26 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v } const usage_build_generic = - \\Usage: zig build-exe <options> [files] - \\ zig build-lib <options> [files] - \\ zig build-obj <options> [files] - \\ zig test <options> [files] - \\ zig run <options> [file] [-- [args]] + \\Usage: zig build-exe <options> [files] + \\ zig build-lib <options> [files] + \\ zig build-obj <options> [files] + \\ zig test <options> [files] + \\ zig run <options> [file] [-- [args]] + \\ zig translate-c <options> [file] \\ \\Supported file types: \\ .zig Zig source code \\ .o ELF object file - \\ .o MACH-O (macOS) object file + \\ .o Mach-O (macOS) object file + \\ .o WebAssembly object file \\ .obj COFF (Windows) object file \\ .lib COFF (Windows) static library \\ .a ELF static library + \\ .a Mach-O (macOS) static library + \\ .a WebAssembly static library \\ .so ELF shared object (dynamic link) \\ .dll Windows Dynamic Link Library - \\ .dylib MACH-O (macOS) dynamic library + \\ .dylib Mach-O (macOS) dynamic library \\ .tbd (macOS) text-based dylib definition \\ .s Target-specific assembly source code \\ .S Assembly with C preprocessor (requires LLVM extensions) @@ -342,6 +346,8 @@ const usage_build_generic = \\ -fno-sanitize-thread Disable Thread Sanitizer \\ -fdll-export-fns Mark exported functions as DLL exports (Windows) \\ -fno-dll-export-fns Force-disable marking exported functions as DLL exports + \\ -funwind-tables Always produce unwind table entries for all functions + \\ -fno-unwind-tables Never produce unwind table entries \\ -fLLVM Force using LLVM as the codegen backend \\ -fno-LLVM Prevent using LLVM as a codegen backend \\ -fClang Force using Clang as the C/C++ compilation backend @@ -569,6 +575,7 @@ fn buildOutputType( var want_pic: ?bool = null; var want_pie: ?bool = null; var want_lto: ?bool = null; + var want_unwind_tables: ?bool = null; var want_sanitize_c: ?bool = null; var want_stack_check: ?bool = null; var want_red_zone: ?bool = null; @@ -925,6 +932,10 @@ fn buildOutputType( want_lto = true; } else if (mem.eql(u8, arg, "-fno-lto")) { want_lto = false; + } else if (mem.eql(u8, arg, "-funwind-tables")) { + want_unwind_tables = true; + } else if (mem.eql(u8, arg, "-fno-unwind-tables")) { + want_unwind_tables = false; } else if (mem.eql(u8, arg, "-fstack-check")) { want_stack_check = true; } else if (mem.eql(u8, arg, "-fno-stack-check")) { @@ -1156,6 +1167,8 @@ fn buildOutputType( .no_lto => want_lto = false, .red_zone => want_red_zone = true, .no_red_zone => want_red_zone = false, + .unwind_tables => want_unwind_tables = true, + .no_unwind_tables => want_unwind_tables = false, .nostdlib => ensure_libc_on_non_freestanding = false, .nostdlib_cpp => ensure_libcpp_on_non_freestanding = false, .shared => { @@ -1913,6 +1926,7 @@ fn buildOutputType( .want_pic = want_pic, .want_pie = want_pie, .want_lto = want_lto, + .want_unwind_tables = want_unwind_tables, .want_sanitize_c = want_sanitize_c, .want_stack_check = want_stack_check, .want_red_zone = want_red_zone, @@ -3315,6 +3329,8 @@ pub const ClangArgIterator = struct { no_pie, lto, no_lto, + unwind_tables, + no_unwind_tables, nostdlib, nostdlib_cpp, shared, |
