| ... | @@ -6,6 +6,7 @@ const target_util = @import("target.zig"); | ... | @@ -6,6 +6,7 @@ const target_util = @import("target.zig"); |
| 6 | const Compilation = @import("Compilation.zig"); | 6 | const Compilation = @import("Compilation.zig"); |
| 7 | const build_options = @import("build_options"); | 7 | const build_options = @import("build_options"); |
| 8 | const trace = @import("tracy.zig").trace; | 8 | const trace = @import("tracy.zig").trace; |
| | 9 | const Module = @import("Package/Module.zig"); |
| 9 | | 10 | |
| 10 | pub const AbiVersion = enum(u2) { | 11 | pub const AbiVersion = enum(u2) { |
| 11 | @"1" = 1, | 12 | @"1" = 1, |
| ... | @@ -115,7 +116,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -115,7 +116,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 115 | const root_name = "c++"; | 116 | const root_name = "c++"; |
| 116 | const output_mode = .Lib; | 117 | const output_mode = .Lib; |
| 117 | const link_mode = .Static; | 118 | const link_mode = .Static; |
| 118 | const target = comp.getTarget(); | 119 | const target = comp.root_mod.resolved_target.result; |
| 119 | const basename = try std.zig.binNameAlloc(arena, .{ | 120 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 120 | .root_name = root_name, | 121 | .root_name = root_name, |
| 121 | .target = target, | 122 | .target = target, |
| ... | @@ -226,46 +227,70 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -226,46 +227,70 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 226 | }); | 227 | }); |
| 227 | } | 228 | } |
| 228 | | 229 | |
| | 230 | const optimize_mode = comp.compilerRtOptMode(); |
| | 231 | const strip = comp.compilerRtStrip(); |
| | 232 | |
| | 233 | const config = try Compilation.Config.resolve(.{ |
| | 234 | .output_mode = output_mode, |
| | 235 | .link_mode = link_mode, |
| | 236 | .resolved_target = comp.root_mod.resolved_target, |
| | 237 | .is_test = false, |
| | 238 | .have_zcu = false, |
| | 239 | .emit_bin = true, |
| | 240 | .root_optimize_mode = optimize_mode, |
| | 241 | .root_strip = strip, |
| | 242 | .link_libc = true, |
| | 243 | .lto = comp.config.lto, |
| | 244 | }); |
| | 245 | |
| | 246 | const root_mod = try Module.create(arena, .{ |
| | 247 | .global_cache_directory = comp.global_cache_directory, |
| | 248 | .paths = .{ |
| | 249 | .root = .{ .root_dir = comp.zig_lib_directory }, |
| | 250 | .root_src_path = "", |
| | 251 | }, |
| | 252 | .fully_qualified_name = "root", |
| | 253 | .inherited = .{ |
| | 254 | .strip = strip, |
| | 255 | .stack_check = false, |
| | 256 | .stack_protector = 0, |
| | 257 | .sanitize_c = false, |
| | 258 | .sanitize_thread = comp.config.any_sanitize_thread, |
| | 259 | .red_zone = comp.root_mod.red_zone, |
| | 260 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, |
| | 261 | .valgrind = false, |
| | 262 | .optimize_mode = optimize_mode, |
| | 263 | .structured_cfg = comp.root_mod.structured_cfg, |
| | 264 | .pic = comp.root_mod.pic, |
| | 265 | }, |
| | 266 | .global = config, |
| | 267 | .cc_argv = &.{}, |
| | 268 | .parent = null, |
| | 269 | .builtin_mod = null, |
| | 270 | }); |
| | 271 | |
| 229 | const sub_compilation = try Compilation.create(comp.gpa, .{ | 272 | const sub_compilation = try Compilation.create(comp.gpa, .{ |
| 230 | .local_cache_directory = comp.global_cache_directory, | 273 | .local_cache_directory = comp.global_cache_directory, |
| 231 | .global_cache_directory = comp.global_cache_directory, | 274 | .global_cache_directory = comp.global_cache_directory, |
| 232 | .zig_lib_directory = comp.zig_lib_directory, | 275 | .zig_lib_directory = comp.zig_lib_directory, |
| | 276 | .self_exe_path = comp.self_exe_path, |
| 233 | .cache_mode = .whole, | 277 | .cache_mode = .whole, |
| 234 | .target = target, | 278 | .config = config, |
| | 279 | .root_mod = root_mod, |
| 235 | .root_name = root_name, | 280 | .root_name = root_name, |
| 236 | .main_mod = null, | | |
| 237 | .output_mode = output_mode, | | |
| 238 | .thread_pool = comp.thread_pool, | 281 | .thread_pool = comp.thread_pool, |
| 239 | .libc_installation = comp.bin_file.options.libc_installation, | 282 | .libc_installation = comp.libc_installation, |
| 240 | .emit_bin = emit_bin, | 283 | .emit_bin = emit_bin, |
| 241 | .optimize_mode = comp.compilerRtOptMode(), | | |
| 242 | .link_mode = link_mode, | | |
| 243 | .want_sanitize_c = false, | | |
| 244 | .want_stack_check = false, | | |
| 245 | .want_stack_protector = 0, | | |
| 246 | .want_red_zone = comp.bin_file.options.red_zone, | | |
| 247 | .omit_frame_pointer = comp.bin_file.options.omit_frame_pointer, | | |
| 248 | .want_valgrind = false, | | |
| 249 | .want_tsan = comp.bin_file.options.tsan, | | |
| 250 | .want_pic = comp.bin_file.options.pic, | | |
| 251 | .want_pie = null, | | |
| 252 | .want_lto = comp.bin_file.options.lto, | | |
| 253 | .function_sections = comp.bin_file.options.function_sections, | | |
| 254 | .emit_h = null, | 284 | .emit_h = null, |
| 255 | .strip = comp.compilerRtStrip(), | | |
| 256 | .is_native_os = comp.bin_file.options.is_native_os, | | |
| 257 | .is_native_abi = comp.bin_file.options.is_native_abi, | | |
| 258 | .self_exe_path = comp.self_exe_path, | | |
| 259 | .c_source_files = c_source_files.items, | 285 | .c_source_files = c_source_files.items, |
| 260 | .verbose_cc = comp.verbose_cc, | 286 | .verbose_cc = comp.verbose_cc, |
| 261 | .verbose_link = comp.bin_file.options.verbose_link, | 287 | .verbose_link = comp.verbose_link, |
| 262 | .verbose_air = comp.verbose_air, | 288 | .verbose_air = comp.verbose_air, |
| 263 | .verbose_llvm_ir = comp.verbose_llvm_ir, | 289 | .verbose_llvm_ir = comp.verbose_llvm_ir, |
| 264 | .verbose_llvm_bc = comp.verbose_llvm_bc, | 290 | .verbose_llvm_bc = comp.verbose_llvm_bc, |
| 265 | .verbose_cimport = comp.verbose_cimport, | 291 | .verbose_cimport = comp.verbose_cimport, |
| 266 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, | 292 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 267 | .clang_passthrough_mode = comp.clang_passthrough_mode, | 293 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 268 | .link_libc = true, | | |
| 269 | .skip_linker_dependencies = true, | 294 | .skip_linker_dependencies = true, |
| 270 | }); | 295 | }); |
| 271 | defer sub_compilation.destroy(); | 296 | defer sub_compilation.destroy(); |
| ... | @@ -274,8 +299,8 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -274,8 +299,8 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 274 | | 299 | |
| 275 | assert(comp.libcxx_static_lib == null); | 300 | assert(comp.libcxx_static_lib == null); |
| 276 | comp.libcxx_static_lib = Compilation.CRTFile{ | 301 | comp.libcxx_static_lib = Compilation.CRTFile{ |
| 277 | .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{ | 302 | .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{ |
| 278 | sub_compilation.bin_file.options.emit.?.sub_path, | 303 | sub_compilation.bin_file.?.emit.sub_path, |
| 279 | }), | 304 | }), |
| 280 | .lock = sub_compilation.bin_file.toOwnedLock(), | 305 | .lock = sub_compilation.bin_file.toOwnedLock(), |
| 281 | }; | 306 | }; |
| ... | @@ -296,7 +321,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -296,7 +321,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 296 | const root_name = "c++abi"; | 321 | const root_name = "c++abi"; |
| 297 | const output_mode = .Lib; | 322 | const output_mode = .Lib; |
| 298 | const link_mode = .Static; | 323 | const link_mode = .Static; |
| 299 | const target = comp.getTarget(); | 324 | const target = comp.root_mod.resolved_target.result; |
| 300 | const basename = try std.zig.binNameAlloc(arena, .{ | 325 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 301 | .root_name = root_name, | 326 | .root_name = root_name, |
| 302 | .target = target, | 327 | .target = target, |
| ... | @@ -365,7 +390,6 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -365,7 +390,6 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 365 | } | 390 | } |
| 366 | try cflags.append("-nostdinc++"); | 391 | try cflags.append("-nostdinc++"); |
| 367 | try cflags.append("-fstrict-aliasing"); | 392 | try cflags.append("-fstrict-aliasing"); |
| 368 | try cflags.append("-funwind-tables"); | | |
| 369 | try cflags.append("-std=c++20"); | 393 | try cflags.append("-std=c++20"); |
| 370 | | 394 | |
| 371 | // These depend on only the zig lib directory file path, which is | 395 | // These depend on only the zig lib directory file path, which is |
| ... | @@ -389,46 +413,73 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -389,46 +413,73 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 389 | }); | 413 | }); |
| 390 | } | 414 | } |
| 391 | | 415 | |
| | 416 | const optimize_mode = comp.compilerRtOptMode(); |
| | 417 | const strip = comp.compilerRtStrip(); |
| | 418 | const unwind_tables = true; |
| | 419 | |
| | 420 | const config = try Compilation.Config.resolve(.{ |
| | 421 | .output_mode = output_mode, |
| | 422 | .link_mode = link_mode, |
| | 423 | .resolved_target = comp.root_mod.resolved_target, |
| | 424 | .is_test = false, |
| | 425 | .have_zcu = false, |
| | 426 | .emit_bin = true, |
| | 427 | .root_optimize_mode = optimize_mode, |
| | 428 | .root_strip = strip, |
| | 429 | .link_libc = true, |
| | 430 | .any_unwind_tables = unwind_tables, |
| | 431 | .lto = comp.config.lto, |
| | 432 | }); |
| | 433 | |
| | 434 | const root_mod = try Module.create(arena, .{ |
| | 435 | .global_cache_directory = comp.global_cache_directory, |
| | 436 | .paths = .{ |
| | 437 | .root = .{ .root_dir = comp.zig_lib_directory }, |
| | 438 | .root_src_path = "", |
| | 439 | }, |
| | 440 | .fully_qualified_name = "root", |
| | 441 | .inherited = .{ |
| | 442 | .strip = strip, |
| | 443 | .stack_check = false, |
| | 444 | .stack_protector = 0, |
| | 445 | .sanitize_c = false, |
| | 446 | .sanitize_thread = comp.config.any_sanitize_thread, |
| | 447 | .red_zone = comp.root_mod.red_zone, |
| | 448 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, |
| | 449 | .valgrind = false, |
| | 450 | .optimize_mode = optimize_mode, |
| | 451 | .structured_cfg = comp.root_mod.structured_cfg, |
| | 452 | .unwind_tables = unwind_tables, |
| | 453 | .pic = comp.root_mod.pic, |
| | 454 | }, |
| | 455 | .global = config, |
| | 456 | .cc_argv = &.{}, |
| | 457 | .parent = null, |
| | 458 | .builtin_mod = null, |
| | 459 | }); |
| | 460 | |
| 392 | const sub_compilation = try Compilation.create(comp.gpa, .{ | 461 | const sub_compilation = try Compilation.create(comp.gpa, .{ |
| 393 | .local_cache_directory = comp.global_cache_directory, | 462 | .local_cache_directory = comp.global_cache_directory, |
| 394 | .global_cache_directory = comp.global_cache_directory, | 463 | .global_cache_directory = comp.global_cache_directory, |
| 395 | .zig_lib_directory = comp.zig_lib_directory, | 464 | .zig_lib_directory = comp.zig_lib_directory, |
| | 465 | .self_exe_path = comp.self_exe_path, |
| 396 | .cache_mode = .whole, | 466 | .cache_mode = .whole, |
| 397 | .target = target, | 467 | .config = config, |
| | 468 | .root_mod = root_mod, |
| 398 | .root_name = root_name, | 469 | .root_name = root_name, |
| 399 | .main_mod = null, | | |
| 400 | .output_mode = output_mode, | | |
| 401 | .thread_pool = comp.thread_pool, | 470 | .thread_pool = comp.thread_pool, |
| 402 | .libc_installation = comp.bin_file.options.libc_installation, | 471 | .libc_installation = comp.libc_installation, |
| 403 | .emit_bin = emit_bin, | 472 | .emit_bin = emit_bin, |
| 404 | .optimize_mode = comp.compilerRtOptMode(), | | |
| 405 | .link_mode = link_mode, | | |
| 406 | .want_sanitize_c = false, | | |
| 407 | .want_stack_check = false, | | |
| 408 | .want_stack_protector = 0, | | |
| 409 | .want_red_zone = comp.bin_file.options.red_zone, | | |
| 410 | .omit_frame_pointer = comp.bin_file.options.omit_frame_pointer, | | |
| 411 | .want_valgrind = false, | | |
| 412 | .want_tsan = comp.bin_file.options.tsan, | | |
| 413 | .want_pic = comp.bin_file.options.pic, | | |
| 414 | .want_pie = null, | | |
| 415 | .want_lto = comp.bin_file.options.lto, | | |
| 416 | .function_sections = comp.bin_file.options.function_sections, | | |
| 417 | .emit_h = null, | 473 | .emit_h = null, |
| 418 | .strip = comp.compilerRtStrip(), | | |
| 419 | .is_native_os = comp.bin_file.options.is_native_os, | | |
| 420 | .is_native_abi = comp.bin_file.options.is_native_abi, | | |
| 421 | .self_exe_path = comp.self_exe_path, | | |
| 422 | .c_source_files = c_source_files.items, | 474 | .c_source_files = c_source_files.items, |
| 423 | .verbose_cc = comp.verbose_cc, | 475 | .verbose_cc = comp.verbose_cc, |
| 424 | .verbose_link = comp.bin_file.options.verbose_link, | 476 | .verbose_link = comp.verbose_link, |
| 425 | .verbose_air = comp.verbose_air, | 477 | .verbose_air = comp.verbose_air, |
| 426 | .verbose_llvm_ir = comp.verbose_llvm_ir, | 478 | .verbose_llvm_ir = comp.verbose_llvm_ir, |
| 427 | .verbose_llvm_bc = comp.verbose_llvm_bc, | 479 | .verbose_llvm_bc = comp.verbose_llvm_bc, |
| 428 | .verbose_cimport = comp.verbose_cimport, | 480 | .verbose_cimport = comp.verbose_cimport, |
| 429 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, | 481 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 430 | .clang_passthrough_mode = comp.clang_passthrough_mode, | 482 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 431 | .link_libc = true, | | |
| 432 | .skip_linker_dependencies = true, | 483 | .skip_linker_dependencies = true, |
| 433 | }); | 484 | }); |
| 434 | defer sub_compilation.destroy(); | 485 | defer sub_compilation.destroy(); |
| ... | @@ -437,8 +488,8 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -437,8 +488,8 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 437 | | 488 | |
| 438 | assert(comp.libcxxabi_static_lib == null); | 489 | assert(comp.libcxxabi_static_lib == null); |
| 439 | comp.libcxxabi_static_lib = Compilation.CRTFile{ | 490 | comp.libcxxabi_static_lib = Compilation.CRTFile{ |
| 440 | .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{ | 491 | .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{ |
| 441 | sub_compilation.bin_file.options.emit.?.sub_path, | 492 | sub_compilation.bin_file.?.emit.sub_path, |
| 442 | }), | 493 | }), |
| 443 | .lock = sub_compilation.bin_file.toOwnedLock(), | 494 | .lock = sub_compilation.bin_file.toOwnedLock(), |
| 444 | }; | 495 | }; |