mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
update libunwind references to bin_file.options
This commit is contained in:
parent
f5ddef1e45
commit
1642c003b4
@ -6212,9 +6212,9 @@ fn buildOutputFromZig(
|
||||
.local_cache_directory = comp.global_cache_directory,
|
||||
.zig_lib_directory = comp.zig_lib_directory,
|
||||
.resolved = config,
|
||||
.root_mod = root_mod,
|
||||
.cache_mode = .whole,
|
||||
.root_name = root_name,
|
||||
.root_mod = root_mod,
|
||||
.thread_pool = comp.thread_pool,
|
||||
.libc_installation = comp.bin_file.options.libc_installation,
|
||||
.emit_bin = emit_bin,
|
||||
|
||||
@ -4,6 +4,7 @@ const assert = std.debug.assert;
|
||||
|
||||
const target_util = @import("target.zig");
|
||||
const Compilation = @import("Compilation.zig");
|
||||
const Module = @import("Package/Module.zig");
|
||||
const build_options = @import("build_options");
|
||||
const trace = @import("tracy.zig").trace;
|
||||
|
||||
@ -19,10 +20,44 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
defer arena_allocator.deinit();
|
||||
const arena = arena_allocator.allocator();
|
||||
|
||||
const root_name = "unwind";
|
||||
const output_mode = .Lib;
|
||||
const config = try Compilation.Config.resolve(.{
|
||||
.output_mode = .Lib,
|
||||
.resolved_target = comp.root_mod.resolved_target,
|
||||
.is_test = false,
|
||||
.have_zcu = false,
|
||||
.emit_bin = true,
|
||||
.root_optimize_mode = comp.compilerRtOptMode(),
|
||||
.link_libc = true,
|
||||
// Disable LTO to avoid https://github.com/llvm/llvm-project/issues/56825
|
||||
.lto = false,
|
||||
});
|
||||
const root_mod = Module.create(.{
|
||||
.paths = .{
|
||||
.root = .{ .root_dir = comp.zig_lib_directory },
|
||||
.root_src_path = "",
|
||||
},
|
||||
.fully_qualified_name = "root",
|
||||
.inherited = .{
|
||||
.strip = comp.compilerRtStrip(),
|
||||
.stack_check = false,
|
||||
.stack_protector = 0,
|
||||
.red_zone = comp.root_mod.red_zone,
|
||||
.omit_frame_pointer = comp.root_mod.omit_frame_pointer,
|
||||
.valgrind = false,
|
||||
.sanitize_c = false,
|
||||
.sanitize_thread = false,
|
||||
.unwind_tables = false,
|
||||
.pic = comp.root_mod.pic,
|
||||
.optimize_mode = comp.compilerRtOptMode(),
|
||||
},
|
||||
.global = config,
|
||||
.cc_argv = &.{},
|
||||
});
|
||||
|
||||
const root_name = "unwind";
|
||||
const link_mode = .Static;
|
||||
const target = comp.getTarget();
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
const basename = try std.zig.binNameAlloc(arena, .{
|
||||
.root_name = root_name,
|
||||
.target = target,
|
||||
@ -64,7 +99,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
// defines will be correct.
|
||||
try cflags.append("-D_LIBUNWIND_IS_NATIVE_ONLY");
|
||||
|
||||
if (comp.bin_file.options.optimize_mode == .Debug) {
|
||||
if (comp.root_mod.optimize_mode == .Debug) {
|
||||
try cflags.append("-D_DEBUG");
|
||||
}
|
||||
if (!comp.config.any_non_single_threaded) {
|
||||
@ -83,46 +118,29 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
};
|
||||
}
|
||||
const sub_compilation = try Compilation.create(comp.gpa, .{
|
||||
.self_exe_path = comp.self_exe_path,
|
||||
.local_cache_directory = comp.global_cache_directory,
|
||||
.global_cache_directory = comp.global_cache_directory,
|
||||
.zig_lib_directory = comp.zig_lib_directory,
|
||||
.resolved = config,
|
||||
.root_mod = root_mod,
|
||||
.cache_mode = .whole,
|
||||
.target = target,
|
||||
.root_name = root_name,
|
||||
.main_mod = null,
|
||||
.output_mode = output_mode,
|
||||
.thread_pool = comp.thread_pool,
|
||||
.libc_installation = comp.bin_file.options.libc_installation,
|
||||
.libc_installation = comp.libc_installation,
|
||||
.emit_bin = emit_bin,
|
||||
.optimize_mode = comp.compilerRtOptMode(),
|
||||
.link_mode = link_mode,
|
||||
.want_sanitize_c = false,
|
||||
.want_stack_check = false,
|
||||
.want_stack_protector = 0,
|
||||
.want_red_zone = comp.bin_file.options.red_zone,
|
||||
.omit_frame_pointer = comp.bin_file.options.omit_frame_pointer,
|
||||
.want_valgrind = false,
|
||||
.want_tsan = false,
|
||||
.want_pic = comp.bin_file.options.pic,
|
||||
.want_pie = null,
|
||||
// Disable LTO to avoid https://github.com/llvm/llvm-project/issues/56825
|
||||
.want_lto = false,
|
||||
.function_sections = comp.bin_file.options.function_sections,
|
||||
.emit_h = null,
|
||||
.strip = comp.compilerRtStrip(),
|
||||
.is_native_os = comp.bin_file.options.is_native_os,
|
||||
.is_native_abi = comp.bin_file.options.is_native_abi,
|
||||
.self_exe_path = comp.self_exe_path,
|
||||
.function_sections = comp.bin_file.function_sections,
|
||||
.c_source_files = &c_source_files,
|
||||
.verbose_cc = comp.verbose_cc,
|
||||
.verbose_link = comp.bin_file.options.verbose_link,
|
||||
.verbose_link = comp.verbose_link,
|
||||
.verbose_air = comp.verbose_air,
|
||||
.verbose_llvm_ir = comp.verbose_llvm_ir,
|
||||
.verbose_llvm_bc = comp.verbose_llvm_bc,
|
||||
.verbose_cimport = comp.verbose_cimport,
|
||||
.verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
|
||||
.clang_passthrough_mode = comp.clang_passthrough_mode,
|
||||
.link_libc = true,
|
||||
.skip_linker_dependencies = true,
|
||||
});
|
||||
defer sub_compilation.destroy();
|
||||
@ -132,8 +150,8 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
assert(comp.libunwind_static_lib == null);
|
||||
|
||||
comp.libunwind_static_lib = Compilation.CRTFile{
|
||||
.full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{
|
||||
sub_compilation.bin_file.options.emit.?.sub_path,
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
};
|
||||
|
||||
32
src/main.zig
32
src/main.zig
@ -3552,7 +3552,7 @@ fn buildOutputType(
|
||||
if (test_exec_args.items.len == 0 and target.ofmt == .c) default_exec_args: {
|
||||
// Default to using `zig run` to execute the produced .c code from `zig test`.
|
||||
const c_code_loc = emit_bin_loc orelse break :default_exec_args;
|
||||
const c_code_directory = c_code_loc.directory orelse comp.bin_file.options.emit.?.directory;
|
||||
const c_code_directory = c_code_loc.directory orelse comp.bin_file.?.emit.directory;
|
||||
const c_code_path = try fs.path.join(arena, &[_][]const u8{
|
||||
c_code_directory.path orelse ".", c_code_loc.basename,
|
||||
});
|
||||
@ -3921,7 +3921,7 @@ fn serve(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (comp.bin_file.options.output_mode == .Exe) {
|
||||
if (comp.config.output_mode == .Exe) {
|
||||
try comp.makeBinFileWritable();
|
||||
}
|
||||
|
||||
@ -3971,7 +3971,7 @@ fn serve(
|
||||
try comp.hotCodeSwap(main_progress_node, pid);
|
||||
try serveUpdateResults(&server, comp);
|
||||
} else {
|
||||
if (comp.bin_file.options.output_mode == .Exe) {
|
||||
if (comp.config.output_mode == .Exe) {
|
||||
try comp.makeBinFileWritable();
|
||||
}
|
||||
try comp.update(main_progress_node);
|
||||
@ -4067,13 +4067,14 @@ fn serveUpdateResults(s: *Server, comp: *Compilation) !void {
|
||||
// system depends on that fact. So, until the protocol is changed to
|
||||
// reflect this, this logic only needs to ensure that emit_bin_path is
|
||||
// emitted for at least one thing, if there are any artifacts.
|
||||
if (comp.bin_file.options.emit) |emit| {
|
||||
if (comp.bin_file) |lf| {
|
||||
const emit = lf.emit;
|
||||
const full_path = try emit.directory.join(gpa, &.{emit.sub_path});
|
||||
defer gpa.free(full_path);
|
||||
try s.serveEmitBinPath(full_path, .{
|
||||
.flags = .{ .cache_hit = comp.last_update_was_cache_hit },
|
||||
});
|
||||
} else if (comp.bin_file.options.docs_emit) |emit| {
|
||||
} else if (comp.docs_emit) |emit| {
|
||||
const full_path = try emit.directory.join(gpa, &.{emit.sub_path});
|
||||
defer gpa.free(full_path);
|
||||
try s.serveEmitBinPath(full_path, .{
|
||||
@ -4148,11 +4149,11 @@ fn runOrTest(
|
||||
runtime_args_start: ?usize,
|
||||
link_libc: bool,
|
||||
) !void {
|
||||
const exe_emit = comp.bin_file.options.emit orelse return;
|
||||
const lf = comp.bin_file orelse return;
|
||||
// A naive `directory.join` here will indeed get the correct path to the binary,
|
||||
// however, in the case of cwd, we actually want `./foo` so that the path can be executed.
|
||||
const exe_path = try fs.path.join(arena, &[_][]const u8{
|
||||
exe_emit.directory.path orelse ".", exe_emit.sub_path,
|
||||
lf.emit.directory.path orelse ".", lf.emit.sub_path,
|
||||
});
|
||||
|
||||
var argv = std.ArrayList([]const u8).init(gpa);
|
||||
@ -4244,7 +4245,7 @@ fn runOrTestHotSwap(
|
||||
all_args: []const []const u8,
|
||||
runtime_args_start: ?usize,
|
||||
) !std.ChildProcess.Id {
|
||||
const exe_emit = comp.bin_file.options.emit.?;
|
||||
const lf = comp.bin_file.?;
|
||||
|
||||
const exe_path = switch (builtin.target.os.tag) {
|
||||
// On Windows it seems impossible to perform an atomic rename of a file that is currently
|
||||
@ -4252,16 +4253,16 @@ fn runOrTestHotSwap(
|
||||
// tmp zig-cache and use it to spawn the child process. This way we are free to update
|
||||
// the binary with each requested hot update.
|
||||
.windows => blk: {
|
||||
try exe_emit.directory.handle.copyFile(exe_emit.sub_path, comp.local_cache_directory.handle, exe_emit.sub_path, .{});
|
||||
try lf.emit.directory.handle.copyFile(lf.emit.sub_path, comp.local_cache_directory.handle, lf.emit.sub_path, .{});
|
||||
break :blk try fs.path.join(gpa, &[_][]const u8{
|
||||
comp.local_cache_directory.path orelse ".", exe_emit.sub_path,
|
||||
comp.local_cache_directory.path orelse ".", lf.emit.sub_path,
|
||||
});
|
||||
},
|
||||
|
||||
// A naive `directory.join` here will indeed get the correct path to the binary,
|
||||
// however, in the case of cwd, we actually want `./foo` so that the path can be executed.
|
||||
else => try fs.path.join(gpa, &[_][]const u8{
|
||||
exe_emit.directory.path orelse ".", exe_emit.sub_path,
|
||||
lf.emit.directory.path orelse ".", lf.emit.sub_path,
|
||||
}),
|
||||
};
|
||||
defer gpa.free(exe_path);
|
||||
@ -4367,7 +4368,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati
|
||||
assert(comp.c_source_files.len == 1);
|
||||
const c_source_file = comp.c_source_files[0];
|
||||
|
||||
const translated_zig_basename = try std.fmt.allocPrint(arena, "{s}.zig", .{comp.bin_file.options.root_name});
|
||||
const translated_zig_basename = try std.fmt.allocPrint(arena, "{s}.zig", .{comp.root_name});
|
||||
|
||||
var man: Cache.Manifest = comp.obtainCObjectCacheManifest();
|
||||
man.want_shared_lock = false;
|
||||
@ -5450,11 +5451,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
};
|
||||
try comp.makeBinFileExecutable();
|
||||
|
||||
const emit = comp.bin_file.options.emit.?;
|
||||
child_argv.items[argv_index_exe] = try emit.directory.join(
|
||||
arena,
|
||||
&[_][]const u8{emit.sub_path},
|
||||
);
|
||||
const emit = comp.bin_file.?.emit;
|
||||
child_argv.items[argv_index_exe] = try emit.directory.join(arena, &.{emit.sub_path});
|
||||
|
||||
break :argv child_argv.items;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user