aboutsummaryrefslogtreecommitdiff
path: root/src/libunwind.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-05-09 01:52:26 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-05-09 01:52:26 -0700
commitbcb534c295d5cc6fd63caa570cc08e6b148a507c (patch)
tree0b17cb1e632d894f50f25e550d5113f232b0e877 /src/libunwind.zig
parentd9b00ee4ba48717ff6b306a6f9419e7b604ac04b (diff)
parent74f52954b9cb40d59d80b839b45bb859146731a7 (diff)
downloadzig-bcb534c295d5cc6fd63caa570cc08e6b148a507c.tar.gz
zig-bcb534c295d5cc6fd63caa570cc08e6b148a507c.zip
Merge branch 'llvm18'
Upgrades the LLVM, Clang, and LLD dependencies to LLVM 18.x Related to #16270
Diffstat (limited to 'src/libunwind.zig')
-rw-r--r--src/libunwind.zig54
1 files changed, 46 insertions, 8 deletions
diff --git a/src/libunwind.zig b/src/libunwind.zig
index 2fae6a65f9..808ea298ab 100644
--- a/src/libunwind.zig
+++ b/src/libunwind.zig
@@ -8,7 +8,13 @@ const Module = @import("Package/Module.zig");
const build_options = @import("build_options");
const trace = @import("tracy.zig").trace;
-pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
+pub const BuildError = error{
+ OutOfMemory,
+ SubCompilationFailed,
+ ZigCompilerNotBuiltWithLLVMExtensions,
+};
+
+pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void {
if (!build_options.have_llvm) {
return error.ZigCompilerNotBuiltWithLLVMExtensions;
}
@@ -21,7 +27,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
const arena = arena_allocator.allocator();
const output_mode = .Lib;
- const config = try Compilation.Config.resolve(.{
+ const config = Compilation.Config.resolve(.{
.output_mode = .Lib,
.resolved_target = comp.root_mod.resolved_target,
.is_test = false,
@@ -32,8 +38,15 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.link_libc = true,
// Disable LTO to avoid https://github.com/llvm/llvm-project/issues/56825
.lto = false,
- });
- const root_mod = try Module.create(arena, .{
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: resolving configuration failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+ const root_mod = Module.create(arena, .{
.global_cache_directory = comp.global_cache_directory,
.paths = .{
.root = .{ .root_dir = comp.zig_lib_directory },
@@ -59,7 +72,14 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.parent = null,
.builtin_mod = null,
.builtin_modules = null, // there is only one module in this compilation
- });
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: creating module failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
const root_name = "unwind";
const link_mode = .static;
@@ -124,7 +144,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.owner = root_mod,
};
}
- const sub_compilation = try Compilation.create(comp.gpa, arena, .{
+ const sub_compilation = Compilation.create(comp.gpa, arena, .{
.self_exe_path = comp.self_exe_path,
.local_cache_directory = comp.global_cache_directory,
.global_cache_directory = comp.global_cache_directory,
@@ -148,10 +168,27 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
.clang_passthrough_mode = comp.clang_passthrough_mode,
.skip_linker_dependencies = true,
- });
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: create compilation failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
defer sub_compilation.destroy();
- try comp.updateSubCompilation(sub_compilation, .libunwind, prog_node);
+ comp.updateSubCompilation(sub_compilation, .libunwind, prog_node) catch |err| switch (err) {
+ error.SubCompilationFailed => return error.SubCompilationFailed,
+ else => |e| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: compilation failed: {s}",
+ .{@errorName(e)},
+ );
+ return error.SubCompilationFailed;
+ },
+ };
assert(comp.libunwind_static_lib == null);
comp.libunwind_static_lib = try sub_compilation.toCrtFile();
@@ -164,6 +201,7 @@ const unwind_src_list = [_][]const u8{
"libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1.c",
"libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1-gcc-ext.c",
"libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-sjlj.c",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-wasm.c",
"libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersRestore.S",
"libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersSave.S",
"libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind_AIXExtras.cpp",