@@ -443,6 +443,9 @@ const usage_build_generic =
443443 \\ -dynamic Force output to be dynamically linked
444444 \\ -static Force output to be statically linked
445445 \\ -Bsymbolic Bind global references locally
446+ \\ --compress-debug-sections=[e] Debug section compression settings
447+ \\ none No compression
448+ \\ zlib Compression with deflate/inflate
446449 \\ --subsystem [subsystem] (Windows) /SUBSYSTEM:<subsystem> to the linker
447450 \\ --stack [size] Override default stack size
448451 \\ --image-base [addr] Set base address for executable image
@@ -657,6 +660,7 @@ fn buildOutputType(
657660 var version_script : ? []const u8 = null ;
658661 var disable_c_depfile = false ;
659662 var linker_gc_sections : ? bool = null ;
663+ var linker_compress_debug_sections : ? link.CompressDebugSections = null ;
660664 var linker_allow_shlib_undefined : ? bool = null ;
661665 var linker_bind_global_refs_locally : ? bool = null ;
662666 var linker_import_memory : ? bool = null ;
@@ -938,6 +942,13 @@ fn buildOutputType(
938942 install_name = args_iter .next () orelse {
939943 fatal ("expected parameter after {s}" , .{arg });
940944 };
945+ } else if (mem .startsWith (u8 , arg , "--compress-debug-sections=" )) {
946+ const param = arg ["--compress-debug-sections=" .len .. ];
947+ linker_compress_debug_sections = std .meta .stringToEnum (link .CompressDebugSections , param ) orelse {
948+ fatal ("expected --compress-debug-sections=[none|zlib], found '{s}'" , .{param });
949+ };
950+ } else if (mem .eql (u8 , arg , "--compress-debug-sections" )) {
951+ linker_compress_debug_sections = link .CompressDebugSections .zlib ;
941952 } else if (mem .eql (u8 , arg , "-pagezero_size" )) {
942953 const next_arg = args_iter .next () orelse {
943954 fatal ("expected parameter after {s}" , .{arg });
@@ -1640,6 +1651,15 @@ fn buildOutputType(
16401651 .weak_library = > try system_libs .put (it .only_arg , .{ .weak = true }),
16411652 .weak_framework = > try frameworks .put (gpa , it .only_arg , .{ .weak = true }),
16421653 .headerpad_max_install_names = > headerpad_max_install_names = true ,
1654+ .compress_debug_sections = > {
1655+ if (it .only_arg .len == 0 ) {
1656+ linker_compress_debug_sections = .zlib ;
1657+ } else {
1658+ linker_compress_debug_sections = std .meta .stringToEnum (link .CompressDebugSections , it .only_arg ) orelse {
1659+ fatal ("expected [none|zlib] after --compress-debug-sections, found '{s}'" , .{it .only_arg });
1660+ };
1661+ }
1662+ },
16431663 }
16441664 }
16451665 // Parse linker args.
@@ -1776,6 +1796,15 @@ fn buildOutputType(
17761796 linker_global_base = parseIntSuffix (arg , "--global-base=" .len );
17771797 } else if (mem .startsWith (u8 , arg , "--export=" )) {
17781798 try linker_export_symbol_names .append (arg ["--export=" .len .. ]);
1799+ } else if (mem .eql (u8 , arg , "--compress-debug-sections" )) {
1800+ i += 1 ;
1801+ if (i >= linker_args .items .len ) {
1802+ fatal ("expected linker arg after '{s}'" , .{arg });
1803+ }
1804+ const arg1 = linker_args .items [i ];
1805+ linker_compress_debug_sections = std .meta .stringToEnum (link .CompressDebugSections , arg1 ) orelse {
1806+ fatal ("expected [none|zlib] after --compress-debug-sections, found '{s}'" , .{arg1 });
1807+ };
17791808 } else if (mem .eql (u8 , arg , "-z" )) {
17801809 i += 1 ;
17811810 if (i >= linker_args .items .len ) {
@@ -2849,6 +2878,7 @@ fn buildOutputType(
28492878 .linker_nxcompat = linker_nxcompat ,
28502879 .linker_dynamicbase = linker_dynamicbase ,
28512880 .linker_optimization = linker_optimization ,
2881+ .linker_compress_debug_sections = linker_compress_debug_sections ,
28522882 .major_subsystem_version = major_subsystem_version ,
28532883 .minor_subsystem_version = minor_subsystem_version ,
28542884 .link_eh_frame_hdr = link_eh_frame_hdr ,
@@ -4599,6 +4629,7 @@ pub const ClangArgIterator = struct {
45994629 weak_library ,
46004630 weak_framework ,
46014631 headerpad_max_install_names ,
4632+ compress_debug_sections ,
46024633 };
46034634
46044635 const Args = struct {
0 commit comments