authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-14 19:10:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
log7e7d5dc958b08dc0f671cd1b119cd831fc877d16
treec9981ac31ed6e0a816d7a39856b0df743c222e84
parent6b44bddf5dd4a50c79cd1a4d3596cc07d868dd63

musl: update references to bin_file.options


2 files changed, 59 insertions(+), 29 deletions(-)

src/Compilation.zig+1-1
...@@ -6241,7 +6241,7 @@ pub fn build_crt_file(...@@ -6241,7 +6241,7 @@ pub fn build_crt_file(
6241 defer arena_allocator.deinit();6241 defer arena_allocator.deinit();
6242 const arena = arena_allocator.allocator();6242 const arena = arena_allocator.allocator();
62436243
6244 const basename = try std.zig.binNameAlloc(arena, .{6244 const basename = try std.zig.binNameAlloc(gpa, .{
6245 .root_name = root_name,6245 .root_name = root_name,
6246 .target = comp.root_mod.resolved_target.result,6246 .target = comp.root_mod.resolved_target.result,
6247 .output_mode = output_mode,6247 .output_mode = output_mode,
src/musl.zig+58-28
...@@ -3,6 +3,7 @@ const Allocator = std.mem.Allocator;...@@ -3,6 +3,7 @@ const Allocator = std.mem.Allocator;
3const mem = std.mem;3const mem = std.mem;
4const path = std.fs.path;4const path = std.fs.path;
5const assert = std.debug.assert;5const assert = std.debug.assert;
6const Module = @import("Package/Module.zig");
67
7const Compilation = @import("Compilation.zig");8const Compilation = @import("Compilation.zig");
8const build_options = @import("build_options");9const build_options = @import("build_options");
...@@ -190,41 +191,70 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -190,41 +191,70 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
190 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items);191 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items);
191 },192 },
192 .libc_so => {193 .libc_so => {
193 const target = comp.getTarget();194 const unwind_tables = false;
195 const optimize_mode = comp.compilerRtOptMode();
196 const strip = comp.compilerRtStrip();
197 const config = try Compilation.Config.resolve(.{
198 .output_mode = .Lib,
199 .link_mode = .Dynamic,
200 .resolved_target = comp.root_mod.resolved_target,
201 .is_test = false,
202 .have_zcu = false,
203 .emit_bin = true,
204 .root_optimize_mode = optimize_mode,
205 .root_strip = strip,
206 .link_libc = false,
207 .any_unwind_tables = unwind_tables,
208 });
209
210 const target = comp.root_mod.resolved_target.result;
194 const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{211 const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{
195 @tagName(target.cpu.arch),212 @tagName(target.cpu.arch),
196 });213 });
197 const clang_argv: []const []const u8 = if (target.ptrBitWidth() == 64)214 const cc_argv: []const []const u8 = if (target.ptrBitWidth() == 64)
198 &[_][]const u8{ "-DPTR64", arch_define }215 &.{ "-DPTR64", arch_define }
199 else216 else
200 &[_][]const u8{arch_define};217 &.{arch_define};
218
219 const root_mod = try Module.create(arena, .{
220 .global_cache_directory = comp.global_cache_directory,
221 .paths = .{
222 .root = .{ .root_dir = comp.zig_lib_directory },
223 .root_src_path = "",
224 },
225 .fully_qualified_name = "root",
226 .inherited = .{
227 .strip = strip,
228 .stack_check = false,
229 .stack_protector = 0,
230 .sanitize_c = false,
231 .sanitize_thread = false,
232 .red_zone = comp.root_mod.red_zone,
233 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
234 .valgrind = false,
235 .unwind_tables = unwind_tables,
236 .optimize_mode = optimize_mode,
237 .structured_cfg = comp.root_mod.structured_cfg,
238 },
239 .global = config,
240 .cc_argv = &.{},
241 .parent = null,
242 .builtin_mod = null,
243 });
201244
202 const sub_compilation = try Compilation.create(comp.gpa, .{245 const sub_compilation = try Compilation.create(comp.gpa, .{
203 .local_cache_directory = comp.global_cache_directory,246 .local_cache_directory = comp.global_cache_directory,
204 .global_cache_directory = comp.global_cache_directory,247 .global_cache_directory = comp.global_cache_directory,
205 .cache_mode = .whole,
206 .zig_lib_directory = comp.zig_lib_directory,248 .zig_lib_directory = comp.zig_lib_directory,
207 .target = target,249 .self_exe_path = comp.self_exe_path,
208 .root_name = "c",250 .cache_mode = .whole,
209 .main_mod = null,251 .config = config,
210 .output_mode = .Lib,252 .root_mod = root_mod,
211 .link_mode = .Dynamic,
212 .thread_pool = comp.thread_pool,253 .thread_pool = comp.thread_pool,
213 .libc_installation = comp.bin_file.options.libc_installation,254 .root_name = "c",
214 .emit_bin = Compilation.EmitLoc{ .directory = null, .basename = "libc.so" },255 .libc_installation = comp.libc_installation,
215 .optimize_mode = comp.compilerRtOptMode(),256 .emit_bin = .{ .directory = null, .basename = "libc.so" },
216 .want_sanitize_c = false,
217 .want_stack_check = false,
218 .want_stack_protector = 0,
219 .want_red_zone = comp.bin_file.options.red_zone,
220 .omit_frame_pointer = comp.bin_file.options.omit_frame_pointer,
221 .want_valgrind = false,
222 .want_tsan = false,
223 .emit_h = null,257 .emit_h = null,
224 .strip = comp.compilerRtStrip(),
225 .is_native_os = false,
226 .is_native_abi = false,
227 .self_exe_path = comp.self_exe_path,
228 .verbose_cc = comp.verbose_cc,258 .verbose_cc = comp.verbose_cc,
229 .verbose_link = comp.verbose_link,259 .verbose_link = comp.verbose_link,
230 .verbose_air = comp.verbose_air,260 .verbose_air = comp.verbose_air,
...@@ -233,9 +263,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -233,9 +263,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
233 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,263 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
234 .clang_passthrough_mode = comp.clang_passthrough_mode,264 .clang_passthrough_mode = comp.clang_passthrough_mode,
235 .c_source_files = &[_]Compilation.CSourceFile{265 .c_source_files = &[_]Compilation.CSourceFile{
236 .{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "libc.S" }) },266 .{ .src_path = try comp.zig_lib_directory.join(arena, &.{ "libc", "musl", "libc.S" }) },
237 },267 },
238 .clang_argv = clang_argv,268 .cc_argv = cc_argv,
239 .skip_linker_dependencies = true,269 .skip_linker_dependencies = true,
240 .soname = "libc.so",270 .soname = "libc.so",
241 });271 });
...@@ -249,8 +279,8 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -249,8 +279,8 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
249 errdefer comp.gpa.free(basename);279 errdefer comp.gpa.free(basename);
250280
251 comp.crt_files.putAssumeCapacityNoClobber(basename, .{281 comp.crt_files.putAssumeCapacityNoClobber(basename, .{
252 .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{282 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{
253 sub_compilation.bin_file.options.emit.?.sub_path,283 sub_compilation.bin_file.?.emit.sub_path,
254 }),284 }),
255 .lock = sub_compilation.bin_file.toOwnedLock(),285 .lock = sub_compilation.bin_file.toOwnedLock(),
256 });286 });