aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorMotiejus Jakštys <motiejus@jakstys.lt>2022-06-14 14:41:47 +0300
committerAndrew Kelley <andrew@ziglang.org>2022-07-11 13:55:29 -0700
commit1f410b500c8dbe33191a54a4ae02a6fb0febec46 (patch)
tree7948dd086ed915e1dbd2d94a32e314ea6bb9af10 /src/Compilation.zig
parentade9bd9287fcdd730a7562811d0e50a6899a6cf2 (diff)
downloadzig-1f410b500c8dbe33191a54a4ae02a6fb0febec46.tar.gz
zig-1f410b500c8dbe33191a54a4ae02a6fb0febec46.zip
ELF: understand -Wl,--compress-debug-sections
This argument is both a compiler and a linker flag. The linker flag was not understood; now it is. Go likes to use it as a linker flag. Tested with sqlite3. The size difference is significant, and I confirmed gdb understands both binaries. zlib: 3.66MB ------------ CC="zig cc" CFLAGS="-Wl,--compress-debug-sections=zlib -O2" ./configure --disable-tcl make FILE SIZE VM SIZE -------------- -------------- 39.1% 1.43Mi 88.4% 1.43Mi .text 19.6% 734Ki 0.0% 0 .debug_info 16.4% 613Ki 0.0% 0 .debug_loc 13.1% 492Ki 0.0% 0 .debug_line 4.2% 157Ki 9.5% 157Ki .rodata 2.3% 87.6Ki 0.0% 0 .debug_ranges 1.5% 56.2Ki 0.0% 0 .symtab 1.1% 40.2Ki 0.0% 0 .strtab 1.0% 38.2Ki 0.0% 0 .debug_str 0.7% 26.2Ki 0.0% 0 .debug_frame 0.4% 15.3Ki 0.9% 15.3Ki .data 0.1% 4.71Ki 0.3% 4.71Ki .dynsym 0.1% 3.65Ki 0.2% 3.26Ki [16 Others] 0.1% 2.55Ki 0.2% 2.55Ki .rela.plt 0.1% 2.12Ki 0.0% 0 [ELF Section Headers] 0.0% 0 0.1% 2.02Ki .bss 0.0% 1.84Ki 0.1% 1.84Ki .dynstr 0.0% 1.72Ki 0.1% 1.72Ki .plt 0.0% 1.58Ki 0.1% 1.58Ki .hash 0.0% 1.17Ki 0.0% 0 .debug_abbrev 0.0% 1.01Ki 0.1% 1.01Ki .rela.dyn 100.0% 3.66Mi 100.0% 1.62Mi TOTAL none: 8.56MB ------------ CC="zig cc" CFLAGS="-O2" ./configure --disable-tcl make FILE SIZE VM SIZE -------------- -------------- 41.1% 3.52Mi 0.0% 0 .debug_loc 18.5% 1.59Mi 0.0% 0 .debug_info 16.7% 1.43Mi 88.4% 1.43Mi .text 11.8% 1.01Mi 0.0% 0 .debug_line 5.9% 515Ki 0.0% 0 .debug_ranges 1.8% 157Ki 9.5% 157Ki .rodata 1.3% 118Ki 0.0% 0 .debug_frame 1.3% 110Ki 0.0% 0 .debug_str 0.6% 56.2Ki 0.0% 0 .symtab 0.5% 40.2Ki 0.0% 0 .strtab 0.2% 15.3Ki 0.9% 15.3Ki .data 0.1% 4.71Ki 0.3% 4.71Ki .dynsym 0.0% 3.64Ki 0.2% 3.26Ki [16 Others] 0.0% 2.98Ki 0.0% 0 .debug_abbrev 0.0% 2.55Ki 0.2% 2.55Ki .rela.plt 0.0% 2.12Ki 0.0% 0 [ELF Section Headers] 0.0% 0 0.1% 2.02Ki .bss 0.0% 1.84Ki 0.1% 1.84Ki .dynstr 0.0% 1.72Ki 0.1% 1.72Ki .plt 0.0% 1.58Ki 0.1% 1.58Ki .hash 0.0% 1.01Ki 0.1% 1.01Ki .rela.dyn 100.0% 8.56Mi 100.0% 1.62Mi TOTAL
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index b00f135813..8abe2770ec 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -860,6 +860,7 @@ pub const InitOptions = struct {
linker_nxcompat: bool = false,
linker_dynamicbase: bool = false,
linker_optimization: ?u8 = null,
+ linker_compress_debug_sections: ?link.CompressDebugSections = null,
major_subsystem_version: ?u32 = null,
minor_subsystem_version: ?u32 = null,
clang_passthrough_mode: bool = false,
@@ -1687,6 +1688,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.no_builtin = options.no_builtin,
.allow_shlib_undefined = options.linker_allow_shlib_undefined,
.bind_global_refs_locally = options.linker_bind_global_refs_locally orelse false,
+ .compress_debug_sections = options.linker_compress_debug_sections,
.import_memory = options.linker_import_memory orelse false,
.import_table = options.linker_import_table,
.export_table = options.linker_export_table,
@@ -2459,6 +2461,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
man.hash.add(comp.bin_file.options.z_now);
man.hash.add(comp.bin_file.options.z_relro);
man.hash.add(comp.bin_file.options.hash_style);
+ man.hash.addOptional(comp.bin_file.options.compress_debug_sections);
man.hash.add(comp.bin_file.options.include_compiler_rt);
if (comp.bin_file.options.link_libc) {
man.hash.add(comp.bin_file.options.libc_installation != null);