diff --git a/src/Compilation.zig b/src/Compilation.zig index 0dcc121fac..f646ef258a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6264,6 +6264,7 @@ fn buildOutputFromZig( pub const CrtFileOptions = struct { function_sections: ?bool = null, data_sections: ?bool = null, + omit_frame_pointer: ?bool = null, pic: ?bool = null, no_builtin: ?bool = null, }; @@ -6322,7 +6323,8 @@ pub fn build_crt_file( .sanitize_c = false, .sanitize_thread = false, .red_zone = comp.root_mod.red_zone, - .omit_frame_pointer = comp.root_mod.omit_frame_pointer, + // Some libcs (e.g. musl) are opinionated about -fomit-frame-pointer. + .omit_frame_pointer = options.omit_frame_pointer orelse comp.root_mod.omit_frame_pointer, .valgrind = false, .unwind_tables = false, // Some CRT objects (e.g. musl's rcrt1.o and Scrt1.o) are opinionated about PIC. diff --git a/src/musl.zig b/src/musl.zig index 99662bbd2c..b1d47361a8 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -41,6 +41,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{ .function_sections = true, .data_sections = true, + .omit_frame_pointer = true, .no_builtin = true, }); }, @@ -57,6 +58,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{ .function_sections = true, .data_sections = true, + .omit_frame_pointer = true, .no_builtin = true, }); }, @@ -76,6 +78,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{ .function_sections = true, .data_sections = true, + .omit_frame_pointer = true, .no_builtin = true, }); }, @@ -95,6 +98,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{ .function_sections = true, .data_sections = true, + .omit_frame_pointer = true, .pic = true, .no_builtin = true, }); @@ -115,6 +119,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{ .function_sections = true, .data_sections = true, + .omit_frame_pointer = true, .pic = true, .no_builtin = true, }); @@ -213,6 +218,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{ .function_sections = true, .data_sections = true, + .omit_frame_pointer = true, .no_builtin = true, }); }, @@ -457,7 +463,6 @@ fn addCcArgs( o_arg, - "-fomit-frame-pointer", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables",