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(...@@ -6262,6 +6262,8 @@ fn buildOutputFromZig(
6262}6262}
62636263
6264pub const CrtFileOptions = struct {6264pub const CrtFileOptions = struct {
6265 function_sections: ?bool = null,
6266 data_sections: ?bool = null,
6265 pic: ?bool = null,6267 pic: ?bool = null,
6266 no_builtin: ?bool = null,6268 no_builtin: ?bool = null,
6267};6269};
...@@ -6356,6 +6358,8 @@ pub fn build_crt_file(...@@ -6356,6 +6358,8 @@ pub fn build_crt_file(
6356 .directory = null, // Put it in the cache directory.6358 .directory = null, // Put it in the cache directory.
6357 .basename = basename,6359 .basename = basename,
6358 },6360 },
6361 .function_sections = options.function_sections orelse false,
6362 .data_sections = options.data_sections orelse false,
6359 .emit_h = null,6363 .emit_h = null,
6360 .c_source_files = c_source_files,6364 .c_source_files = c_source_files,
6361 .verbose_cc = comp.verbose_cc,6365 .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...@@ -39,6 +39,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
39 },39 },
40 };40 };
41 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{41 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{
42 .function_sections = true,
43 .data_sections = true,
42 .no_builtin = true,44 .no_builtin = true,
43 });45 });
44 },46 },
...@@ -53,6 +55,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -53,6 +55,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
53 },55 },
54 };56 };
55 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{57 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{
58 .function_sections = true,
59 .data_sections = true,
56 .no_builtin = true,60 .no_builtin = true,
57 });61 });
58 },62 },
...@@ -70,6 +74,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -70,6 +74,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
70 },74 },
71 };75 };
72 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{76 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{
77 .function_sections = true,
78 .data_sections = true,
73 .no_builtin = true,79 .no_builtin = true,
74 });80 });
75 },81 },
...@@ -87,6 +93,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -87,6 +93,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
87 },93 },
88 };94 };
89 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{95 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{
96 .function_sections = true,
97 .data_sections = true,
90 .pic = true,98 .pic = true,
91 .no_builtin = true,99 .no_builtin = true,
92 });100 });
...@@ -105,6 +113,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -105,6 +113,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
105 },113 },
106 };114 };
107 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{115 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{
116 .function_sections = true,
117 .data_sections = true,
108 .pic = true,118 .pic = true,
109 .no_builtin = true,119 .no_builtin = true,
110 });120 });
...@@ -201,6 +211,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -201,6 +211,8 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
201 };211 };
202 }212 }
203 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{213 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{
214 .function_sections = true,
215 .data_sections = true,
204 .no_builtin = true,216 .no_builtin = true,
205 });217 });
206 },218 },
...@@ -448,8 +460,6 @@ fn addCcArgs(...@@ -448,8 +460,6 @@ fn addCcArgs(
448 "-fomit-frame-pointer",460 "-fomit-frame-pointer",
449 "-fno-unwind-tables",461 "-fno-unwind-tables",
450 "-fno-asynchronous-unwind-tables",462 "-fno-asynchronous-unwind-tables",
451 "-ffunction-sections",
452 "-fdata-sections",
453463
454 "-Qunused-arguments",464 "-Qunused-arguments",
455 "-w", // disable all warnings465 "-w", // disable all warnings