From 7fef0b4a23ae616ebfec978d6af8e9f716a63555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 5 Nov 2024 15:33:28 +0100 Subject: [PATCH] musl: Pass -f(function,data)-sections via CrtFileOptions instead of CFLAGS. --- src/Compilation.zig | 4 ++++ src/musl.zig | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index b3684d7e61..0dcc121fac 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6262,6 +6262,8 @@ fn buildOutputFromZig( } pub const CrtFileOptions = struct { + function_sections: ?bool = null, + data_sections: ?bool = null, pic: ?bool = null, no_builtin: ?bool = null, }; @@ -6356,6 +6358,8 @@ pub fn build_crt_file( .directory = null, // Put it in the cache directory. .basename = basename, }, + .function_sections = options.function_sections orelse false, + .data_sections = options.data_sections orelse false, .emit_h = null, .c_source_files = c_source_files, .verbose_cc = comp.verbose_cc, diff --git a/src/musl.zig b/src/musl.zig index ec2b0674ff..99662bbd2c 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -39,6 +39,8 @@ 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, .no_builtin = true, }); }, @@ -53,6 +55,8 @@ 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, .no_builtin = true, }); }, @@ -70,6 +74,8 @@ 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, .no_builtin = true, }); }, @@ -87,6 +93,8 @@ 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, .pic = true, .no_builtin = true, }); @@ -105,6 +113,8 @@ 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, .pic = true, .no_builtin = true, }); @@ -201,6 +211,8 @@ 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, .no_builtin = true, }); }, @@ -448,8 +460,6 @@ fn addCcArgs( "-fomit-frame-pointer", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", - "-ffunction-sections", - "-fdata-sections", "-Qunused-arguments", "-w", // disable all warnings