@@ -423,6 +423,8 @@ const usage_build_generic =
423
423
\\ -fno-each-lib-rpath Prevent adding rpath for each used dynamic library
424
424
\\ -fallow-shlib-undefined Allows undefined symbols in shared libraries
425
425
\\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries
426
+ \\ -fbuild-id Helps coordinate stripped binaries with debug symbols
427
+ \\ -fno-build-id (default) Saves a bit of time linking
426
428
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker
427
429
\\ --emit-relocs Enable output of relocation sections for post build tools
428
430
\\ -z [arg] Set linker extension flags
@@ -671,6 +673,7 @@ fn buildOutputType(
671
673
var link_eh_frame_hdr = false ;
672
674
var link_emit_relocs = false ;
673
675
var each_lib_rpath : ? bool = null ;
676
+ var build_id : ? bool = null ;
674
677
var sysroot : ? []const u8 = null ;
675
678
var libc_paths_file : ? []const u8 = try optionalStringEnvVar (arena , "ZIG_LIBC" );
676
679
var machine_code_model : std.builtin.CodeModel = .default ;
@@ -1030,6 +1033,10 @@ fn buildOutputType(
1030
1033
each_lib_rpath = true ;
1031
1034
} else if (mem .eql (u8 , arg , "-fno-each-lib-rpath" )) {
1032
1035
each_lib_rpath = false ;
1036
+ } else if (mem .eql (u8 , arg , "-fbuild-id" )) {
1037
+ build_id = true ;
1038
+ } else if (mem .eql (u8 , arg , "-fno-build-id" )) {
1039
+ build_id = false ;
1033
1040
} else if (mem .eql (u8 , arg , "--enable-cache" )) {
1034
1041
enable_cache = true ;
1035
1042
} else if (mem .eql (u8 , arg , "--test-cmd-bin" )) {
@@ -1415,10 +1422,20 @@ fn buildOutputType(
1415
1422
while (split_it .next ()) | linker_arg | {
1416
1423
// Handle nested-joined args like `-Wl,-rpath=foo`.
1417
1424
// Must be prefixed with 1 or 2 dashes.
1418
- if (linker_arg .len >= 3 and linker_arg [0 ] == '-' and linker_arg [2 ] != '-' ) {
1425
+ if (linker_arg .len >= 3 and
1426
+ linker_arg [0 ] == '-' and
1427
+ linker_arg [2 ] != '-' )
1428
+ {
1419
1429
if (mem .indexOfScalar (u8 , linker_arg , '=' )) | equals_pos | {
1420
- try linker_args .append (linker_arg [0.. equals_pos ]);
1421
- try linker_args .append (linker_arg [equals_pos + 1 .. ]);
1430
+ const key = linker_arg [0.. equals_pos ];
1431
+ const value = linker_arg [equals_pos + 1 .. ];
1432
+ if (mem .eql (u8 , key , "build-id" )) {
1433
+ build_id = true ;
1434
+ warn ("ignoring build-id style argument: '{s}'" , .{value });
1435
+ continue ;
1436
+ }
1437
+ try linker_args .append (key );
1438
+ try linker_args .append (value );
1422
1439
continue ;
1423
1440
}
1424
1441
}
@@ -2727,6 +2744,7 @@ fn buildOutputType(
2727
2744
.stack_report = stack_report ,
2728
2745
.is_test = arg_mode == .zig_test ,
2729
2746
.each_lib_rpath = each_lib_rpath ,
2747
+ .build_id = build_id ,
2730
2748
.test_evented_io = test_evented_io ,
2731
2749
.test_filter = test_filter ,
2732
2750
.test_name_prefix = test_name_prefix ,
0 commit comments