authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-05 15:33:28+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-05 22:41:09+01:00
log7fef0b4a23ae616ebfec978d6af8e9f716a63555
tree7a6589eea300419aac05c8c5b53c3683a290026b
parentf973d3e93e9bb419212a187e787de94929de928d
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

musl: Pass -f(function,data)-sections via CrtFileOptions instead of CFLAGS.


2 files changed, 16 insertions(+), 2 deletions(-)

src/Compilation.zig+4
......@@ -6262,6 +6262,8 @@ fn buildOutputFromZig(
62626262}
62636263
62646264pub const CrtFileOptions = struct {
6265 function_sections: ?bool = null,
6266 data_sections: ?bool = null,
62656267 pic: ?bool = null,
62666268 no_builtin: ?bool = null,
62676269};
......@@ -6356,6 +6358,8 @@ pub fn build_crt_file(
63566358 .directory = null, // Put it in the cache directory.
63576359 .basename = basename,
63586360 },
6361 .function_sections = options.function_sections orelse false,
6362 .data_sections = options.data_sections orelse false,
63596363 .emit_h = null,
63606364 .c_source_files = c_source_files,
63616365 .verbose_cc = comp.verbose_cc,
src/musl.zig+12-2
......@@ -39,6 +39,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
3939 },
4040 };
4141 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{
42 .function_sections = true,
43 .data_sections = true,
4244 .no_builtin = true,
4345 });
4446 },
......@@ -53,6 +55,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
5355 },
5456 };
5557 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{
58 .function_sections = true,
59 .data_sections = true,
5660 .no_builtin = true,
5761 });
5862 },
......@@ -70,6 +74,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
7074 },
7175 };
7276 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{
77 .function_sections = true,
78 .data_sections = true,
7379 .no_builtin = true,
7480 });
7581 },
......@@ -87,6 +93,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
8793 },
8894 };
8995 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{
96 .function_sections = true,
97 .data_sections = true,
9098 .pic = true,
9199 .no_builtin = true,
92100 });
......@@ -105,6 +113,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
105113 },
106114 };
107115 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{
116 .function_sections = true,
117 .data_sections = true,
108118 .pic = true,
109119 .no_builtin = true,
110120 });
......@@ -201,6 +211,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
201211 };
202212 }
203213 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{
214 .function_sections = true,
215 .data_sections = true,
204216 .no_builtin = true,
205217 });
206218 },
......@@ -448,8 +460,6 @@ fn addCcArgs(
448460 "-fomit-frame-pointer",
449461 "-fno-unwind-tables",
450462 "-fno-asynchronous-unwind-tables",
451 "-ffunction-sections",
452 "-fdata-sections",
453463
454464 "-Qunused-arguments",
455465 "-w", // disable all warnings