From 796d4845ff6747611c0061f8fe5c3c1c5b967226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 5 Nov 2024 14:47:36 +0100 Subject: [PATCH] musl: Pass -fomit-frame-pointer via CrtFileOptions. --- src/Compilation.zig | 4 +++- src/musl.zig | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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",