| ... | @@ -107,7 +107,13 @@ const libcxx_files = [_][]const u8{ | ... | @@ -107,7 +107,13 @@ const libcxx_files = [_][]const u8{ |
| 107 | "src/verbose_abort.cpp", | 107 | "src/verbose_abort.cpp", |
| 108 | }; | 108 | }; |
| 109 | | 109 | |
| 110 | pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | 110 | pub const BuildError = error{ |
| | 111 | OutOfMemory, |
| | 112 | SubCompilationFailed, |
| | 113 | ZigCompilerNotBuiltWithLLVMExtensions, |
| | 114 | }; |
| | 115 | |
| | 116 | pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void { |
| 111 | if (!build_options.have_llvm) { | 117 | if (!build_options.have_llvm) { |
| 112 | return error.ZigCompilerNotBuiltWithLLVMExtensions; | 118 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 113 | } | 119 | } |
| ... | @@ -148,7 +154,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -148,7 +154,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 148 | const optimize_mode = comp.compilerRtOptMode(); | 154 | const optimize_mode = comp.compilerRtOptMode(); |
| 149 | const strip = comp.compilerRtStrip(); | 155 | const strip = comp.compilerRtStrip(); |
| 150 | | 156 | |
| 151 | const config = try Compilation.Config.resolve(.{ | 157 | const config = Compilation.Config.resolve(.{ |
| 152 | .output_mode = output_mode, | 158 | .output_mode = output_mode, |
| 153 | .link_mode = link_mode, | 159 | .link_mode = link_mode, |
| 154 | .resolved_target = comp.root_mod.resolved_target, | 160 | .resolved_target = comp.root_mod.resolved_target, |
| ... | @@ -160,9 +166,16 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -160,9 +166,16 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 160 | .link_libc = true, | 166 | .link_libc = true, |
| 161 | .lto = comp.config.lto, | 167 | .lto = comp.config.lto, |
| 162 | .any_sanitize_thread = comp.config.any_sanitize_thread, | 168 | .any_sanitize_thread = comp.config.any_sanitize_thread, |
| 163 | }); | 169 | }) catch |err| { |
| | 170 | comp.setMiscFailure( |
| | 171 | .libcxx, |
| | 172 | "unable to build libc++: resolving configuration failed: {s}", |
| | 173 | .{@errorName(err)}, |
| | 174 | ); |
| | 175 | return error.SubCompilationFailed; |
| | 176 | }; |
| 164 | | 177 | |
| 165 | const root_mod = try Module.create(arena, .{ | 178 | const root_mod = Module.create(arena, .{ |
| 166 | .global_cache_directory = comp.global_cache_directory, | 179 | .global_cache_directory = comp.global_cache_directory, |
| 167 | .paths = .{ | 180 | .paths = .{ |
| 168 | .root = .{ .root_dir = comp.zig_lib_directory }, | 181 | .root = .{ .root_dir = comp.zig_lib_directory }, |
| ... | @@ -188,7 +201,14 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -188,7 +201,14 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 188 | .parent = null, | 201 | .parent = null, |
| 189 | .builtin_mod = null, | 202 | .builtin_mod = null, |
| 190 | .builtin_modules = null, // there is only one module in this compilation | 203 | .builtin_modules = null, // there is only one module in this compilation |
| 191 | }); | 204 | }) catch |err| { |
| | 205 | comp.setMiscFailure( |
| | 206 | .libcxx, |
| | 207 | "unable to build libc++: creating module failed: {s}", |
| | 208 | .{@errorName(err)}, |
| | 209 | ); |
| | 210 | return error.SubCompilationFailed; |
| | 211 | }; |
| 192 | | 212 | |
| 193 | var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len); | 213 | var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len); |
| 194 | | 214 | |
| ... | @@ -288,7 +308,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -288,7 +308,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 288 | }); | 308 | }); |
| 289 | } | 309 | } |
| 290 | | 310 | |
| 291 | const sub_compilation = try Compilation.create(comp.gpa, arena, .{ | 311 | const sub_compilation = Compilation.create(comp.gpa, arena, .{ |
| 292 | .local_cache_directory = comp.global_cache_directory, | 312 | .local_cache_directory = comp.global_cache_directory, |
| 293 | .global_cache_directory = comp.global_cache_directory, | 313 | .global_cache_directory = comp.global_cache_directory, |
| 294 | .zig_lib_directory = comp.zig_lib_directory, | 314 | .zig_lib_directory = comp.zig_lib_directory, |
| ... | @@ -311,16 +331,33 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -311,16 +331,33 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 311 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, | 331 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 312 | .clang_passthrough_mode = comp.clang_passthrough_mode, | 332 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 313 | .skip_linker_dependencies = true, | 333 | .skip_linker_dependencies = true, |
| 314 | }); | 334 | }) catch |err| { |
| | 335 | comp.setMiscFailure( |
| | 336 | .libcxx, |
| | 337 | "unable to build libc++: create compilation failed: {s}", |
| | 338 | .{@errorName(err)}, |
| | 339 | ); |
| | 340 | return error.SubCompilationFailed; |
| | 341 | }; |
| 315 | defer sub_compilation.destroy(); | 342 | defer sub_compilation.destroy(); |
| 316 | | 343 | |
| 317 | try comp.updateSubCompilation(sub_compilation, .libcxx, prog_node); | 344 | comp.updateSubCompilation(sub_compilation, .libcxx, prog_node) catch |err| switch (err) { |
| | 345 | error.SubCompilationFailed => return error.SubCompilationFailed, |
| | 346 | else => |e| { |
| | 347 | comp.setMiscFailure( |
| | 348 | .libcxx, |
| | 349 | "unable to build libc++: compilation failed: {s}", |
| | 350 | .{@errorName(e)}, |
| | 351 | ); |
| | 352 | return error.SubCompilationFailed; |
| | 353 | }, |
| | 354 | }; |
| 318 | | 355 | |
| 319 | assert(comp.libcxx_static_lib == null); | 356 | assert(comp.libcxx_static_lib == null); |
| 320 | comp.libcxx_static_lib = try sub_compilation.toCrtFile(); | 357 | comp.libcxx_static_lib = try sub_compilation.toCrtFile(); |
| 321 | } | 358 | } |
| 322 | | 359 | |
| 323 | pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | 360 | pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void { |
| 324 | if (!build_options.have_llvm) { | 361 | if (!build_options.have_llvm) { |
| 325 | return error.ZigCompilerNotBuiltWithLLVMExtensions; | 362 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 326 | } | 363 | } |
| ... | @@ -362,7 +399,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -362,7 +399,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 362 | const strip = comp.compilerRtStrip(); | 399 | const strip = comp.compilerRtStrip(); |
| 363 | const unwind_tables = true; | 400 | const unwind_tables = true; |
| 364 | | 401 | |
| 365 | const config = try Compilation.Config.resolve(.{ | 402 | const config = Compilation.Config.resolve(.{ |
| 366 | .output_mode = output_mode, | 403 | .output_mode = output_mode, |
| 367 | .link_mode = link_mode, | 404 | .link_mode = link_mode, |
| 368 | .resolved_target = comp.root_mod.resolved_target, | 405 | .resolved_target = comp.root_mod.resolved_target, |
| ... | @@ -375,9 +412,16 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -375,9 +412,16 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 375 | .any_unwind_tables = unwind_tables, | 412 | .any_unwind_tables = unwind_tables, |
| 376 | .lto = comp.config.lto, | 413 | .lto = comp.config.lto, |
| 377 | .any_sanitize_thread = comp.config.any_sanitize_thread, | 414 | .any_sanitize_thread = comp.config.any_sanitize_thread, |
| 378 | }); | 415 | }) catch |err| { |
| | 416 | comp.setMiscFailure( |
| | 417 | .libcxxabi, |
| | 418 | "unable to build libc++abi: resolving configuration failed: {s}", |
| | 419 | .{@errorName(err)}, |
| | 420 | ); |
| | 421 | return error.SubCompilationFailed; |
| | 422 | }; |
| 379 | | 423 | |
| 380 | const root_mod = try Module.create(arena, .{ | 424 | const root_mod = Module.create(arena, .{ |
| 381 | .global_cache_directory = comp.global_cache_directory, | 425 | .global_cache_directory = comp.global_cache_directory, |
| 382 | .paths = .{ | 426 | .paths = .{ |
| 383 | .root = .{ .root_dir = comp.zig_lib_directory }, | 427 | .root = .{ .root_dir = comp.zig_lib_directory }, |
| ... | @@ -404,7 +448,14 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -404,7 +448,14 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 404 | .parent = null, | 448 | .parent = null, |
| 405 | .builtin_mod = null, | 449 | .builtin_mod = null, |
| 406 | .builtin_modules = null, // there is only one module in this compilation | 450 | .builtin_modules = null, // there is only one module in this compilation |
| 407 | }); | 451 | }) catch |err| { |
| | 452 | comp.setMiscFailure( |
| | 453 | .libcxxabi, |
| | 454 | "unable to build libc++abi: creating module failed: {s}", |
| | 455 | .{@errorName(err)}, |
| | 456 | ); |
| | 457 | return error.SubCompilationFailed; |
| | 458 | }; |
| 408 | | 459 | |
| 409 | var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len); | 460 | var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len); |
| 410 | | 461 | |
| ... | @@ -487,7 +538,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -487,7 +538,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 487 | }); | 538 | }); |
| 488 | } | 539 | } |
| 489 | | 540 | |
| 490 | const sub_compilation = try Compilation.create(comp.gpa, arena, .{ | 541 | const sub_compilation = Compilation.create(comp.gpa, arena, .{ |
| 491 | .local_cache_directory = comp.global_cache_directory, | 542 | .local_cache_directory = comp.global_cache_directory, |
| 492 | .global_cache_directory = comp.global_cache_directory, | 543 | .global_cache_directory = comp.global_cache_directory, |
| 493 | .zig_lib_directory = comp.zig_lib_directory, | 544 | .zig_lib_directory = comp.zig_lib_directory, |
| ... | @@ -510,10 +561,27 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -510,10 +561,27 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 510 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, | 561 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 511 | .clang_passthrough_mode = comp.clang_passthrough_mode, | 562 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 512 | .skip_linker_dependencies = true, | 563 | .skip_linker_dependencies = true, |
| 513 | }); | 564 | }) catch |err| { |
| | 565 | comp.setMiscFailure( |
| | 566 | .libcxxabi, |
| | 567 | "unable to build libc++abi: create compilation failed: {s}", |
| | 568 | .{@errorName(err)}, |
| | 569 | ); |
| | 570 | return error.SubCompilationFailed; |
| | 571 | }; |
| 514 | defer sub_compilation.destroy(); | 572 | defer sub_compilation.destroy(); |
| 515 | | 573 | |
| 516 | try comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node); | 574 | comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node) catch |err| switch (err) { |
| | 575 | error.SubCompilationFailed => return error.SubCompilationFailed, |
| | 576 | else => |e| { |
| | 577 | comp.setMiscFailure( |
| | 578 | .libcxxabi, |
| | 579 | "unable to build libc++abi: compilation failed: {s}", |
| | 580 | .{@errorName(e)}, |
| | 581 | ); |
| | 582 | return error.SubCompilationFailed; |
| | 583 | }, |
| | 584 | }; |
| 517 | | 585 | |
| 518 | assert(comp.libcxxabi_static_lib == null); | 586 | assert(comp.libcxxabi_static_lib == null); |
| 519 | comp.libcxxabi_static_lib = try sub_compilation.toCrtFile(); | 587 | comp.libcxxabi_static_lib = try sub_compilation.toCrtFile(); |