| author | |
| committer | |
| log | e5e6eb983159df0a089e7d1c8efcea9006e253a9 |
| tree | 80611a8b7faca0d150bcb66c4d8403134a339a49 |
| parent | 39f43fea8d0f6aa1c69cb7c3209f57f5ce00b273 |
| parent | b75eeae5951f2dc4ff19f795ebd856c134722375 |
| signature |
make self-hosted the default compiler47 files changed, 484 insertions(+), 1507 deletions(-)
CMakeLists.txt+1-1| ... | ... | @@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE) |
| 12 | 12 | endif() |
| 13 | 13 | |
| 14 | 14 | if(NOT CMAKE_INSTALL_PREFIX) |
| 15 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage1" CACHE STRING | |
| 15 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage2" CACHE STRING | |
| 16 | 16 | "Directory to install zig to" FORCE) |
| 17 | 17 | endif() |
| 18 | 18 |
build.zig+29-42| ... | ... | @@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024; |
| 15 | 15 | |
| 16 | 16 | pub fn build(b: *Builder) !void { |
| 17 | 17 | b.setPreferredReleaseMode(.ReleaseFast); |
| 18 | const test_step = b.step("test", "Run all the tests"); | |
| 18 | 19 | const mode = b.standardReleaseOptions(); |
| 19 | 20 | const target = b.standardTargetOptions(.{}); |
| 20 | 21 | const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode"); |
| ... | ... | @@ -39,8 +40,6 @@ pub fn build(b: *Builder) !void { |
| 39 | 40 | const docs_step = b.step("docs", "Build documentation"); |
| 40 | 41 | docs_step.dependOn(&docgen_cmd.step); |
| 41 | 42 | |
| 42 | const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain"); | |
| 43 | ||
| 44 | 43 | var test_cases = b.addTest("src/test.zig"); |
| 45 | 44 | test_cases.stack_size = stack_size; |
| 46 | 45 | test_cases.setBuildMode(mode); |
| ... | ... | @@ -64,10 +63,9 @@ pub fn build(b: *Builder) !void { |
| 64 | 63 | |
| 65 | 64 | const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; |
| 66 | 65 | |
| 67 | const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false; | |
| 68 | const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false; | |
| 66 | const have_stage1 = b.option(bool, "enable-stage1", "Include the stage1 compiler behind a feature flag") orelse false; | |
| 69 | 67 | const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; |
| 70 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm); | |
| 68 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (have_stage1 or static_llvm); | |
| 71 | 69 | const llvm_has_m68k = b.option( |
| 72 | 70 | bool, |
| 73 | 71 | "llvm-has-m68k", |
| ... | ... | @@ -137,7 +135,7 @@ pub fn build(b: *Builder) !void { |
| 137 | 135 | }; |
| 138 | 136 | |
| 139 | 137 | const main_file: ?[]const u8 = mf: { |
| 140 | if (!is_stage1) break :mf "src/main.zig"; | |
| 138 | if (!have_stage1) break :mf "src/main.zig"; | |
| 141 | 139 | if (use_zig0) break :mf null; |
| 142 | 140 | break :mf "src/stage1.zig"; |
| 143 | 141 | }; |
| ... | ... | @@ -150,7 +148,7 @@ pub fn build(b: *Builder) !void { |
| 150 | 148 | exe.setBuildMode(mode); |
| 151 | 149 | exe.setTarget(target); |
| 152 | 150 | if (!skip_stage2_tests) { |
| 153 | toolchain_step.dependOn(&exe.step); | |
| 151 | test_step.dependOn(&exe.step); | |
| 154 | 152 | } |
| 155 | 153 | |
| 156 | 154 | b.default_step.dependOn(&exe.step); |
| ... | ... | @@ -248,7 +246,7 @@ pub fn build(b: *Builder) !void { |
| 248 | 246 | } |
| 249 | 247 | }; |
| 250 | 248 | |
| 251 | if (is_stage1) { | |
| 249 | if (have_stage1) { | |
| 252 | 250 | const softfloat = b.addStaticLibrary("softfloat", null); |
| 253 | 251 | softfloat.setBuildMode(.ReleaseFast); |
| 254 | 252 | softfloat.setTarget(target); |
| ... | ... | @@ -360,8 +358,7 @@ pub fn build(b: *Builder) !void { |
| 360 | 358 | exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); |
| 361 | 359 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); |
| 362 | 360 | exe_options.addOption(bool, "value_tracing", value_tracing); |
| 363 | exe_options.addOption(bool, "is_stage1", is_stage1); | |
| 364 | exe_options.addOption(bool, "omit_stage2", omit_stage2); | |
| 361 | exe_options.addOption(bool, "have_stage1", have_stage1); | |
| 365 | 362 | if (tracy) |tracy_path| { |
| 366 | 363 | const client_cpp = fs.path.join( |
| 367 | 364 | b.allocator, |
| ... | ... | @@ -396,8 +393,7 @@ pub fn build(b: *Builder) !void { |
| 396 | 393 | test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); |
| 397 | 394 | test_cases_options.addOption(bool, "skip_non_native", skip_non_native); |
| 398 | 395 | test_cases_options.addOption(bool, "skip_stage1", skip_stage1); |
| 399 | test_cases_options.addOption(bool, "is_stage1", is_stage1); | |
| 400 | test_cases_options.addOption(bool, "omit_stage2", omit_stage2); | |
| 396 | test_cases_options.addOption(bool, "have_stage1", have_stage1); | |
| 401 | 397 | test_cases_options.addOption(bool, "have_llvm", enable_llvm); |
| 402 | 398 | test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); |
| 403 | 399 | test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky); |
| ... | ... | @@ -418,7 +414,7 @@ pub fn build(b: *Builder) !void { |
| 418 | 414 | const test_cases_step = b.step("test-cases", "Run the main compiler test cases"); |
| 419 | 415 | test_cases_step.dependOn(&test_cases.step); |
| 420 | 416 | if (!skip_stage2_tests) { |
| 421 | toolchain_step.dependOn(test_cases_step); | |
| 417 | test_step.dependOn(test_cases_step); | |
| 422 | 418 | } |
| 423 | 419 | |
| 424 | 420 | var chosen_modes: [4]builtin.Mode = undefined; |
| ... | ... | @@ -442,11 +438,11 @@ pub fn build(b: *Builder) !void { |
| 442 | 438 | const modes = chosen_modes[0..chosen_mode_index]; |
| 443 | 439 | |
| 444 | 440 | // run stage1 `zig fmt` on this build.zig file just to make sure it works |
| 445 | toolchain_step.dependOn(&fmt_build_zig.step); | |
| 441 | test_step.dependOn(&fmt_build_zig.step); | |
| 446 | 442 | const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works"); |
| 447 | 443 | fmt_step.dependOn(&fmt_build_zig.step); |
| 448 | 444 | |
| 449 | toolchain_step.dependOn(tests.addPkgTests( | |
| 445 | test_step.dependOn(tests.addPkgTests( | |
| 450 | 446 | b, |
| 451 | 447 | test_filter, |
| 452 | 448 | "test/behavior.zig", |
| ... | ... | @@ -457,11 +453,10 @@ pub fn build(b: *Builder) !void { |
| 457 | 453 | skip_non_native, |
| 458 | 454 | skip_libc, |
| 459 | 455 | skip_stage1, |
| 460 | omit_stage2, | |
| 461 | is_stage1, | |
| 456 | skip_stage2_tests, | |
| 462 | 457 | )); |
| 463 | 458 | |
| 464 | toolchain_step.dependOn(tests.addPkgTests( | |
| 459 | test_step.dependOn(tests.addPkgTests( | |
| 465 | 460 | b, |
| 466 | 461 | test_filter, |
| 467 | 462 | "lib/compiler_rt.zig", |
| ... | ... | @@ -472,11 +467,10 @@ pub fn build(b: *Builder) !void { |
| 472 | 467 | skip_non_native, |
| 473 | 468 | true, // skip_libc |
| 474 | 469 | skip_stage1, |
| 475 | omit_stage2 or true, // TODO get these all passing | |
| 476 | is_stage1, | |
| 470 | skip_stage2_tests or true, // TODO get these all passing | |
| 477 | 471 | )); |
| 478 | 472 | |
| 479 | toolchain_step.dependOn(tests.addPkgTests( | |
| 473 | test_step.dependOn(tests.addPkgTests( | |
| 480 | 474 | b, |
| 481 | 475 | test_filter, |
| 482 | 476 | "lib/c.zig", |
| ... | ... | @@ -487,37 +481,36 @@ pub fn build(b: *Builder) !void { |
| 487 | 481 | skip_non_native, |
| 488 | 482 | true, // skip_libc |
| 489 | 483 | skip_stage1, |
| 490 | omit_stage2 or true, // TODO get these all passing | |
| 491 | is_stage1, | |
| 484 | skip_stage2_tests or true, // TODO get these all passing | |
| 492 | 485 | )); |
| 493 | 486 | |
| 494 | toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); | |
| 495 | toolchain_step.dependOn(tests.addStandaloneTests( | |
| 487 | test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); | |
| 488 | test_step.dependOn(tests.addStandaloneTests( | |
| 496 | 489 | b, |
| 497 | 490 | test_filter, |
| 498 | 491 | modes, |
| 499 | 492 | skip_non_native, |
| 500 | 493 | enable_macos_sdk, |
| 501 | 494 | target, |
| 502 | omit_stage2, | |
| 495 | skip_stage2_tests, | |
| 503 | 496 | b.enable_darling, |
| 504 | 497 | b.enable_qemu, |
| 505 | 498 | b.enable_rosetta, |
| 506 | 499 | b.enable_wasmtime, |
| 507 | 500 | b.enable_wine, |
| 508 | 501 | )); |
| 509 | toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2)); | |
| 510 | toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); | |
| 511 | toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes)); | |
| 512 | toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes)); | |
| 513 | toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter)); | |
| 502 | test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests)); | |
| 503 | test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); | |
| 504 | test_step.dependOn(tests.addCliTests(b, test_filter, modes)); | |
| 505 | test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes)); | |
| 506 | test_step.dependOn(tests.addTranslateCTests(b, test_filter)); | |
| 514 | 507 | if (!skip_run_translated_c) { |
| 515 | toolchain_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target)); | |
| 508 | test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target)); | |
| 516 | 509 | } |
| 517 | 510 | // tests for this feature are disabled until we have the self-hosted compiler available |
| 518 | // toolchain_step.dependOn(tests.addGenHTests(b, test_filter)); | |
| 511 | // test_step.dependOn(tests.addGenHTests(b, test_filter)); | |
| 519 | 512 | |
| 520 | const std_step = tests.addPkgTests( | |
| 513 | test_step.dependOn(tests.addPkgTests( | |
| 521 | 514 | b, |
| 522 | 515 | test_filter, |
| 523 | 516 | "lib/std/std.zig", |
| ... | ... | @@ -528,14 +521,8 @@ pub fn build(b: *Builder) !void { |
| 528 | 521 | skip_non_native, |
| 529 | 522 | skip_libc, |
| 530 | 523 | skip_stage1, |
| 531 | omit_stage2 or true, // TODO get these all passing | |
| 532 | is_stage1, | |
| 533 | ); | |
| 534 | ||
| 535 | const test_step = b.step("test", "Run all the tests"); | |
| 536 | test_step.dependOn(toolchain_step); | |
| 537 | test_step.dependOn(std_step); | |
| 538 | test_step.dependOn(docs_step); | |
| 524 | true, // TODO get these all passing | |
| 525 | )); | |
| 539 | 526 | } |
| 540 | 527 | |
| 541 | 528 | const exe_cflags = [_][]const u8{ |
ci/azure/build.zig deleted-976| ... | ... | @@ -1,976 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = std.builtin; | |
| 3 | const Builder = std.build.Builder; | |
| 4 | const BufMap = std.BufMap; | |
| 5 | const mem = std.mem; | |
| 6 | const ArrayList = std.ArrayList; | |
| 7 | const io = std.io; | |
| 8 | const fs = std.fs; | |
| 9 | const InstallDirectoryOptions = std.build.InstallDirectoryOptions; | |
| 10 | const assert = std.debug.assert; | |
| 11 | ||
| 12 | const zig_version = std.builtin.Version{ .major = 0, .minor = 10, .patch = 0 }; | |
| 13 | ||
| 14 | pub fn build(b: *Builder) !void { | |
| 15 | b.setPreferredReleaseMode(.ReleaseFast); | |
| 16 | const mode = b.standardReleaseOptions(); | |
| 17 | const target = b.standardTargetOptions(.{}); | |
| 18 | const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode"); | |
| 19 | const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false; | |
| 20 | ||
| 21 | const docgen_exe = b.addExecutable("docgen", "doc/docgen.zig"); | |
| 22 | docgen_exe.single_threaded = single_threaded; | |
| 23 | ||
| 24 | const rel_zig_exe = try fs.path.relative(b.allocator, b.build_root, b.zig_exe); | |
| 25 | const langref_out_path = fs.path.join( | |
| 26 | b.allocator, | |
| 27 | &[_][]const u8{ b.cache_root, "langref.html" }, | |
| 28 | ) catch unreachable; | |
| 29 | const docgen_cmd = docgen_exe.run(); | |
| 30 | docgen_cmd.addArgs(&[_][]const u8{ | |
| 31 | rel_zig_exe, | |
| 32 | "doc" ++ fs.path.sep_str ++ "langref.html.in", | |
| 33 | langref_out_path, | |
| 34 | }); | |
| 35 | docgen_cmd.step.dependOn(&docgen_exe.step); | |
| 36 | ||
| 37 | const docs_step = b.step("docs", "Build documentation"); | |
| 38 | docs_step.dependOn(&docgen_cmd.step); | |
| 39 | ||
| 40 | const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false; | |
| 41 | const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false; | |
| 42 | const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; | |
| 43 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm); | |
| 44 | const llvm_has_m68k = b.option( | |
| 45 | bool, | |
| 46 | "llvm-has-m68k", | |
| 47 | "Whether LLVM has the experimental target m68k enabled", | |
| 48 | ) orelse false; | |
| 49 | const llvm_has_csky = b.option( | |
| 50 | bool, | |
| 51 | "llvm-has-csky", | |
| 52 | "Whether LLVM has the experimental target csky enabled", | |
| 53 | ) orelse false; | |
| 54 | const llvm_has_arc = b.option( | |
| 55 | bool, | |
| 56 | "llvm-has-arc", | |
| 57 | "Whether LLVM has the experimental target arc enabled", | |
| 58 | ) orelse false; | |
| 59 | const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); | |
| 60 | ||
| 61 | b.installDirectory(InstallDirectoryOptions{ | |
| 62 | .source_dir = "lib", | |
| 63 | .install_dir = .lib, | |
| 64 | .install_subdir = "zig", | |
| 65 | .exclude_extensions = &[_][]const u8{ | |
| 66 | // exclude files from lib/std/compress/ | |
| 67 | ".gz", | |
| 68 | ".z.0", | |
| 69 | ".z.9", | |
| 70 | "rfc1951.txt", | |
| 71 | "rfc1952.txt", | |
| 72 | // exclude files from lib/std/compress/deflate/testdata | |
| 73 | ".expect", | |
| 74 | ".expect-noinput", | |
| 75 | ".golden", | |
| 76 | ".input", | |
| 77 | "compress-e.txt", | |
| 78 | "compress-gettysburg.txt", | |
| 79 | "compress-pi.txt", | |
| 80 | "rfc1951.txt", | |
| 81 | // exclude files from lib/std/tz/ | |
| 82 | ".tzif", | |
| 83 | // others | |
| 84 | "README.md", | |
| 85 | }, | |
| 86 | .blank_extensions = &[_][]const u8{ | |
| 87 | "test.zig", | |
| 88 | }, | |
| 89 | }); | |
| 90 | ||
| 91 | const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); | |
| 92 | const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse false; | |
| 93 | const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse false; | |
| 94 | const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false; | |
| 95 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; | |
| 96 | const strip = b.option(bool, "strip", "Omit debug information") orelse false; | |
| 97 | const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false; | |
| 98 | ||
| 99 | const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: { | |
| 100 | if (strip) break :blk @as(u32, 0); | |
| 101 | if (mode != .Debug) break :blk 0; | |
| 102 | break :blk 4; | |
| 103 | }; | |
| 104 | ||
| 105 | const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig"; | |
| 106 | ||
| 107 | const exe = b.addExecutable("zig", main_file); | |
| 108 | exe.strip = strip; | |
| 109 | exe.install(); | |
| 110 | exe.setBuildMode(mode); | |
| 111 | exe.setTarget(target); | |
| 112 | ||
| 113 | b.default_step.dependOn(&exe.step); | |
| 114 | exe.single_threaded = single_threaded; | |
| 115 | ||
| 116 | if (target.isWindows() and target.getAbi() == .gnu) { | |
| 117 | // LTO is currently broken on mingw, this can be removed when it's fixed. | |
| 118 | exe.want_lto = false; | |
| 119 | } | |
| 120 | ||
| 121 | const exe_options = b.addOptions(); | |
| 122 | exe.addOptions("build_options", exe_options); | |
| 123 | ||
| 124 | exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames); | |
| 125 | exe_options.addOption(bool, "skip_non_native", false); | |
| 126 | exe_options.addOption(bool, "have_llvm", enable_llvm); | |
| 127 | exe_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); | |
| 128 | exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky); | |
| 129 | exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc); | |
| 130 | exe_options.addOption(bool, "force_gpa", force_gpa); | |
| 131 | ||
| 132 | if (link_libc) { | |
| 133 | exe.linkLibC(); | |
| 134 | } | |
| 135 | ||
| 136 | const is_debug = mode == .Debug; | |
| 137 | const enable_logging = b.option(bool, "log", "Enable debug logging with --debug-log") orelse is_debug; | |
| 138 | const enable_link_snapshots = b.option(bool, "link-snapshot", "Whether to enable linker state snapshots") orelse false; | |
| 139 | ||
| 140 | const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git."); | |
| 141 | const version = if (opt_version_string) |version| version else v: { | |
| 142 | const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch }); | |
| 143 | ||
| 144 | var code: u8 = undefined; | |
| 145 | const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ | |
| 146 | "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags", | |
| 147 | }, &code, .Ignore) catch { | |
| 148 | break :v version_string; | |
| 149 | }; | |
| 150 | const git_describe = mem.trim(u8, git_describe_untrimmed, " \n\r"); | |
| 151 | ||
| 152 | switch (mem.count(u8, git_describe, "-")) { | |
| 153 | 0 => { | |
| 154 | // Tagged release version (e.g. 0.9.0). | |
| 155 | if (!mem.eql(u8, git_describe, version_string)) { | |
| 156 | std.debug.print("Zig version '{s}' does not match Git tag '{s}'\n", .{ version_string, git_describe }); | |
| 157 | std.process.exit(1); | |
| 158 | } | |
| 159 | break :v version_string; | |
| 160 | }, | |
| 161 | 2 => { | |
| 162 | // Untagged development build (e.g. 0.9.0-dev.2025+ecf0050a9). | |
| 163 | var it = mem.split(u8, git_describe, "-"); | |
| 164 | const tagged_ancestor = it.next() orelse unreachable; | |
| 165 | const commit_height = it.next() orelse unreachable; | |
| 166 | const commit_id = it.next() orelse unreachable; | |
| 167 | ||
| 168 | const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor); | |
| 169 | if (zig_version.order(ancestor_ver) != .gt) { | |
| 170 | std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver }); | |
| 171 | std.process.exit(1); | |
| 172 | } | |
| 173 | ||
| 174 | // Check that the commit hash is prefixed with a 'g' (a Git convention). | |
| 175 | if (commit_id.len < 1 or commit_id[0] != 'g') { | |
| 176 | std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); | |
| 177 | break :v version_string; | |
| 178 | } | |
| 179 | ||
| 180 | // The version is reformatted in accordance with the https://semver.org specification. | |
| 181 | break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] }); | |
| 182 | }, | |
| 183 | else => { | |
| 184 | std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); | |
| 185 | break :v version_string; | |
| 186 | }, | |
| 187 | } | |
| 188 | }; | |
| 189 | exe_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); | |
| 190 | ||
| 191 | if (enable_llvm) { | |
| 192 | const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); | |
| 193 | ||
| 194 | if (is_stage1) { | |
| 195 | const softfloat = b.addStaticLibrary("softfloat", null); | |
| 196 | softfloat.setBuildMode(.ReleaseFast); | |
| 197 | softfloat.setTarget(target); | |
| 198 | softfloat.addIncludeDir("deps/SoftFloat-3e-prebuilt"); | |
| 199 | softfloat.addIncludeDir("deps/SoftFloat-3e/source/8086"); | |
| 200 | softfloat.addIncludeDir("deps/SoftFloat-3e/source/include"); | |
| 201 | softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); | |
| 202 | softfloat.single_threaded = single_threaded; | |
| 203 | ||
| 204 | const zig0 = b.addExecutable("zig0", null); | |
| 205 | zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags); | |
| 206 | zig0.addIncludeDir("zig-cache/tmp"); // for config.h | |
| 207 | zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major})); | |
| 208 | zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor})); | |
| 209 | zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch})); | |
| 210 | zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version})); | |
| 211 | ||
| 212 | for ([_]*std.build.LibExeObjStep{ zig0, exe }) |artifact| { | |
| 213 | artifact.addIncludeDir("src"); | |
| 214 | artifact.addIncludeDir("deps/SoftFloat-3e/source/include"); | |
| 215 | artifact.addIncludeDir("deps/SoftFloat-3e-prebuilt"); | |
| 216 | ||
| 217 | artifact.defineCMacro("ZIG_LINK_MODE", "Static"); | |
| 218 | ||
| 219 | artifact.addCSourceFiles(&stage1_sources, &exe_cflags); | |
| 220 | artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); | |
| 221 | ||
| 222 | artifact.linkLibrary(softfloat); | |
| 223 | artifact.linkLibCpp(); | |
| 224 | } | |
| 225 | ||
| 226 | try addStaticLlvmOptionsToExe(zig0); | |
| 227 | ||
| 228 | const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch()); | |
| 229 | const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) }); | |
| 230 | const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" }); | |
| 231 | ||
| 232 | const zig1_obj = zig0.run(); | |
| 233 | zig1_obj.addArgs(&.{ | |
| 234 | "src/stage1.zig", | |
| 235 | "-target", | |
| 236 | try target.zigTriple(b.allocator), | |
| 237 | "-mcpu=baseline", | |
| 238 | "--name", | |
| 239 | "zig1", | |
| 240 | "--zig-lib-dir", | |
| 241 | b.pathFromRoot("lib"), | |
| 242 | b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}), | |
| 243 | "-fcompiler-rt", | |
| 244 | "-lc", | |
| 245 | }); | |
| 246 | { | |
| 247 | zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" }); | |
| 248 | zig1_obj.addFileSourceArg(exe_options.getSource()); | |
| 249 | zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" }); | |
| 250 | } | |
| 251 | switch (mode) { | |
| 252 | .Debug => {}, | |
| 253 | .ReleaseFast => { | |
| 254 | zig1_obj.addArg("-OReleaseFast"); | |
| 255 | zig1_obj.addArg("--strip"); | |
| 256 | }, | |
| 257 | .ReleaseSafe => { | |
| 258 | zig1_obj.addArg("-OReleaseSafe"); | |
| 259 | zig1_obj.addArg("--strip"); | |
| 260 | }, | |
| 261 | .ReleaseSmall => { | |
| 262 | zig1_obj.addArg("-OReleaseSmall"); | |
| 263 | zig1_obj.addArg("--strip"); | |
| 264 | }, | |
| 265 | } | |
| 266 | if (single_threaded orelse false) { | |
| 267 | zig1_obj.addArg("-fsingle-threaded"); | |
| 268 | } | |
| 269 | ||
| 270 | exe.step.dependOn(&zig1_obj.step); | |
| 271 | exe.addObjectFile(zig1_obj_path); | |
| 272 | ||
| 273 | // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case | |
| 274 | // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that | |
| 275 | // is pointless. | |
| 276 | exe.addPackagePath("compiler_rt", "src/empty.zig"); | |
| 277 | } | |
| 278 | if (cmake_cfg) |cfg| { | |
| 279 | // Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD. | |
| 280 | // That means we also have to rely on stage1 compiled c++ files. We parse config.h to find | |
| 281 | // the information passed on to us from cmake. | |
| 282 | if (cfg.cmake_prefix_path.len > 0) { | |
| 283 | b.addSearchPrefix(cfg.cmake_prefix_path); | |
| 284 | } | |
| 285 | ||
| 286 | try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx); | |
| 287 | } else { | |
| 288 | // Here we are -Denable-llvm but no cmake integration. | |
| 289 | try addStaticLlvmOptionsToExe(exe); | |
| 290 | } | |
| 291 | } | |
| 292 | ||
| 293 | const semver = try std.SemanticVersion.parse(version); | |
| 294 | exe_options.addOption(std.SemanticVersion, "semver", semver); | |
| 295 | ||
| 296 | exe_options.addOption(bool, "enable_logging", enable_logging); | |
| 297 | exe_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); | |
| 298 | exe_options.addOption(bool, "enable_tracy", tracy != null); | |
| 299 | exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); | |
| 300 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); | |
| 301 | exe_options.addOption(bool, "value_tracing", value_tracing); | |
| 302 | exe_options.addOption(bool, "is_stage1", is_stage1); | |
| 303 | exe_options.addOption(bool, "omit_stage2", omit_stage2); | |
| 304 | if (tracy) |tracy_path| { | |
| 305 | const client_cpp = fs.path.join( | |
| 306 | b.allocator, | |
| 307 | &[_][]const u8{ tracy_path, "TracyClient.cpp" }, | |
| 308 | ) catch unreachable; | |
| 309 | ||
| 310 | // On mingw, we need to opt into windows 7+ to get some features required by tracy. | |
| 311 | const tracy_c_flags: []const []const u8 = if (target.isWindows() and target.getAbi() == .gnu) | |
| 312 | &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" } | |
| 313 | else | |
| 314 | &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; | |
| 315 | ||
| 316 | exe.addIncludeDir(tracy_path); | |
| 317 | exe.addCSourceFile(client_cpp, tracy_c_flags); | |
| 318 | if (!enable_llvm) { | |
| 319 | exe.linkSystemLibraryName("c++"); | |
| 320 | } | |
| 321 | exe.linkLibC(); | |
| 322 | ||
| 323 | if (target.isWindows()) { | |
| 324 | exe.linkSystemLibrary("dbghelp"); | |
| 325 | exe.linkSystemLibrary("ws2_32"); | |
| 326 | } | |
| 327 | } | |
| 328 | } | |
| 329 | ||
| 330 | const exe_cflags = [_][]const u8{ | |
| 331 | "-std=c++14", | |
| 332 | "-D__STDC_CONSTANT_MACROS", | |
| 333 | "-D__STDC_FORMAT_MACROS", | |
| 334 | "-D__STDC_LIMIT_MACROS", | |
| 335 | "-D_GNU_SOURCE", | |
| 336 | "-fvisibility-inlines-hidden", | |
| 337 | "-fno-exceptions", | |
| 338 | "-fno-rtti", | |
| 339 | "-Werror=type-limits", | |
| 340 | "-Wno-missing-braces", | |
| 341 | "-Wno-comment", | |
| 342 | }; | |
| 343 | ||
| 344 | fn addCmakeCfgOptionsToExe( | |
| 345 | b: *Builder, | |
| 346 | cfg: CMakeConfig, | |
| 347 | exe: *std.build.LibExeObjStep, | |
| 348 | use_zig_libcxx: bool, | |
| 349 | ) !void { | |
| 350 | exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ | |
| 351 | cfg.cmake_binary_dir, | |
| 352 | "zigcpp", | |
| 353 | b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }), | |
| 354 | }) catch unreachable); | |
| 355 | assert(cfg.lld_include_dir.len != 0); | |
| 356 | exe.addIncludeDir(cfg.lld_include_dir); | |
| 357 | addCMakeLibraryList(exe, cfg.clang_libraries); | |
| 358 | addCMakeLibraryList(exe, cfg.lld_libraries); | |
| 359 | addCMakeLibraryList(exe, cfg.llvm_libraries); | |
| 360 | ||
| 361 | if (use_zig_libcxx) { | |
| 362 | exe.linkLibCpp(); | |
| 363 | } else { | |
| 364 | const need_cpp_includes = true; | |
| 365 | ||
| 366 | // System -lc++ must be used because in this code path we are attempting to link | |
| 367 | // against system-provided LLVM, Clang, LLD. | |
| 368 | if (exe.target.getOsTag() == .linux) { | |
| 369 | // First we try to static link against gcc libstdc++. If that doesn't work, | |
| 370 | // we fall back to -lc++ and cross our fingers. | |
| 371 | addCxxKnownPath(b, cfg, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) { | |
| 372 | error.RequiredLibraryNotFound => { | |
| 373 | exe.linkSystemLibrary("c++"); | |
| 374 | }, | |
| 375 | else => |e| return e, | |
| 376 | }; | |
| 377 | exe.linkSystemLibrary("unwind"); | |
| 378 | } else if (exe.target.isFreeBSD()) { | |
| 379 | try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); | |
| 380 | exe.linkSystemLibrary("pthread"); | |
| 381 | } else if (exe.target.getOsTag() == .openbsd) { | |
| 382 | try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); | |
| 383 | try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes); | |
| 384 | } else if (exe.target.isDarwin()) { | |
| 385 | exe.linkSystemLibrary("c++"); | |
| 386 | } | |
| 387 | } | |
| 388 | ||
| 389 | if (cfg.dia_guids_lib.len != 0) { | |
| 390 | exe.addObjectFile(cfg.dia_guids_lib); | |
| 391 | } | |
| 392 | } | |
| 393 | ||
| 394 | fn addStaticLlvmOptionsToExe( | |
| 395 | exe: *std.build.LibExeObjStep, | |
| 396 | ) !void { | |
| 397 | // Adds the Zig C++ sources which both stage1 and stage2 need. | |
| 398 | // | |
| 399 | // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling | |
| 400 | // in a dependency on llvm::cfg::Update<llvm::BasicBlock*>::dump() which is | |
| 401 | // unavailable when LLVM is compiled in Release mode. | |
| 402 | const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"}; | |
| 403 | exe.addCSourceFiles(&zig_cpp_sources, &zig_cpp_cflags); | |
| 404 | ||
| 405 | for (clang_libs) |lib_name| { | |
| 406 | exe.linkSystemLibrary(lib_name); | |
| 407 | } | |
| 408 | ||
| 409 | for (lld_libs) |lib_name| { | |
| 410 | exe.linkSystemLibrary(lib_name); | |
| 411 | } | |
| 412 | ||
| 413 | for (llvm_libs) |lib_name| { | |
| 414 | exe.linkSystemLibrary(lib_name); | |
| 415 | } | |
| 416 | ||
| 417 | exe.linkSystemLibrary("z"); | |
| 418 | ||
| 419 | // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries. | |
| 420 | exe.linkSystemLibrary("c++"); | |
| 421 | ||
| 422 | if (exe.target.getOs().tag == .windows) { | |
| 423 | exe.linkSystemLibrary("version"); | |
| 424 | exe.linkSystemLibrary("uuid"); | |
| 425 | exe.linkSystemLibrary("ole32"); | |
| 426 | } | |
| 427 | } | |
| 428 | ||
| 429 | fn addCxxKnownPath( | |
| 430 | b: *Builder, | |
| 431 | ctx: CMakeConfig, | |
| 432 | exe: *std.build.LibExeObjStep, | |
| 433 | objname: []const u8, | |
| 434 | errtxt: ?[]const u8, | |
| 435 | need_cpp_includes: bool, | |
| 436 | ) !void { | |
| 437 | const path_padded = try b.exec(&[_][]const u8{ | |
| 438 | ctx.cxx_compiler, | |
| 439 | b.fmt("-print-file-name={s}", .{objname}), | |
| 440 | }); | |
| 441 | const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?; | |
| 442 | if (mem.eql(u8, path_unpadded, objname)) { | |
| 443 | if (errtxt) |msg| { | |
| 444 | std.debug.print("{s}", .{msg}); | |
| 445 | } else { | |
| 446 | std.debug.print("Unable to determine path to {s}\n", .{objname}); | |
| 447 | } | |
| 448 | return error.RequiredLibraryNotFound; | |
| 449 | } | |
| 450 | exe.addObjectFile(path_unpadded); | |
| 451 | ||
| 452 | // TODO a way to integrate with system c++ include files here | |
| 453 | // cc -E -Wp,-v -xc++ /dev/null | |
| 454 | if (need_cpp_includes) { | |
| 455 | // I used these temporarily for testing something but we obviously need a | |
| 456 | // more general purpose solution here. | |
| 457 | //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0"); | |
| 458 | //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/x86_64-unknown-linux-gnu"); | |
| 459 | //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/backward"); | |
| 460 | } | |
| 461 | } | |
| 462 | ||
| 463 | fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void { | |
| 464 | var it = mem.tokenize(u8, list, ";"); | |
| 465 | while (it.next()) |lib| { | |
| 466 | if (mem.startsWith(u8, lib, "-l")) { | |
| 467 | exe.linkSystemLibrary(lib["-l".len..]); | |
| 468 | } else { | |
| 469 | exe.addObjectFile(lib); | |
| 470 | } | |
| 471 | } | |
| 472 | } | |
| 473 | ||
| 474 | const CMakeConfig = struct { | |
| 475 | cmake_binary_dir: []const u8, | |
| 476 | cmake_prefix_path: []const u8, | |
| 477 | cxx_compiler: []const u8, | |
| 478 | lld_include_dir: []const u8, | |
| 479 | lld_libraries: []const u8, | |
| 480 | clang_libraries: []const u8, | |
| 481 | llvm_libraries: []const u8, | |
| 482 | dia_guids_lib: []const u8, | |
| 483 | }; | |
| 484 | ||
| 485 | const max_config_h_bytes = 1 * 1024 * 1024; | |
| 486 | ||
| 487 | fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeConfig { | |
| 488 | const config_h_text: []const u8 = if (config_h_path_option) |config_h_path| blk: { | |
| 489 | break :blk fs.cwd().readFileAlloc(b.allocator, config_h_path, max_config_h_bytes) catch unreachable; | |
| 490 | } else blk: { | |
| 491 | // TODO this should stop looking for config.h once it detects we hit the | |
| 492 | // zig source root directory. | |
| 493 | var check_dir = fs.path.dirname(b.zig_exe).?; | |
| 494 | while (true) { | |
| 495 | var dir = fs.cwd().openDir(check_dir, .{}) catch unreachable; | |
| 496 | defer dir.close(); | |
| 497 | ||
| 498 | break :blk dir.readFileAlloc(b.allocator, "config.h", max_config_h_bytes) catch |err| switch (err) { | |
| 499 | error.FileNotFound => { | |
| 500 | const new_check_dir = fs.path.dirname(check_dir); | |
| 501 | if (new_check_dir == null or mem.eql(u8, new_check_dir.?, check_dir)) { | |
| 502 | return null; | |
| 503 | } | |
| 504 | check_dir = new_check_dir.?; | |
| 505 | continue; | |
| 506 | }, | |
| 507 | else => unreachable, | |
| 508 | }; | |
| 509 | } else unreachable; // TODO should not need `else unreachable`. | |
| 510 | }; | |
| 511 | ||
| 512 | var ctx: CMakeConfig = .{ | |
| 513 | .cmake_binary_dir = undefined, | |
| 514 | .cmake_prefix_path = undefined, | |
| 515 | .cxx_compiler = undefined, | |
| 516 | .lld_include_dir = undefined, | |
| 517 | .lld_libraries = undefined, | |
| 518 | .clang_libraries = undefined, | |
| 519 | .llvm_libraries = undefined, | |
| 520 | .dia_guids_lib = undefined, | |
| 521 | }; | |
| 522 | ||
| 523 | const mappings = [_]struct { prefix: []const u8, field: []const u8 }{ | |
| 524 | .{ | |
| 525 | .prefix = "#define ZIG_CMAKE_BINARY_DIR ", | |
| 526 | .field = "cmake_binary_dir", | |
| 527 | }, | |
| 528 | .{ | |
| 529 | .prefix = "#define ZIG_CMAKE_PREFIX_PATH ", | |
| 530 | .field = "cmake_prefix_path", | |
| 531 | }, | |
| 532 | .{ | |
| 533 | .prefix = "#define ZIG_CXX_COMPILER ", | |
| 534 | .field = "cxx_compiler", | |
| 535 | }, | |
| 536 | .{ | |
| 537 | .prefix = "#define ZIG_LLD_INCLUDE_PATH ", | |
| 538 | .field = "lld_include_dir", | |
| 539 | }, | |
| 540 | .{ | |
| 541 | .prefix = "#define ZIG_LLD_LIBRARIES ", | |
| 542 | .field = "lld_libraries", | |
| 543 | }, | |
| 544 | .{ | |
| 545 | .prefix = "#define ZIG_CLANG_LIBRARIES ", | |
| 546 | .field = "clang_libraries", | |
| 547 | }, | |
| 548 | .{ | |
| 549 | .prefix = "#define ZIG_LLVM_LIBRARIES ", | |
| 550 | .field = "llvm_libraries", | |
| 551 | }, | |
| 552 | .{ | |
| 553 | .prefix = "#define ZIG_DIA_GUIDS_LIB ", | |
| 554 | .field = "dia_guids_lib", | |
| 555 | }, | |
| 556 | }; | |
| 557 | ||
| 558 | var lines_it = mem.tokenize(u8, config_h_text, "\r\n"); | |
| 559 | while (lines_it.next()) |line| { | |
| 560 | inline for (mappings) |mapping| { | |
| 561 | if (mem.startsWith(u8, line, mapping.prefix)) { | |
| 562 | var it = mem.split(u8, line, "\""); | |
| 563 | _ = it.next().?; // skip the stuff before the quote | |
| 564 | const quoted = it.next().?; // the stuff inside the quote | |
| 565 | @field(ctx, mapping.field) = toNativePathSep(b, quoted); | |
| 566 | } | |
| 567 | } | |
| 568 | } | |
| 569 | return ctx; | |
| 570 | } | |
| 571 | ||
| 572 | fn toNativePathSep(b: *Builder, s: []const u8) []u8 { | |
| 573 | const duplicated = b.allocator.dupe(u8, s) catch unreachable; | |
| 574 | for (duplicated) |*byte| switch (byte.*) { | |
| 575 | '/' => byte.* = fs.path.sep, | |
| 576 | else => {}, | |
| 577 | }; | |
| 578 | return duplicated; | |
| 579 | } | |
| 580 | ||
| 581 | const softfloat_sources = [_][]const u8{ | |
| 582 | "deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c", | |
| 583 | "deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c", | |
| 584 | "deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c", | |
| 585 | "deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.c", | |
| 586 | "deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c", | |
| 587 | "deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c", | |
| 588 | "deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c", | |
| 589 | "deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c", | |
| 590 | "deps/SoftFloat-3e/source/8086/s_extF80MToCommonNaN.c", | |
| 591 | "deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c", | |
| 592 | "deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c", | |
| 593 | "deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c", | |
| 594 | "deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c", | |
| 595 | "deps/SoftFloat-3e/source/8086/s_propagateNaNExtF80M.c", | |
| 596 | "deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c", | |
| 597 | "deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c", | |
| 598 | "deps/SoftFloat-3e/source/f128M_add.c", | |
| 599 | "deps/SoftFloat-3e/source/f128M_div.c", | |
| 600 | "deps/SoftFloat-3e/source/f128M_eq.c", | |
| 601 | "deps/SoftFloat-3e/source/f128M_eq_signaling.c", | |
| 602 | "deps/SoftFloat-3e/source/f128M_le.c", | |
| 603 | "deps/SoftFloat-3e/source/f128M_le_quiet.c", | |
| 604 | "deps/SoftFloat-3e/source/f128M_lt.c", | |
| 605 | "deps/SoftFloat-3e/source/f128M_lt_quiet.c", | |
| 606 | "deps/SoftFloat-3e/source/f128M_mul.c", | |
| 607 | "deps/SoftFloat-3e/source/f128M_mulAdd.c", | |
| 608 | "deps/SoftFloat-3e/source/f128M_rem.c", | |
| 609 | "deps/SoftFloat-3e/source/f128M_roundToInt.c", | |
| 610 | "deps/SoftFloat-3e/source/f128M_sqrt.c", | |
| 611 | "deps/SoftFloat-3e/source/f128M_sub.c", | |
| 612 | "deps/SoftFloat-3e/source/f128M_to_f16.c", | |
| 613 | "deps/SoftFloat-3e/source/f128M_to_f32.c", | |
| 614 | "deps/SoftFloat-3e/source/f128M_to_f64.c", | |
| 615 | "deps/SoftFloat-3e/source/f128M_to_extF80M.c", | |
| 616 | "deps/SoftFloat-3e/source/f128M_to_i32.c", | |
| 617 | "deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c", | |
| 618 | "deps/SoftFloat-3e/source/f128M_to_i64.c", | |
| 619 | "deps/SoftFloat-3e/source/f128M_to_i64_r_minMag.c", | |
| 620 | "deps/SoftFloat-3e/source/f128M_to_ui32.c", | |
| 621 | "deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c", | |
| 622 | "deps/SoftFloat-3e/source/f128M_to_ui64.c", | |
| 623 | "deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c", | |
| 624 | "deps/SoftFloat-3e/source/extF80M_add.c", | |
| 625 | "deps/SoftFloat-3e/source/extF80M_div.c", | |
| 626 | "deps/SoftFloat-3e/source/extF80M_eq.c", | |
| 627 | "deps/SoftFloat-3e/source/extF80M_le.c", | |
| 628 | "deps/SoftFloat-3e/source/extF80M_lt.c", | |
| 629 | "deps/SoftFloat-3e/source/extF80M_mul.c", | |
| 630 | "deps/SoftFloat-3e/source/extF80M_rem.c", | |
| 631 | "deps/SoftFloat-3e/source/extF80M_roundToInt.c", | |
| 632 | "deps/SoftFloat-3e/source/extF80M_sqrt.c", | |
| 633 | "deps/SoftFloat-3e/source/extF80M_sub.c", | |
| 634 | "deps/SoftFloat-3e/source/extF80M_to_f16.c", | |
| 635 | "deps/SoftFloat-3e/source/extF80M_to_f32.c", | |
| 636 | "deps/SoftFloat-3e/source/extF80M_to_f64.c", | |
| 637 | "deps/SoftFloat-3e/source/extF80M_to_f128M.c", | |
| 638 | "deps/SoftFloat-3e/source/f16_add.c", | |
| 639 | "deps/SoftFloat-3e/source/f16_div.c", | |
| 640 | "deps/SoftFloat-3e/source/f16_eq.c", | |
| 641 | "deps/SoftFloat-3e/source/f16_isSignalingNaN.c", | |
| 642 | "deps/SoftFloat-3e/source/f16_lt.c", | |
| 643 | "deps/SoftFloat-3e/source/f16_mul.c", | |
| 644 | "deps/SoftFloat-3e/source/f16_mulAdd.c", | |
| 645 | "deps/SoftFloat-3e/source/f16_rem.c", | |
| 646 | "deps/SoftFloat-3e/source/f16_roundToInt.c", | |
| 647 | "deps/SoftFloat-3e/source/f16_sqrt.c", | |
| 648 | "deps/SoftFloat-3e/source/f16_sub.c", | |
| 649 | "deps/SoftFloat-3e/source/f16_to_extF80M.c", | |
| 650 | "deps/SoftFloat-3e/source/f16_to_f128M.c", | |
| 651 | "deps/SoftFloat-3e/source/f16_to_f64.c", | |
| 652 | "deps/SoftFloat-3e/source/f32_to_extF80M.c", | |
| 653 | "deps/SoftFloat-3e/source/f32_to_f128M.c", | |
| 654 | "deps/SoftFloat-3e/source/f64_to_extF80M.c", | |
| 655 | "deps/SoftFloat-3e/source/f64_to_f128M.c", | |
| 656 | "deps/SoftFloat-3e/source/f64_to_f16.c", | |
| 657 | "deps/SoftFloat-3e/source/i32_to_f128M.c", | |
| 658 | "deps/SoftFloat-3e/source/s_add256M.c", | |
| 659 | "deps/SoftFloat-3e/source/s_addCarryM.c", | |
| 660 | "deps/SoftFloat-3e/source/s_addComplCarryM.c", | |
| 661 | "deps/SoftFloat-3e/source/s_addF128M.c", | |
| 662 | "deps/SoftFloat-3e/source/s_addExtF80M.c", | |
| 663 | "deps/SoftFloat-3e/source/s_addM.c", | |
| 664 | "deps/SoftFloat-3e/source/s_addMagsF16.c", | |
| 665 | "deps/SoftFloat-3e/source/s_addMagsF32.c", | |
| 666 | "deps/SoftFloat-3e/source/s_addMagsF64.c", | |
| 667 | "deps/SoftFloat-3e/source/s_approxRecip32_1.c", | |
| 668 | "deps/SoftFloat-3e/source/s_approxRecipSqrt32_1.c", | |
| 669 | "deps/SoftFloat-3e/source/s_approxRecipSqrt_1Ks.c", | |
| 670 | "deps/SoftFloat-3e/source/s_approxRecip_1Ks.c", | |
| 671 | "deps/SoftFloat-3e/source/s_compare128M.c", | |
| 672 | "deps/SoftFloat-3e/source/s_compare96M.c", | |
| 673 | "deps/SoftFloat-3e/source/s_compareNonnormExtF80M.c", | |
| 674 | "deps/SoftFloat-3e/source/s_countLeadingZeros16.c", | |
| 675 | "deps/SoftFloat-3e/source/s_countLeadingZeros32.c", | |
| 676 | "deps/SoftFloat-3e/source/s_countLeadingZeros64.c", | |
| 677 | "deps/SoftFloat-3e/source/s_countLeadingZeros8.c", | |
| 678 | "deps/SoftFloat-3e/source/s_eq128.c", | |
| 679 | "deps/SoftFloat-3e/source/s_invalidF128M.c", | |
| 680 | "deps/SoftFloat-3e/source/s_invalidExtF80M.c", | |
| 681 | "deps/SoftFloat-3e/source/s_isNaNF128M.c", | |
| 682 | "deps/SoftFloat-3e/source/s_le128.c", | |
| 683 | "deps/SoftFloat-3e/source/s_lt128.c", | |
| 684 | "deps/SoftFloat-3e/source/s_mul128MTo256M.c", | |
| 685 | "deps/SoftFloat-3e/source/s_mul64To128M.c", | |
| 686 | "deps/SoftFloat-3e/source/s_mulAddF128M.c", | |
| 687 | "deps/SoftFloat-3e/source/s_mulAddF16.c", | |
| 688 | "deps/SoftFloat-3e/source/s_mulAddF32.c", | |
| 689 | "deps/SoftFloat-3e/source/s_mulAddF64.c", | |
| 690 | "deps/SoftFloat-3e/source/s_negXM.c", | |
| 691 | "deps/SoftFloat-3e/source/s_normExtF80SigM.c", | |
| 692 | "deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c", | |
| 693 | "deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.c", | |
| 694 | "deps/SoftFloat-3e/source/s_normRoundPackToF16.c", | |
| 695 | "deps/SoftFloat-3e/source/s_normRoundPackToF32.c", | |
| 696 | "deps/SoftFloat-3e/source/s_normRoundPackToF64.c", | |
| 697 | "deps/SoftFloat-3e/source/s_normSubnormalF128SigM.c", | |
| 698 | "deps/SoftFloat-3e/source/s_normSubnormalF16Sig.c", | |
| 699 | "deps/SoftFloat-3e/source/s_normSubnormalF32Sig.c", | |
| 700 | "deps/SoftFloat-3e/source/s_normSubnormalF64Sig.c", | |
| 701 | "deps/SoftFloat-3e/source/s_remStepMBy32.c", | |
| 702 | "deps/SoftFloat-3e/source/s_roundMToI64.c", | |
| 703 | "deps/SoftFloat-3e/source/s_roundMToUI64.c", | |
| 704 | "deps/SoftFloat-3e/source/s_roundPackMToExtF80M.c", | |
| 705 | "deps/SoftFloat-3e/source/s_roundPackMToF128M.c", | |
| 706 | "deps/SoftFloat-3e/source/s_roundPackToF16.c", | |
| 707 | "deps/SoftFloat-3e/source/s_roundPackToF32.c", | |
| 708 | "deps/SoftFloat-3e/source/s_roundPackToF64.c", | |
| 709 | "deps/SoftFloat-3e/source/s_roundToI32.c", | |
| 710 | "deps/SoftFloat-3e/source/s_roundToI64.c", | |
| 711 | "deps/SoftFloat-3e/source/s_roundToUI32.c", | |
| 712 | "deps/SoftFloat-3e/source/s_roundToUI64.c", | |
| 713 | "deps/SoftFloat-3e/source/s_shiftLeftM.c", | |
| 714 | "deps/SoftFloat-3e/source/s_shiftNormSigF128M.c", | |
| 715 | "deps/SoftFloat-3e/source/s_shiftRightJam256M.c", | |
| 716 | "deps/SoftFloat-3e/source/s_shiftRightJam32.c", | |
| 717 | "deps/SoftFloat-3e/source/s_shiftRightJam64.c", | |
| 718 | "deps/SoftFloat-3e/source/s_shiftRightJamM.c", | |
| 719 | "deps/SoftFloat-3e/source/s_shiftRightM.c", | |
| 720 | "deps/SoftFloat-3e/source/s_shortShiftLeft64To96M.c", | |
| 721 | "deps/SoftFloat-3e/source/s_shortShiftLeftM.c", | |
| 722 | "deps/SoftFloat-3e/source/s_shortShiftRightExtendM.c", | |
| 723 | "deps/SoftFloat-3e/source/s_shortShiftRightJam64.c", | |
| 724 | "deps/SoftFloat-3e/source/s_shortShiftRightJamM.c", | |
| 725 | "deps/SoftFloat-3e/source/s_shortShiftRightM.c", | |
| 726 | "deps/SoftFloat-3e/source/s_sub1XM.c", | |
| 727 | "deps/SoftFloat-3e/source/s_sub256M.c", | |
| 728 | "deps/SoftFloat-3e/source/s_subM.c", | |
| 729 | "deps/SoftFloat-3e/source/s_subMagsF16.c", | |
| 730 | "deps/SoftFloat-3e/source/s_subMagsF32.c", | |
| 731 | "deps/SoftFloat-3e/source/s_subMagsF64.c", | |
| 732 | "deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c", | |
| 733 | "deps/SoftFloat-3e/source/s_tryPropagateNaNExtF80M.c", | |
| 734 | "deps/SoftFloat-3e/source/softfloat_state.c", | |
| 735 | "deps/SoftFloat-3e/source/ui32_to_f128M.c", | |
| 736 | "deps/SoftFloat-3e/source/ui64_to_f128M.c", | |
| 737 | "deps/SoftFloat-3e/source/ui32_to_extF80M.c", | |
| 738 | "deps/SoftFloat-3e/source/ui64_to_extF80M.c", | |
| 739 | }; | |
| 740 | ||
| 741 | const stage1_sources = [_][]const u8{ | |
| 742 | "src/stage1/analyze.cpp", | |
| 743 | "src/stage1/astgen.cpp", | |
| 744 | "src/stage1/bigfloat.cpp", | |
| 745 | "src/stage1/bigint.cpp", | |
| 746 | "src/stage1/buffer.cpp", | |
| 747 | "src/stage1/codegen.cpp", | |
| 748 | "src/stage1/errmsg.cpp", | |
| 749 | "src/stage1/error.cpp", | |
| 750 | "src/stage1/heap.cpp", | |
| 751 | "src/stage1/ir.cpp", | |
| 752 | "src/stage1/ir_print.cpp", | |
| 753 | "src/stage1/mem.cpp", | |
| 754 | "src/stage1/os.cpp", | |
| 755 | "src/stage1/parser.cpp", | |
| 756 | "src/stage1/range_set.cpp", | |
| 757 | "src/stage1/stage1.cpp", | |
| 758 | "src/stage1/target.cpp", | |
| 759 | "src/stage1/tokenizer.cpp", | |
| 760 | "src/stage1/util.cpp", | |
| 761 | "src/stage1/softfloat_ext.cpp", | |
| 762 | }; | |
| 763 | const optimized_c_sources = [_][]const u8{ | |
| 764 | "src/stage1/parse_f128.c", | |
| 765 | }; | |
| 766 | const zig_cpp_sources = [_][]const u8{ | |
| 767 | // These are planned to stay even when we are self-hosted. | |
| 768 | "src/zig_llvm.cpp", | |
| 769 | "src/zig_clang.cpp", | |
| 770 | "src/zig_llvm-ar.cpp", | |
| 771 | "src/zig_clang_driver.cpp", | |
| 772 | "src/zig_clang_cc1_main.cpp", | |
| 773 | "src/zig_clang_cc1as_main.cpp", | |
| 774 | // https://github.com/ziglang/zig/issues/6363 | |
| 775 | "src/windows_sdk.cpp", | |
| 776 | }; | |
| 777 | ||
| 778 | const clang_libs = [_][]const u8{ | |
| 779 | "clangFrontendTool", | |
| 780 | "clangCodeGen", | |
| 781 | "clangFrontend", | |
| 782 | "clangDriver", | |
| 783 | "clangSerialization", | |
| 784 | "clangSema", | |
| 785 | "clangStaticAnalyzerFrontend", | |
| 786 | "clangStaticAnalyzerCheckers", | |
| 787 | "clangStaticAnalyzerCore", | |
| 788 | "clangAnalysis", | |
| 789 | "clangASTMatchers", | |
| 790 | "clangAST", | |
| 791 | "clangParse", | |
| 792 | "clangSema", | |
| 793 | "clangBasic", | |
| 794 | "clangEdit", | |
| 795 | "clangLex", | |
| 796 | "clangARCMigrate", | |
| 797 | "clangRewriteFrontend", | |
| 798 | "clangRewrite", | |
| 799 | "clangCrossTU", | |
| 800 | "clangIndex", | |
| 801 | "clangToolingCore", | |
| 802 | }; | |
| 803 | const lld_libs = [_][]const u8{ | |
| 804 | "lldMinGW", | |
| 805 | "lldELF", | |
| 806 | "lldCOFF", | |
| 807 | "lldWasm", | |
| 808 | "lldMachO", | |
| 809 | "lldCommon", | |
| 810 | }; | |
| 811 | // This list can be re-generated with `llvm-config --libfiles` and then | |
| 812 | // reformatting using your favorite text editor. Note we do not execute | |
| 813 | // `llvm-config` here because we are cross compiling. Also omit LLVMTableGen | |
| 814 | // from these libs. | |
| 815 | const llvm_libs = [_][]const u8{ | |
| 816 | "LLVMWindowsManifest", | |
| 817 | "LLVMXRay", | |
| 818 | "LLVMLibDriver", | |
| 819 | "LLVMDlltoolDriver", | |
| 820 | "LLVMCoverage", | |
| 821 | "LLVMLineEditor", | |
| 822 | "LLVMXCoreDisassembler", | |
| 823 | "LLVMXCoreCodeGen", | |
| 824 | "LLVMXCoreDesc", | |
| 825 | "LLVMXCoreInfo", | |
| 826 | "LLVMX86TargetMCA", | |
| 827 | "LLVMX86Disassembler", | |
| 828 | "LLVMX86AsmParser", | |
| 829 | "LLVMX86CodeGen", | |
| 830 | "LLVMX86Desc", | |
| 831 | "LLVMX86Info", | |
| 832 | "LLVMWebAssemblyDisassembler", | |
| 833 | "LLVMWebAssemblyAsmParser", | |
| 834 | "LLVMWebAssemblyCodeGen", | |
| 835 | "LLVMWebAssemblyDesc", | |
| 836 | "LLVMWebAssemblyUtils", | |
| 837 | "LLVMWebAssemblyInfo", | |
| 838 | "LLVMVEDisassembler", | |
| 839 | "LLVMVEAsmParser", | |
| 840 | "LLVMVECodeGen", | |
| 841 | "LLVMVEDesc", | |
| 842 | "LLVMVEInfo", | |
| 843 | "LLVMSystemZDisassembler", | |
| 844 | "LLVMSystemZAsmParser", | |
| 845 | "LLVMSystemZCodeGen", | |
| 846 | "LLVMSystemZDesc", | |
| 847 | "LLVMSystemZInfo", | |
| 848 | "LLVMSparcDisassembler", | |
| 849 | "LLVMSparcAsmParser", | |
| 850 | "LLVMSparcCodeGen", | |
| 851 | "LLVMSparcDesc", | |
| 852 | "LLVMSparcInfo", | |
| 853 | "LLVMRISCVDisassembler", | |
| 854 | "LLVMRISCVAsmParser", | |
| 855 | "LLVMRISCVCodeGen", | |
| 856 | "LLVMRISCVDesc", | |
| 857 | "LLVMRISCVInfo", | |
| 858 | "LLVMPowerPCDisassembler", | |
| 859 | "LLVMPowerPCAsmParser", | |
| 860 | "LLVMPowerPCCodeGen", | |
| 861 | "LLVMPowerPCDesc", | |
| 862 | "LLVMPowerPCInfo", | |
| 863 | "LLVMNVPTXCodeGen", | |
| 864 | "LLVMNVPTXDesc", | |
| 865 | "LLVMNVPTXInfo", | |
| 866 | "LLVMMSP430Disassembler", | |
| 867 | "LLVMMSP430AsmParser", | |
| 868 | "LLVMMSP430CodeGen", | |
| 869 | "LLVMMSP430Desc", | |
| 870 | "LLVMMSP430Info", | |
| 871 | "LLVMMipsDisassembler", | |
| 872 | "LLVMMipsAsmParser", | |
| 873 | "LLVMMipsCodeGen", | |
| 874 | "LLVMMipsDesc", | |
| 875 | "LLVMMipsInfo", | |
| 876 | "LLVMLanaiDisassembler", | |
| 877 | "LLVMLanaiCodeGen", | |
| 878 | "LLVMLanaiAsmParser", | |
| 879 | "LLVMLanaiDesc", | |
| 880 | "LLVMLanaiInfo", | |
| 881 | "LLVMHexagonDisassembler", | |
| 882 | "LLVMHexagonCodeGen", | |
| 883 | "LLVMHexagonAsmParser", | |
| 884 | "LLVMHexagonDesc", | |
| 885 | "LLVMHexagonInfo", | |
| 886 | "LLVMBPFDisassembler", | |
| 887 | "LLVMBPFAsmParser", | |
| 888 | "LLVMBPFCodeGen", | |
| 889 | "LLVMBPFDesc", | |
| 890 | "LLVMBPFInfo", | |
| 891 | "LLVMAVRDisassembler", | |
| 892 | "LLVMAVRAsmParser", | |
| 893 | "LLVMAVRCodeGen", | |
| 894 | "LLVMAVRDesc", | |
| 895 | "LLVMAVRInfo", | |
| 896 | "LLVMARMDisassembler", | |
| 897 | "LLVMARMAsmParser", | |
| 898 | "LLVMARMCodeGen", | |
| 899 | "LLVMARMDesc", | |
| 900 | "LLVMARMUtils", | |
| 901 | "LLVMARMInfo", | |
| 902 | "LLVMAMDGPUTargetMCA", | |
| 903 | "LLVMAMDGPUDisassembler", | |
| 904 | "LLVMAMDGPUAsmParser", | |
| 905 | "LLVMAMDGPUCodeGen", | |
| 906 | "LLVMAMDGPUDesc", | |
| 907 | "LLVMAMDGPUUtils", | |
| 908 | "LLVMAMDGPUInfo", | |
| 909 | "LLVMAArch64Disassembler", | |
| 910 | "LLVMAArch64AsmParser", | |
| 911 | "LLVMAArch64CodeGen", | |
| 912 | "LLVMAArch64Desc", | |
| 913 | "LLVMAArch64Utils", | |
| 914 | "LLVMAArch64Info", | |
| 915 | "LLVMOrcJIT", | |
| 916 | "LLVMMCJIT", | |
| 917 | "LLVMJITLink", | |
| 918 | "LLVMInterpreter", | |
| 919 | "LLVMExecutionEngine", | |
| 920 | "LLVMRuntimeDyld", | |
| 921 | "LLVMOrcTargetProcess", | |
| 922 | "LLVMOrcShared", | |
| 923 | "LLVMDWP", | |
| 924 | "LLVMSymbolize", | |
| 925 | "LLVMDebugInfoPDB", | |
| 926 | "LLVMDebugInfoGSYM", | |
| 927 | "LLVMOption", | |
| 928 | "LLVMObjectYAML", | |
| 929 | "LLVMMCA", | |
| 930 | "LLVMMCDisassembler", | |
| 931 | "LLVMLTO", | |
| 932 | "LLVMPasses", | |
| 933 | "LLVMCFGuard", | |
| 934 | "LLVMCoroutines", | |
| 935 | "LLVMObjCARCOpts", | |
| 936 | "LLVMipo", | |
| 937 | "LLVMVectorize", | |
| 938 | "LLVMLinker", | |
| 939 | "LLVMInstrumentation", | |
| 940 | "LLVMFrontendOpenMP", | |
| 941 | "LLVMFrontendOpenACC", | |
| 942 | "LLVMExtensions", | |
| 943 | "LLVMDWARFLinker", | |
| 944 | "LLVMGlobalISel", | |
| 945 | "LLVMMIRParser", | |
| 946 | "LLVMAsmPrinter", | |
| 947 | "LLVMDebugInfoMSF", | |
| 948 | "LLVMSelectionDAG", | |
| 949 | "LLVMCodeGen", | |
| 950 | "LLVMIRReader", | |
| 951 | "LLVMAsmParser", | |
| 952 | "LLVMInterfaceStub", | |
| 953 | "LLVMFileCheck", | |
| 954 | "LLVMFuzzMutate", | |
| 955 | "LLVMTarget", | |
| 956 | "LLVMScalarOpts", | |
| 957 | "LLVMInstCombine", | |
| 958 | "LLVMAggressiveInstCombine", | |
| 959 | "LLVMTransformUtils", | |
| 960 | "LLVMBitWriter", | |
| 961 | "LLVMAnalysis", | |
| 962 | "LLVMProfileData", | |
| 963 | "LLVMDebugInfoDWARF", | |
| 964 | "LLVMObject", | |
| 965 | "LLVMTextAPI", | |
| 966 | "LLVMMCParser", | |
| 967 | "LLVMMC", | |
| 968 | "LLVMDebugInfoCodeView", | |
| 969 | "LLVMBitReader", | |
| 970 | "LLVMCore", | |
| 971 | "LLVMRemarks", | |
| 972 | "LLVMBitstreamReader", | |
| 973 | "LLVMBinaryFormat", | |
| 974 | "LLVMSupport", | |
| 975 | "LLVMDemangle", | |
| 976 | }; |
ci/azure/macos_script+19-36| ... | ... | @@ -34,13 +34,11 @@ git fetch --tags |
| 34 | 34 | mkdir build |
| 35 | 35 | cd build |
| 36 | 36 | cmake .. \ |
| 37 | -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \ | |
| 38 | 37 | -DCMAKE_PREFIX_PATH="$PREFIX" \ |
| 39 | 38 | -DCMAKE_BUILD_TYPE=Release \ |
| 40 | 39 | -DZIG_TARGET_TRIPLE="$TARGET" \ |
| 41 | 40 | -DZIG_TARGET_MCPU="$MCPU" \ |
| 42 | -DZIG_STATIC=ON \ | |
| 43 | -DZIG_OMIT_STAGE2=ON | |
| 41 | -DZIG_STATIC=ON | |
| 44 | 42 | |
| 45 | 43 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables |
| 46 | 44 | # so that installation and testing do not get affected by them. |
| ... | ... | @@ -49,45 +47,30 @@ unset CXX |
| 49 | 47 | |
| 50 | 48 | make $JOBS install |
| 51 | 49 | |
| 52 | # Here we rebuild zig but this time using the Zig binary we just now produced to | |
| 53 | # build zig1.o rather than relying on the one built with stage0. See | |
| 54 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 55 | cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig" | |
| 56 | make $JOBS install | |
| 50 | stage2/bin/zig build \ | |
| 51 | --prefix stage3-release \ | |
| 52 | --search-prefix "$PREFIX" \ | |
| 53 | -Dstatic-llvm \ | |
| 54 | -Drelease \ | |
| 55 | -Dstrip \ | |
| 56 | -Dtarget="$TARGET" \ | |
| 57 | -Denable-stage1 | |
| 57 | 58 | |
| 58 | # Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. | |
| 59 | release/bin/zig build -p stage2 -Denable-llvm | |
| 60 | ||
| 61 | stage2/bin/zig build test-behavior | |
| 62 | ||
| 63 | # TODO: upgrade these to test stage2 instead of stage1 | |
| 64 | # TODO: upgrade these to test stage3 instead of stage2 | |
| 65 | release/bin/zig build test-behavior -Denable-macos-sdk -Domit-stage2 | |
| 66 | release/bin/zig build test-compiler-rt -Denable-macos-sdk | |
| 67 | release/bin/zig build test-std -Denable-macos-sdk | |
| 68 | release/bin/zig build test-universal-libc -Denable-macos-sdk | |
| 69 | release/bin/zig build test-compare-output -Denable-macos-sdk | |
| 70 | release/bin/zig build test-standalone -Denable-macos-sdk | |
| 71 | release/bin/zig build test-stack-traces -Denable-macos-sdk | |
| 72 | release/bin/zig build test-cli -Denable-macos-sdk | |
| 73 | release/bin/zig build test-asm-link -Denable-macos-sdk | |
| 74 | release/bin/zig build test-translate-c -Denable-macos-sdk | |
| 75 | release/bin/zig build test-run-translated-c -Denable-macos-sdk | |
| 76 | release/bin/zig build docs -Denable-macos-sdk | |
| 77 | release/bin/zig build test-fmt -Denable-macos-sdk | |
| 78 | release/bin/zig build test-cases -Denable-macos-sdk -Dsingle-threaded | |
| 79 | release/bin/zig build test-link -Denable-macos-sdk -Domit-stage2 | |
| 59 | stage3-release/bin/zig build test docs \ | |
| 60 | -Denable-macos-sdk \ | |
| 61 | -Dstatic-llvm \ | |
| 62 | --search-prefix "$PREFIX" | |
| 80 | 63 | |
| 81 | 64 | if [ "${BUILD_REASON}" != "PullRequest" ]; then |
| 82 | mv ../LICENSE release/ | |
| 83 | mv ../zig-cache/langref.html release/ | |
| 84 | mv release/bin/zig release/ | |
| 85 | rmdir release/bin | |
| 65 | mv ../LICENSE stage3-release/ | |
| 66 | mv ../zig-cache/langref.html stage3-release/ | |
| 67 | mv stage3-release/bin/zig stage3-release/ | |
| 68 | rmdir stage3-release/bin | |
| 86 | 69 | |
| 87 | VERSION=$(release/zig version) | |
| 70 | VERSION=$(stage3-release/zig version) | |
| 88 | 71 | DIRNAME="zig-macos-$ARCH-$VERSION" |
| 89 | 72 | TARBALL="$DIRNAME.tar.xz" |
| 90 | mv release "$DIRNAME" | |
| 73 | mv stage3-release "$DIRNAME" | |
| 91 | 74 | tar cfJ "$TARBALL" "$DIRNAME" |
| 92 | 75 | |
| 93 | 76 | mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" |
ci/azure/pipelines.yml+21-60| ... | ... | @@ -27,7 +27,7 @@ jobs: |
| 27 | 27 | vmImage: 'windows-2019' |
| 28 | 28 | variables: |
| 29 | 29 | TARGET: 'x86_64-windows-gnu' |
| 30 | ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.3524+74673b7f6' | |
| 30 | ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.3653+7152a58c1' | |
| 31 | 31 | ZIG_LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/${{ variables.ZIG_LLVM_CLANG_LLD_NAME }}.zip' |
| 32 | 32 | steps: |
| 33 | 33 | - pwsh: | |
| ... | ... | @@ -37,8 +37,8 @@ jobs: |
| 37 | 37 | displayName: 'Install ZIG/LLVM/CLANG/LLD' |
| 38 | 38 | |
| 39 | 39 | - pwsh: | |
| 40 | Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build" | |
| 41 | Set-Variable -Name ZIGINSTALLDIR -Value "${ZIGBUILDDIR}\dist" | |
| 40 | Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib" | |
| 41 | Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release" | |
| 42 | 42 | Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(ZIG_LLVM_CLANG_LLD_NAME)" |
| 43 | 43 | |
| 44 | 44 | function CheckLastExitCode { |
| ... | ... | @@ -56,40 +56,22 @@ jobs: |
| 56 | 56 | git fetch --unshallow # `git describe` won't work on a shallow repo |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | # The dev kit zip file that we have here is old, and may be incompatible with | |
| 60 | # the build.zig script of master branch. So we keep an old version of build.zig | |
| 61 | # here in the CI directory. | |
| 62 | mv build.zig build.zig.master | |
| 63 | mv ci/azure/build.zig build.zig | |
| 64 | ||
| 65 | mkdir $ZIGBUILDDIR | |
| 66 | cd $ZIGBUILDDIR | |
| 67 | ||
| 68 | & "${ZIGPREFIXPATH}/bin/zig.exe" build ` | |
| 59 | & "$ZIGPREFIXPATH\bin\zig.exe" build ` | |
| 69 | 60 | --prefix "$ZIGINSTALLDIR" ` |
| 70 | 61 | --search-prefix "$ZIGPREFIXPATH" ` |
| 71 | -Dstage1 ` | |
| 72 | <# stage2 is omitted until we resolve https://github.com/ziglang/zig/issues/6485 #> ` | |
| 73 | -Domit-stage2 ` | |
| 62 | --zig-lib-dir "$ZIGLIBDIR" ` | |
| 63 | -Denable-stage1 ` | |
| 74 | 64 | -Dstatic-llvm ` |
| 75 | 65 | -Drelease ` |
| 76 | 66 | -Dstrip ` |
| 77 | 67 | -Duse-zig-libcxx ` |
| 78 | 68 | -Dtarget=$(TARGET) |
| 79 | 69 | CheckLastExitCode |
| 80 | ||
| 81 | cd - | |
| 82 | ||
| 83 | # Now that we have built an up-to-date zig.exe, we restore the original | |
| 84 | # build script from master branch. | |
| 85 | rm build.zig | |
| 86 | mv build.zig.master build.zig | |
| 87 | ||
| 88 | 70 | name: build |
| 89 | 71 | displayName: 'Build' |
| 90 | 72 | |
| 91 | 73 | - pwsh: | |
| 92 | Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist" | |
| 74 | Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release" | |
| 93 | 75 | |
| 94 | 76 | function CheckLastExitCode { |
| 95 | 77 | if (!$?) { |
| ... | ... | @@ -98,41 +80,21 @@ jobs: |
| 98 | 80 | return 0 |
| 99 | 81 | } |
| 100 | 82 | |
| 101 | # Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is | |
| 102 | # built with itself and does not gobble as much memory, we can enable these tests. | |
| 103 | #& "$ZIGINSTALLDIR\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" 2>&1 | |
| 104 | #CheckLastExitCode | |
| 105 | ||
| 106 | & "$ZIGINSTALLDIR\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests -Domit-stage2 2>&1 | |
| 107 | CheckLastExitCode | |
| 108 | & "$ZIGINSTALLDIR\bin\zig.exe" build test-std -Dskip-non-native 2>&1 | |
| 83 | & "$ZIGINSTALLDIR\bin\zig.exe" build test docs ` | |
| 84 | --search-prefix "$ZIGPREFIXPATH" ` | |
| 85 | -Dstatic-llvm ` | |
| 86 | -Dskip-non-native ` | |
| 87 | -Dskip-stage2-tests | |
| 109 | 88 | CheckLastExitCode |
| 110 | 89 | name: test |
| 111 | 90 | displayName: 'Test' |
| 112 | 91 | |
| 113 | - pwsh: | | |
| 114 | Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist" | |
| 115 | ||
| 116 | function CheckLastExitCode { | |
| 117 | if (!$?) { | |
| 118 | exit 1 | |
| 119 | } | |
| 120 | return 0 | |
| 121 | } | |
| 122 | ||
| 123 | & "$ZIGINSTALLDIR\bin\zig.exe" build docs | |
| 124 | CheckLastExitCode | |
| 125 | timeoutInMinutes: 60 | |
| 126 | name: doc | |
| 127 | displayName: 'Documentation' | |
| 128 | ||
| 129 | 92 | - task: DownloadSecureFile@1 |
| 130 | 93 | inputs: |
| 131 | 94 | name: aws_credentials |
| 132 | 95 | secureFile: aws_credentials |
| 133 | 96 | |
| 134 | 97 | - pwsh: | |
| 135 | Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build" | |
| 136 | 98 | $Env:AWS_SHARED_CREDENTIALS_FILE = "$Env:DOWNLOADSECUREFILE_SECUREFILEPATH" |
| 137 | 99 | |
| 138 | 100 | # Workaround Azure networking issue |
| ... | ... | @@ -140,21 +102,20 @@ jobs: |
| 140 | 102 | $Env:AWS_EC2_METADATA_DISABLED = "true" |
| 141 | 103 | $Env:AWS_REGION = "us-west-2" |
| 142 | 104 | |
| 143 | cd "$ZIGBUILDDIR" | |
| 144 | mv ../LICENSE dist/ | |
| 145 | mv ../zig-cache/langref.html dist/ | |
| 146 | mv dist/bin/zig.exe dist/ | |
| 147 | rmdir dist/bin | |
| 105 | mv LICENSE stage3-release/ | |
| 106 | mv zig-cache/langref.html stage3-release/ | |
| 107 | mv stage3-release/bin/zig.exe stage3-release/ | |
| 108 | rmdir stage3-release/bin | |
| 148 | 109 | |
| 149 | 110 | # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig |
| 150 | mv dist/lib/zig dist/lib2 | |
| 151 | rmdir dist/lib | |
| 152 | mv dist/lib2 dist/lib | |
| 111 | mv stage3-release/lib/zig stage3-release/lib2 | |
| 112 | rmdir stage3-release/lib | |
| 113 | mv stage3-release/lib2 stage3-release/lib | |
| 153 | 114 | |
| 154 | Set-Variable -Name VERSION -Value $(./dist/zig.exe version) | |
| 115 | Set-Variable -Name VERSION -Value $(./stage3-release/zig.exe version) | |
| 155 | 116 | Set-Variable -Name DIRNAME -Value "zig-windows-x86_64-$VERSION" |
| 156 | 117 | Set-Variable -Name TARBALL -Value "$DIRNAME.zip" |
| 157 | mv dist "$DIRNAME" | |
| 118 | mv stage3-release "$DIRNAME" | |
| 158 | 119 | 7z a "$TARBALL" "$DIRNAME" |
| 159 | 120 | |
| 160 | 121 | aws s3 cp ` |
ci/drone/drone.yml+21-21| ... | ... | @@ -13,65 +13,65 @@ steps: |
| 13 | 13 | commands: |
| 14 | 14 | - ./ci/drone/linux_script_build |
| 15 | 15 | |
| 16 | - name: test-1 | |
| 16 | - name: behavior | |
| 17 | 17 | depends_on: |
| 18 | 18 | - build |
| 19 | 19 | image: ziglang/static-base:llvm14-aarch64-3 |
| 20 | 20 | commands: |
| 21 | - ./ci/drone/linux_script_test 1 | |
| 21 | - ./ci/drone/test_linux_behavior | |
| 22 | 22 | |
| 23 | - name: test-2 | |
| 23 | - name: std_Debug | |
| 24 | 24 | depends_on: |
| 25 | 25 | - build |
| 26 | 26 | image: ziglang/static-base:llvm14-aarch64-3 |
| 27 | 27 | commands: |
| 28 | - ./ci/drone/linux_script_test 2 | |
| 28 | - ./ci/drone/test_linux_std_Debug | |
| 29 | 29 | |
| 30 | - name: test-3 | |
| 30 | - name: std_ReleaseSafe | |
| 31 | 31 | depends_on: |
| 32 | 32 | - build |
| 33 | 33 | image: ziglang/static-base:llvm14-aarch64-3 |
| 34 | 34 | commands: |
| 35 | - ./ci/drone/linux_script_test 3 | |
| 35 | - ./ci/drone/test_linux_std_ReleaseSafe | |
| 36 | 36 | |
| 37 | - name: test-4 | |
| 37 | - name: std_ReleaseFast | |
| 38 | 38 | depends_on: |
| 39 | 39 | - build |
| 40 | 40 | image: ziglang/static-base:llvm14-aarch64-3 |
| 41 | 41 | commands: |
| 42 | - ./ci/drone/linux_script_test 4 | |
| 42 | - ./ci/drone/test_linux_std_ReleaseFast | |
| 43 | 43 | |
| 44 | - name: test-5 | |
| 44 | - name: std_ReleaseSmall | |
| 45 | 45 | depends_on: |
| 46 | 46 | - build |
| 47 | 47 | image: ziglang/static-base:llvm14-aarch64-3 |
| 48 | 48 | commands: |
| 49 | - ./ci/drone/linux_script_test 5 | |
| 49 | - ./ci/drone/test_linux_std_ReleaseSmall | |
| 50 | 50 | |
| 51 | - name: test-6 | |
| 51 | - name: misc | |
| 52 | 52 | depends_on: |
| 53 | 53 | - build |
| 54 | 54 | image: ziglang/static-base:llvm14-aarch64-3 |
| 55 | 55 | commands: |
| 56 | - ./ci/drone/linux_script_test 6 | |
| 56 | - ./ci/drone/test_linux_misc | |
| 57 | 57 | |
| 58 | - name: test-7 | |
| 58 | - name: cases | |
| 59 | 59 | depends_on: |
| 60 | 60 | - build |
| 61 | 61 | image: ziglang/static-base:llvm14-aarch64-3 |
| 62 | 62 | commands: |
| 63 | - ./ci/drone/linux_script_test 7 | |
| 63 | - ./ci/drone/test_linux_cases | |
| 64 | 64 | |
| 65 | 65 | - name: finalize |
| 66 | 66 | depends_on: |
| 67 | 67 | - build |
| 68 | - test-1 | |
| 69 | - test-2 | |
| 70 | - test-3 | |
| 71 | - test-4 | |
| 72 | - test-5 | |
| 73 | - test-6 | |
| 74 | - test-7 | |
| 68 | - behavior | |
| 69 | - std_Debug | |
| 70 | - std_ReleaseSafe | |
| 71 | - std_ReleaseFast | |
| 72 | - std_ReleaseSmall | |
| 73 | - misc | |
| 74 | - cases | |
| 75 | 75 | image: ziglang/static-base:llvm14-aarch64-3 |
| 76 | 76 | environment: |
| 77 | 77 | SRHT_OAUTH_TOKEN: |
ci/drone/linux_script_build+8-6| ... | ... | @@ -42,7 +42,6 @@ git fetch --tags |
| 42 | 42 | mkdir build |
| 43 | 43 | cd build |
| 44 | 44 | cmake .. \ |
| 45 | -DCMAKE_INSTALL_PREFIX="$DISTDIR" \ | |
| 46 | 45 | -DCMAKE_PREFIX_PATH="$PREFIX" \ |
| 47 | 46 | -DCMAKE_BUILD_TYPE=Release \ |
| 48 | 47 | -DCMAKE_AR="$PREFIX/bin/ar" \ |
| ... | ... | @@ -58,8 +57,11 @@ unset CC |
| 58 | 57 | unset CXX |
| 59 | 58 | samu install |
| 60 | 59 | |
| 61 | # Here we rebuild Zig but this time using the Zig binary we just now produced to | |
| 62 | # build zig1.o rather than relying on the one built with stage0. See | |
| 63 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 64 | cmake .. -DZIG_EXECUTABLE="$DISTDIR/bin/zig" | |
| 65 | samu install | |
| 60 | stage2/bin/zig build \ | |
| 61 | --prefix "$DISTDIR" \ | |
| 62 | --search-prefix "$PREFIX" \ | |
| 63 | -Dstatic-llvm \ | |
| 64 | -Drelease \ | |
| 65 | -Dstrip \ | |
| 66 | -Dtarget="$TARGET" \ | |
| 67 | -Denable-stage1 |
ci/drone/linux_script_test deleted-51| ... | ... | @@ -1,51 +0,0 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | BUILD_FLAGS="-Dskip-non-native" | |
| 6 | ||
| 7 | case "$1" in | |
| 8 | 1) | |
| 9 | ./build/zig build $BUILD_FLAGS test-behavior | |
| 10 | ./build/zig build $BUILD_FLAGS test-compiler-rt | |
| 11 | ./build/zig build $BUILD_FLAGS test-fmt | |
| 12 | ./build/zig build $BUILD_FLAGS docs | |
| 13 | ;; | |
| 14 | 2) | |
| 15 | # Debug | |
| 16 | ./build/zig build $BUILD_FLAGS test-std -Dskip-release-safe -Dskip-release-fast -Dskip-release-small | |
| 17 | ;; | |
| 18 | 3) | |
| 19 | # ReleaseSafe | |
| 20 | ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small -Dskip-non-native -Dskip-single-threaded | |
| 21 | ;; | |
| 22 | 4) | |
| 23 | # ReleaseFast | |
| 24 | ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small -Dskip-non-native -Dskip-single-threaded | |
| 25 | ;; | |
| 26 | 5) | |
| 27 | # ReleaseSmall | |
| 28 | ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast | |
| 29 | ;; | |
| 30 | 6) | |
| 31 | ./build/zig build $BUILD_FLAGS test-universal-libc | |
| 32 | ./build/zig build $BUILD_FLAGS test-compare-output | |
| 33 | ./build/zig build $BUILD_FLAGS test-standalone -Dskip-release-safe | |
| 34 | ./build/zig build $BUILD_FLAGS test-stack-traces | |
| 35 | ./build/zig build $BUILD_FLAGS test-cli | |
| 36 | ./build/zig build $BUILD_FLAGS test-asm-link | |
| 37 | ./build/zig build $BUILD_FLAGS test-translate-c | |
| 38 | ;; | |
| 39 | 7) | |
| 40 | ./build/zig build $BUILD_FLAGS # test building self-hosted without LLVM | |
| 41 | ./build/zig build $BUILD_FLAGS test-cases | |
| 42 | ;; | |
| 43 | '') | |
| 44 | echo "error: expecting test group argument" | |
| 45 | exit 1 | |
| 46 | ;; | |
| 47 | *) | |
| 48 | echo "error: unknown test group: $1" | |
| 49 | exit 1 | |
| 50 | ;; | |
| 51 | esac |
ci/drone/test_linux_behavior created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build test-behavior -Dskip-non-native | |
| 6 | ./build/zig build test-compiler-rt -Dskip-non-native | |
| 7 | ./build/zig build test-fmt | |
| 8 | ./build/zig build docs |
ci/drone/test_linux_cases created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build -Dskip-non-native # test building self-hosted without LLVM | |
| 6 | ./build/zig build -Dskip-non-native test-cases |
ci/drone/test_linux_misc created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build test-universal-libc -Dskip-non-native | |
| 6 | ./build/zig build test-compare-output -Dskip-non-native | |
| 7 | ./build/zig build test-standalone -Dskip-non-native -Dskip-release-safe | |
| 8 | ./build/zig build test-stack-traces -Dskip-non-native | |
| 9 | ./build/zig build test-cli -Dskip-non-native | |
| 10 | ./build/zig build test-asm-link -Dskip-non-native | |
| 11 | ./build/zig build test-translate-c -Dskip-non-native |
ci/drone/test_linux_std_Debug created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build test-std -Dskip-release-safe -Dskip-release-fast -Dskip-release-small -Dskip-non-native |
ci/drone/test_linux_std_ReleaseFast created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small -Dskip-non-native -Dskip-single-threaded |
ci/drone/test_linux_std_ReleaseSafe created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small -Dskip-non-native -Dskip-single-threaded |
ci/drone/test_linux_std_ReleaseSmall created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/drone/linux_script_base | |
| 4 | ||
| 5 | ./build/zig build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast -Dskip-non-native |
ci/srht/freebsd_script+33-18| ... | ... | @@ -7,7 +7,9 @@ sudo pkg update -fq |
| 7 | 7 | sudo pkg install -y cmake py39-s3cmd wget curl jq samurai |
| 8 | 8 | |
| 9 | 9 | ZIGDIR="$(pwd)" |
| 10 | CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.10.0-dev.2931+bdf3fa12f" | |
| 10 | TARGET="x86_64-freebsd-gnu" | |
| 11 | MCPU="baseline" | |
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.3524+74673b7f6" | |
| 11 | 13 | PREFIX="$HOME/$CACHE_BASENAME" |
| 12 | 14 | |
| 13 | 15 | cd $HOME |
| ... | ... | @@ -30,33 +32,46 @@ export TERM=dumb |
| 30 | 32 | mkdir build |
| 31 | 33 | cd build |
| 32 | 34 | cmake .. \ |
| 33 | -DCMAKE_BUILD_TYPE=Release \ | |
| 34 | -DCMAKE_PREFIX_PATH=$PREFIX \ | |
| 35 | "-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \ | |
| 36 | -DZIG_STATIC=ON \ | |
| 37 | -DZIG_TARGET_TRIPLE=x86_64-freebsd-gnu \ | |
| 38 | -GNinja | |
| 35 | -DCMAKE_BUILD_TYPE=Release \ | |
| 36 | -DCMAKE_PREFIX_PATH=$PREFIX \ | |
| 37 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 38 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 39 | -DZIG_STATIC=ON \ | |
| 40 | -GNinja | |
| 39 | 41 | samu install |
| 40 | 42 | |
| 41 | # TODO ld.lld: error: undefined symbol: main | |
| 42 | # >>> referenced by crt1_c.c:75 (/usr/src/lib/csu/amd64/crt1_c.c:75) | |
| 43 | # >>> /usr/lib/crt1.o:(_start) | |
| 44 | #release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test | |
| 43 | # TODO: eliminate this workaround. Without this, zig does not end up passing | |
| 44 | # -isystem /usr/include when building libc++, resulting in #include <sys/endian.h> | |
| 45 | # "file not found" errors. | |
| 46 | stage2/bin/zig libc >libc.txt | |
| 47 | ||
| 48 | ZIG_LIBC=libc.txt stage2/bin/zig build \ | |
| 49 | --prefix stage3-release \ | |
| 50 | --search-prefix "$PREFIX" \ | |
| 51 | -Dstatic-llvm \ | |
| 52 | -Drelease \ | |
| 53 | -Dstrip \ | |
| 54 | -Dtarget="$TARGET" \ | |
| 55 | -Denable-stage1 | |
| 45 | 56 | |
| 46 | 57 | # Here we skip some tests to save time. |
| 47 | release/bin/zig build test -Dskip-stage1 -Dskip-non-native | |
| 58 | stage3-release/bin/zig build test docs \ | |
| 59 | -Dstatic-llvm \ | |
| 60 | --search-prefix "$PREFIX" \ | |
| 61 | -Dskip-stage1 \ | |
| 62 | -Dskip-non-native | |
| 48 | 63 | |
| 49 | 64 | if [ -f ~/.s3cfg ]; then |
| 50 | mv ../LICENSE release/ | |
| 51 | mv ../zig-cache/langref.html release/ | |
| 52 | mv release/bin/zig release/ | |
| 53 | rmdir release/bin | |
| 65 | mv ../LICENSE stage3-release/ | |
| 66 | mv ../zig-cache/langref.html stage3-release/ | |
| 67 | mv stage3-release/bin/zig stage3-release/ | |
| 68 | rmdir stage3-release/bin | |
| 54 | 69 | |
| 55 | 70 | GITBRANCH=$(basename $GITHUB_REF) |
| 56 | VERSION=$(release/zig version) | |
| 71 | VERSION=$(stage3-release/zig version) | |
| 57 | 72 | DIRNAME="zig-freebsd-x86_64-$VERSION" |
| 58 | 73 | TARBALL="$DIRNAME.tar.xz" |
| 59 | mv release "$DIRNAME" | |
| 74 | mv stage3-release "$DIRNAME" | |
| 60 | 75 | tar cfJ "$TARBALL" "$DIRNAME" |
| 61 | 76 | |
| 62 | 77 | s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/ |
ci/zinc/drone.yml+11-5| ... | ... | @@ -9,20 +9,26 @@ workspace: |
| 9 | 9 | path: /workspace |
| 10 | 10 | |
| 11 | 11 | steps: |
| 12 | - name: test | |
| 13 | image: ci/debian-amd64:11.1-6 | |
| 12 | - name: test_stage3_debug | |
| 13 | image: ci/debian-amd64:11.1-7 | |
| 14 | 14 | commands: |
| 15 | - ./ci/zinc/linux_test.sh | |
| 15 | - ./ci/zinc/linux_test_stage3_debug.sh | |
| 16 | ||
| 17 | - name: test_stage3_release | |
| 18 | image: ci/debian-amd64:11.1-7 | |
| 19 | commands: | |
| 20 | - ./ci/zinc/linux_test_stage3_release.sh | |
| 16 | 21 | |
| 17 | 22 | - name: package |
| 18 | 23 | depends_on: |
| 19 | - test | |
| 24 | - test_stage3_debug | |
| 25 | - test_stage3_release | |
| 20 | 26 | when: |
| 21 | 27 | branch: |
| 22 | 28 | - master |
| 23 | 29 | event: |
| 24 | 30 | - push |
| 25 | image: ci/debian-amd64:11.1-6 | |
| 31 | image: ci/debian-amd64:11.1-7 | |
| 26 | 32 | environment: |
| 27 | 33 | AWS_ACCESS_KEY_ID: |
| 28 | 34 | from_secret: AWS_ACCESS_KEY_ID |
ci/zinc/linux_base.sh+4| ... | ... | @@ -25,3 +25,7 @@ DEBUG_STAGING="$WORKSPACE/_debug/staging" |
| 25 | 25 | RELEASE_STAGING="$WORKSPACE/_release/staging" |
| 26 | 26 | |
| 27 | 27 | export PATH=$DEPS_LOCAL/bin:$PATH |
| 28 | ||
| 29 | # Make the `zig version` number consistent. | |
| 30 | # This will affect the cmake commands that follow. | |
| 31 | git config core.abbrev 9 |
ci/zinc/linux_package.sh-3| ... | ... | @@ -2,9 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | . ./ci/zinc/linux_base.sh |
| 4 | 4 | |
| 5 | cp LICENSE $RELEASE_STAGING/ | |
| 6 | cp zig-cache/langref.html $RELEASE_STAGING/docs/ | |
| 7 | ||
| 8 | 5 | # Remove the unnecessary bin dir in $prefix/bin/zig |
| 9 | 6 | mv $RELEASE_STAGING/bin/zig $RELEASE_STAGING/ |
| 10 | 7 | rmdir $RELEASE_STAGING/bin |
ci/zinc/linux_test.sh deleted-93| ... | ... | @@ -1,93 +0,0 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | OLD_ZIG="$DEPS_LOCAL/bin/zig" | |
| 6 | TARGET="${ARCH}-linux-musl" | |
| 7 | MCPU="baseline" | |
| 8 | ||
| 9 | # Make the `zig version` number consistent. | |
| 10 | # This will affect the cmake command below. | |
| 11 | git config core.abbrev 9 | |
| 12 | ||
| 13 | echo "building debug zig with zig version $($OLD_ZIG version)" | |
| 14 | ||
| 15 | export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 16 | export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 17 | ||
| 18 | mkdir _debug | |
| 19 | cd _debug | |
| 20 | cmake .. \ | |
| 21 | -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ | |
| 22 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 23 | -DCMAKE_BUILD_TYPE=Debug \ | |
| 24 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 25 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 26 | -DZIG_STATIC=ON \ | |
| 27 | -GNinja | |
| 28 | ||
| 29 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | |
| 30 | # so that installation and testing do not get affected by them. | |
| 31 | unset CC | |
| 32 | unset CXX | |
| 33 | ||
| 34 | ninja install | |
| 35 | ||
| 36 | STAGE1_ZIG="$DEBUG_STAGING/bin/zig" | |
| 37 | ||
| 38 | # Here we rebuild zig but this time using the Zig binary we just now produced to | |
| 39 | # build zig1.o rather than relying on the one built with stage0. See | |
| 40 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 41 | cmake .. -DZIG_EXECUTABLE="$STAGE1_ZIG" | |
| 42 | ninja install | |
| 43 | ||
| 44 | cd $WORKSPACE | |
| 45 | ||
| 46 | echo "Looking for non-conforming code formatting..." | |
| 47 | echo "Formatting errors can be fixed by running 'zig fmt' on the files printed here." | |
| 48 | $STAGE1_ZIG fmt --check . --exclude test/cases/ | |
| 49 | ||
| 50 | $STAGE1_ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" | |
| 51 | stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" | |
| 52 | stage3/bin/zig build # test building self-hosted without LLVM | |
| 53 | stage3/bin/zig build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm | |
| 54 | ||
| 55 | stage3/bin/zig build test-compiler-rt -fqemu -fwasmtime -Denable-llvm | |
| 56 | stage3/bin/zig build test-behavior -fqemu -fwasmtime -Denable-llvm | |
| 57 | stage3/bin/zig build test-std -fqemu -fwasmtime -Denable-llvm | |
| 58 | stage3/bin/zig build test-universal-libc -fqemu -fwasmtime -Denable-llvm | |
| 59 | stage3/bin/zig build test-compare-output -fqemu -fwasmtime -Denable-llvm | |
| 60 | stage3/bin/zig build test-asm-link -fqemu -fwasmtime -Denable-llvm | |
| 61 | stage3/bin/zig build test-fmt -fqemu -fwasmtime -Denable-llvm | |
| 62 | stage3/bin/zig build test-translate-c -fqemu -fwasmtime -Denable-llvm | |
| 63 | stage3/bin/zig build test-run-translated-c -fqemu -fwasmtime -Denable-llvm | |
| 64 | stage3/bin/zig build test-standalone -fqemu -fwasmtime -Denable-llvm | |
| 65 | stage3/bin/zig build test-cli -fqemu -fwasmtime -Denable-llvm | |
| 66 | stage3/bin/zig build test-cases -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" | |
| 67 | stage3/bin/zig build test-link -fqemu -fwasmtime -Denable-llvm | |
| 68 | ||
| 69 | $STAGE1_ZIG build test-stack-traces -fqemu -fwasmtime | |
| 70 | $STAGE1_ZIG build docs -fqemu -fwasmtime | |
| 71 | ||
| 72 | # Produce the experimental std lib documentation. | |
| 73 | mkdir -p "$RELEASE_STAGING/docs/std" | |
| 74 | stage3/bin/zig test lib/std/std.zig \ | |
| 75 | --zig-lib-dir lib \ | |
| 76 | -femit-docs=$RELEASE_STAGING/docs/std \ | |
| 77 | -fno-emit-bin | |
| 78 | ||
| 79 | # Look for HTML errors. | |
| 80 | tidy --drop-empty-elements no -qe zig-cache/langref.html | |
| 81 | ||
| 82 | # Build release zig. | |
| 83 | stage3/bin/zig build \ | |
| 84 | --prefix "$RELEASE_STAGING" \ | |
| 85 | --search-prefix "$DEPS_LOCAL" \ | |
| 86 | -Dstatic-llvm \ | |
| 87 | -Drelease \ | |
| 88 | -Dstrip \ | |
| 89 | -Dtarget="$TARGET" \ | |
| 90 | -Dstage1 | |
| 91 | ||
| 92 | # Explicit exit helps show last command duration. | |
| 93 | exit |
ci/zinc/linux_test_stage3_debug.sh created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | OLD_ZIG="$DEPS_LOCAL/bin/zig" | |
| 6 | TARGET="${ARCH}-linux-musl" | |
| 7 | MCPU="baseline" | |
| 8 | ||
| 9 | echo "building stage3-debug with zig version $($OLD_ZIG version)" | |
| 10 | ||
| 11 | # Override the cache directories so that we don't clobber with the release | |
| 12 | # testing script which is running concurrently and in the same directory. | |
| 13 | # Normally we want processes to cooperate, but in this case we want them isolated. | |
| 14 | export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-cache-local-debug" | |
| 15 | export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-cache-global-debug" | |
| 16 | ||
| 17 | export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 18 | export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 19 | ||
| 20 | mkdir build-debug | |
| 21 | cd build-debug | |
| 22 | cmake .. \ | |
| 23 | -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ | |
| 24 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 25 | -DCMAKE_BUILD_TYPE=Debug \ | |
| 26 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 27 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 28 | -DZIG_STATIC=ON \ | |
| 29 | -GNinja | |
| 30 | ||
| 31 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | |
| 32 | # so that installation and testing do not get affected by them. | |
| 33 | unset CC | |
| 34 | unset CXX | |
| 35 | ||
| 36 | ninja install | |
| 37 | ||
| 38 | cd $WORKSPACE | |
| 39 | ||
| 40 | "$DEBUG_STAGING/bin/zig" build -p stage3 -Denable-stage1 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" | |
| 41 | ||
| 42 | # simultaneously test building self-hosted without LLVM and with 32-bit arm | |
| 43 | stage3/bin/zig build -Dtarget=arm-linux-musleabihf | |
| 44 | ||
| 45 | echo "Looking for non-conforming code formatting..." | |
| 46 | stage3/bin/zig fmt --check . \ | |
| 47 | --exclude test/cases/ \ | |
| 48 | --exclude build-debug \ | |
| 49 | --exclude build-release \ | |
| 50 | --exclude "$ZIG_LOCAL_CACHE_DIR" \ | |
| 51 | --exclude "$ZIG_GLOBAL_CACHE_DIR" | |
| 52 | ||
| 53 | stage3/bin/zig build test \ | |
| 54 | -fqemu \ | |
| 55 | -fwasmtime \ | |
| 56 | -Dstatic-llvm \ | |
| 57 | -Dtarget=native-native-musl \ | |
| 58 | --search-prefix "$DEPS_LOCAL" | |
| 59 | ||
| 60 | # Explicit exit helps show last command duration. | |
| 61 | exit |
ci/zinc/linux_test_stage3_release.sh created+78| ... | ... | @@ -0,0 +1,78 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | OLD_ZIG="$DEPS_LOCAL/bin/zig" | |
| 6 | TARGET="${ARCH}-linux-musl" | |
| 7 | MCPU="baseline" | |
| 8 | ||
| 9 | echo "building stage3-release with zig version $($OLD_ZIG version)" | |
| 10 | ||
| 11 | export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 12 | export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 13 | ||
| 14 | mkdir build-release | |
| 15 | cd build-release | |
| 16 | STAGE2_PREFIX="$(pwd)/stage2" | |
| 17 | cmake .. \ | |
| 18 | -DCMAKE_INSTALL_PREFIX="$STAGE2_PREFIX" \ | |
| 19 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 20 | -DCMAKE_BUILD_TYPE=Release \ | |
| 21 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 22 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 23 | -DZIG_STATIC=ON \ | |
| 24 | -GNinja | |
| 25 | ||
| 26 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | |
| 27 | # so that installation and testing do not get affected by them. | |
| 28 | unset CC | |
| 29 | unset CXX | |
| 30 | ||
| 31 | ninja install | |
| 32 | ||
| 33 | # Here we rebuild zig but this time using the Zig binary we just now produced to | |
| 34 | # build zig1.o rather than relying on the one built with stage0. See | |
| 35 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 36 | cmake .. -DZIG_EXECUTABLE="$STAGE2_PREFIX/bin/zig" | |
| 37 | ninja install | |
| 38 | ||
| 39 | # This is the binary we will distribute. We intentionally test this one in this | |
| 40 | # script. If any test failures occur, hopefully they also occur in the debug | |
| 41 | # version of this script for easier troubleshooting. This prevents distribution | |
| 42 | # of a Zig binary that passes tests in debug mode but has a miscompilation in | |
| 43 | # release mode. | |
| 44 | "$STAGE2_PREFIX/bin/zig" build \ | |
| 45 | --prefix "$RELEASE_STAGING" \ | |
| 46 | --search-prefix "$DEPS_LOCAL" \ | |
| 47 | -Dstatic-llvm \ | |
| 48 | -Drelease \ | |
| 49 | -Dstrip \ | |
| 50 | -Dtarget="$TARGET" \ | |
| 51 | -Denable-stage1 | |
| 52 | ||
| 53 | cd $WORKSPACE | |
| 54 | ||
| 55 | ZIG="$RELEASE_STAGING/bin/zig" | |
| 56 | ||
| 57 | $ZIG build test docs \ | |
| 58 | -fqemu \ | |
| 59 | -fwasmtime \ | |
| 60 | -Dstatic-llvm \ | |
| 61 | -Dtarget=native-native-musl \ | |
| 62 | --search-prefix "$DEPS_LOCAL" | |
| 63 | ||
| 64 | # Produce the experimental std lib documentation. | |
| 65 | mkdir -p "$RELEASE_STAGING/docs/std" | |
| 66 | $ZIG test lib/std/std.zig \ | |
| 67 | --zig-lib-dir lib \ | |
| 68 | -femit-docs=$RELEASE_STAGING/docs/std \ | |
| 69 | -fno-emit-bin | |
| 70 | ||
| 71 | cp LICENSE $RELEASE_STAGING/ | |
| 72 | cp zig-cache/langref.html $RELEASE_STAGING/docs/ | |
| 73 | ||
| 74 | # Look for HTML errors. | |
| 75 | tidy --drop-empty-elements no -qe $RELEASE_STAGING/docs/langref.html | |
| 76 | ||
| 77 | # Explicit exit helps show last command duration. | |
| 78 | exit |
doc/docgen.zig+31| ... | ... | @@ -285,6 +285,7 @@ const Code = struct { |
| 285 | 285 | link_objects: []const []const u8, |
| 286 | 286 | target_str: ?[]const u8, |
| 287 | 287 | link_libc: bool, |
| 288 | backend_stage1: bool, | |
| 288 | 289 | link_mode: ?std.builtin.LinkMode, |
| 289 | 290 | disable_cache: bool, |
| 290 | 291 | verbose_cimport: bool, |
| ... | ... | @@ -554,6 +555,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 554 | 555 | var link_mode: ?std.builtin.LinkMode = null; |
| 555 | 556 | var disable_cache = false; |
| 556 | 557 | var verbose_cimport = false; |
| 558 | var backend_stage1 = false; | |
| 557 | 559 | |
| 558 | 560 | const source_token = while (true) { |
| 559 | 561 | const content_tok = try eatToken(tokenizer, Token.Id.Content); |
| ... | ... | @@ -586,6 +588,8 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 586 | 588 | link_libc = true; |
| 587 | 589 | } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) { |
| 588 | 590 | link_mode = .Dynamic; |
| 591 | } else if (mem.eql(u8, end_tag_name, "backend_stage1")) { | |
| 592 | backend_stage1 = true; | |
| 589 | 593 | } else if (mem.eql(u8, end_tag_name, "code_end")) { |
| 590 | 594 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 591 | 595 | break content_tok; |
| ... | ... | @@ -609,6 +613,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 609 | 613 | .link_objects = link_objects.toOwnedSlice(), |
| 610 | 614 | .target_str = target_str, |
| 611 | 615 | .link_libc = link_libc, |
| 616 | .backend_stage1 = backend_stage1, | |
| 612 | 617 | .link_mode = link_mode, |
| 613 | 618 | .disable_cache = disable_cache, |
| 614 | 619 | .verbose_cimport = verbose_cimport, |
| ... | ... | @@ -1187,6 +1192,9 @@ fn printShell(out: anytype, shell_content: []const u8) !void { |
| 1187 | 1192 | try out.writeAll("</samp></pre></figure>"); |
| 1188 | 1193 | } |
| 1189 | 1194 | |
| 1195 | // Override this to skip to later tests | |
| 1196 | const debug_start_line = 0; | |
| 1197 | ||
| 1190 | 1198 | fn genHtml( |
| 1191 | 1199 | allocator: Allocator, |
| 1192 | 1200 | tokenizer: *Tokenizer, |
| ... | ... | @@ -1266,6 +1274,13 @@ fn genHtml( |
| 1266 | 1274 | continue; |
| 1267 | 1275 | } |
| 1268 | 1276 | |
| 1277 | if (debug_start_line > 0) { | |
| 1278 | const loc = tokenizer.getTokenLocation(code.source_token); | |
| 1279 | if (debug_start_line > loc.line) { | |
| 1280 | continue; | |
| 1281 | } | |
| 1282 | } | |
| 1283 | ||
| 1269 | 1284 | const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end]; |
| 1270 | 1285 | const trimmed_raw_source = mem.trim(u8, raw_source, " \n"); |
| 1271 | 1286 | const tmp_source_file_name = try fs.path.join( |
| ... | ... | @@ -1311,6 +1326,10 @@ fn genHtml( |
| 1311 | 1326 | try build_args.append("-lc"); |
| 1312 | 1327 | try shell_out.print("-lc ", .{}); |
| 1313 | 1328 | } |
| 1329 | if (code.backend_stage1) { | |
| 1330 | try build_args.append("-fstage1"); | |
| 1331 | try shell_out.print("-fstage1", .{}); | |
| 1332 | } | |
| 1314 | 1333 | const target = try std.zig.CrossTarget.parse(.{ |
| 1315 | 1334 | .arch_os_abi = code.target_str orelse "native", |
| 1316 | 1335 | }); |
| ... | ... | @@ -1443,6 +1462,10 @@ fn genHtml( |
| 1443 | 1462 | try test_args.append("-lc"); |
| 1444 | 1463 | try shell_out.print("-lc ", .{}); |
| 1445 | 1464 | } |
| 1465 | if (code.backend_stage1) { | |
| 1466 | try test_args.append("-fstage1"); | |
| 1467 | try shell_out.print("-fstage1", .{}); | |
| 1468 | } | |
| 1446 | 1469 | if (code.target_str) |triple| { |
| 1447 | 1470 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1448 | 1471 | try shell_out.print("-target {s} ", .{triple}); |
| ... | ... | @@ -1490,6 +1513,14 @@ fn genHtml( |
| 1490 | 1513 | try shell_out.print("-O {s} ", .{@tagName(code.mode)}); |
| 1491 | 1514 | }, |
| 1492 | 1515 | } |
| 1516 | if (code.link_libc) { | |
| 1517 | try test_args.append("-lc"); | |
| 1518 | try shell_out.print("-lc ", .{}); | |
| 1519 | } | |
| 1520 | if (code.backend_stage1) { | |
| 1521 | try test_args.append("-fstage1"); | |
| 1522 | try shell_out.print("-fstage1", .{}); | |
| 1523 | } | |
| 1493 | 1524 | const result = try ChildProcess.exec(.{ |
| 1494 | 1525 | .allocator = allocator, |
| 1495 | 1526 | .argv = test_args.items, |
doc/langref.html.in+69-109| ... | ... | @@ -1188,6 +1188,7 @@ test "this will be skipped" { |
| 1188 | 1188 | (The evented IO mode is enabled using the <kbd>--test-evented-io</kbd> command line parameter.) |
| 1189 | 1189 | </p> |
| 1190 | 1190 | {#code_begin|test|async_skip#} |
| 1191 | {#backend_stage1#} | |
| 1191 | 1192 | const std = @import("std"); |
| 1192 | 1193 | |
| 1193 | 1194 | test "async skip test" { |
| ... | ... | @@ -2768,7 +2769,7 @@ test "comptime @intToPtr" { |
| 2768 | 2769 | } |
| 2769 | 2770 | } |
| 2770 | 2771 | {#code_end#} |
| 2771 | {#see_also|Optional Pointers|@intToPtr|@ptrToInt|C Pointers|Pointers to Zero Bit Types#} | |
| 2772 | {#see_also|Optional Pointers|@intToPtr|@ptrToInt|C Pointers#} | |
| 2772 | 2773 | {#header_open|volatile#} |
| 2773 | 2774 | <p>Loads and stores are assumed to not have side effects. If a given load or store |
| 2774 | 2775 | should have side effects, such as Memory Mapped Input/Output (MMIO), use {#syntax#}volatile{#endsyntax#}. |
| ... | ... | @@ -2862,19 +2863,22 @@ var foo: u8 align(4) = 100; |
| 2862 | 2863 | test "global variable alignment" { |
| 2863 | 2864 | try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4); |
| 2864 | 2865 | try expect(@TypeOf(&foo) == *align(4) u8); |
| 2865 | const as_pointer_to_array: *[1]u8 = &foo; | |
| 2866 | const as_slice: []u8 = as_pointer_to_array; | |
| 2867 | try expect(@TypeOf(as_slice) == []align(4) u8); | |
| 2866 | const as_pointer_to_array: *align(4) [1]u8 = &foo; | |
| 2867 | const as_slice: []align(4) u8 = as_pointer_to_array; | |
| 2868 | const as_unaligned_slice: []u8 = as_slice; | |
| 2869 | try expect(as_unaligned_slice[0] == 100); | |
| 2868 | 2870 | } |
| 2869 | 2871 | |
| 2870 | fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; } | |
| 2872 | fn derp() align(@sizeOf(usize) * 2) i32 { | |
| 2873 | return 1234; | |
| 2874 | } | |
| 2871 | 2875 | fn noop1() align(1) void {} |
| 2872 | 2876 | fn noop4() align(4) void {} |
| 2873 | 2877 | |
| 2874 | 2878 | test "function alignment" { |
| 2875 | 2879 | try expect(derp() == 1234); |
| 2876 | try expect(@TypeOf(noop1) == fn() align(1) void); | |
| 2877 | try expect(@TypeOf(noop4) == fn() align(4) void); | |
| 2880 | try expect(@TypeOf(noop1) == fn () align(1) void); | |
| 2881 | try expect(@TypeOf(noop4) == fn () align(4) void); | |
| 2878 | 2882 | noop1(); |
| 2879 | 2883 | noop4(); |
| 2880 | 2884 | } |
| ... | ... | @@ -3336,6 +3340,7 @@ fn doTheTest() !void { |
| 3336 | 3340 | Zig allows the address to be taken of a non-byte-aligned field: |
| 3337 | 3341 | </p> |
| 3338 | 3342 | {#code_begin|test|pointer_to_non-byte_aligned_field#} |
| 3343 | {#backend_stage1#} | |
| 3339 | 3344 | const std = @import("std"); |
| 3340 | 3345 | const expect = std.testing.expect; |
| 3341 | 3346 | |
| ... | ... | @@ -3391,7 +3396,8 @@ fn bar(x: *const u3) u3 { |
| 3391 | 3396 | <p> |
| 3392 | 3397 | Pointers to non-ABI-aligned fields share the same address as the other fields within their host integer: |
| 3393 | 3398 | </p> |
| 3394 | {#code_begin|test|pointer_to_non-bit_aligned_field#} | |
| 3399 | {#code_begin|test|packed_struct_field_addrs#} | |
| 3400 | {#backend_stage1#} | |
| 3395 | 3401 | const std = @import("std"); |
| 3396 | 3402 | const expect = std.testing.expect; |
| 3397 | 3403 | |
| ... | ... | @@ -3407,7 +3413,7 @@ var bit_field = BitField{ |
| 3407 | 3413 | .c = 3, |
| 3408 | 3414 | }; |
| 3409 | 3415 | |
| 3410 | test "pointer to non-bit-aligned field" { | |
| 3416 | test "pointers of sub-byte-aligned fields share addresses" { | |
| 3411 | 3417 | try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.b)); |
| 3412 | 3418 | try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.c)); |
| 3413 | 3419 | } |
| ... | ... | @@ -3438,20 +3444,22 @@ test "pointer to non-bit-aligned field" { |
| 3438 | 3444 | } |
| 3439 | 3445 | {#code_end#} |
| 3440 | 3446 | <p> |
| 3441 | Packed structs have 1-byte alignment. However if you have an overaligned pointer to a packed struct, | |
| 3442 | Zig should correctly understand the alignment of fields. However there is | |
| 3443 | <a href="https://github.com/ziglang/zig/issues/1994">a bug</a>: | |
| 3447 | Packed structs have the same alignment as their backing integer, however, overaligned | |
| 3448 | pointers to packed structs can override this: | |
| 3444 | 3449 | </p> |
| 3445 | {#code_begin|test_err|expected type '*u32', found '*align(1) u32'#} | |
| 3450 | {#code_begin|test|overaligned_packed_struct#} | |
| 3451 | const std = @import("std"); | |
| 3452 | const expect = std.testing.expect; | |
| 3453 | ||
| 3446 | 3454 | const S = packed struct { |
| 3447 | 3455 | a: u32, |
| 3448 | 3456 | b: u32, |
| 3449 | 3457 | }; |
| 3450 | 3458 | test "overaligned pointer to packed struct" { |
| 3451 | var foo: S align(4) = undefined; | |
| 3459 | var foo: S align(4) = .{ .a = 1, .b = 2 }; | |
| 3452 | 3460 | const ptr: *align(4) S = &foo; |
| 3453 | 3461 | const ptr_to_b: *u32 = &ptr.b; |
| 3454 | _ = ptr_to_b; | |
| 3462 | try expect(ptr_to_b.* == 2); | |
| 3455 | 3463 | } |
| 3456 | 3464 | {#code_end#} |
| 3457 | 3465 | <p>When this bug is fixed, the above test in the documentation will unexpectedly pass, which will |
| ... | ... | @@ -3698,7 +3706,7 @@ test "@tagName" { |
| 3698 | 3706 | <p> |
| 3699 | 3707 | By default, enums are not guaranteed to be compatible with the C ABI: |
| 3700 | 3708 | </p> |
| 3701 | {#code_begin|obj_err|parameter of type 'Foo' not allowed in function with calling convention 'C'#} | |
| 3709 | {#code_begin|obj_err|parameter of type 'test.Foo' not allowed in function with calling convention 'C'#} | |
| 3702 | 3710 | const Foo = enum { a, b, c }; |
| 3703 | 3711 | export fn entry(foo: Foo) void { _ = foo; } |
| 3704 | 3712 | {#code_end#} |
| ... | ... | @@ -4004,7 +4012,7 @@ fn makeNumber() Number { |
| 4004 | 4012 | This is typically used for type safety when interacting with C code that does not expose struct details. |
| 4005 | 4013 | Example: |
| 4006 | 4014 | </p> |
| 4007 | {#code_begin|test_err|expected type '*Derp', found '*Wat'#} | |
| 4015 | {#code_begin|test_err|expected type '*test.Derp', found '*test.Wat'#} | |
| 4008 | 4016 | const Derp = opaque {}; |
| 4009 | 4017 | const Wat = opaque {}; |
| 4010 | 4018 | |
| ... | ... | @@ -4203,7 +4211,7 @@ test "switch on tagged union" { |
| 4203 | 4211 | When a {#syntax#}switch{#endsyntax#} expression does not have an {#syntax#}else{#endsyntax#} clause, |
| 4204 | 4212 | it must exhaustively list all the possible values. Failure to do so is a compile error: |
| 4205 | 4213 | </p> |
| 4206 | {#code_begin|test_err|not handled in switch#} | |
| 4214 | {#code_begin|test_err|unhandled enumeration value#} | |
| 4207 | 4215 | const Color = enum { |
| 4208 | 4216 | auto, |
| 4209 | 4217 | off, |
| ... | ... | @@ -5026,17 +5034,9 @@ test "function" { |
| 5026 | 5034 | try expect(do_op(sub2, 5, 6) == -1); |
| 5027 | 5035 | } |
| 5028 | 5036 | {#code_end#} |
| 5029 | <p>Function values are like pointers:</p> | |
| 5030 | {#code_begin|obj#} | |
| 5031 | const assert = @import("std").debug.assert; | |
| 5032 | ||
| 5033 | comptime { | |
| 5034 | assert(@TypeOf(foo) == fn()void); | |
| 5035 | assert(@sizeOf(fn()void) == @sizeOf(?fn()void)); | |
| 5036 | } | |
| 5037 | ||
| 5038 | fn foo() void { } | |
| 5039 | {#code_end#} | |
| 5037 | <p>There is a difference between a function <em>body</em> and a function <em>pointer</em>. | |
| 5038 | Function bodies are {#link|comptime#}-only types while function {#link|Pointers#} may be | |
| 5039 | runtime-known.</p> | |
| 5040 | 5040 | {#header_open|Pass-by-value Parameters#} |
| 5041 | 5041 | <p> |
| 5042 | 5042 | Primitive types such as {#link|Integers#} and {#link|Floats#} passed as parameters |
| ... | ... | @@ -6123,10 +6123,11 @@ test "float widening" { |
| 6123 | 6123 | two choices about the coercion. |
| 6124 | 6124 | </p> |
| 6125 | 6125 | <ul> |
| 6126 | <li> Cast {#syntax#}54.0{#endsyntax#} to {#syntax#}comptime_int{#endsyntax#} resulting in {#syntax#}@as(comptime_int, 10){#endsyntax#}, which is casted to {#syntax#}@as(f32, 10){#endsyntax#}</li> | |
| 6127 | <li> Cast {#syntax#}5{#endsyntax#} to {#syntax#}comptime_float{#endsyntax#} resulting in {#syntax#}@as(comptime_float, 10.8){#endsyntax#}, which is casted to {#syntax#}@as(f32, 10.8){#endsyntax#}</li> | |
| 6126 | <li>Cast {#syntax#}54.0{#endsyntax#} to {#syntax#}comptime_int{#endsyntax#} resulting in {#syntax#}@as(comptime_int, 10){#endsyntax#}, which is casted to {#syntax#}@as(f32, 10){#endsyntax#}</li> | |
| 6127 | <li>Cast {#syntax#}5{#endsyntax#} to {#syntax#}comptime_float{#endsyntax#} resulting in {#syntax#}@as(comptime_float, 10.8){#endsyntax#}, which is casted to {#syntax#}@as(f32, 10.8){#endsyntax#}</li> | |
| 6128 | 6128 | </ul> |
| 6129 | 6129 | {#code_begin|test_err#} |
| 6130 | {#backend_stage1#} | |
| 6130 | 6131 | // Compile time coercion of float to int |
| 6131 | 6132 | test "implicit cast to comptime_int" { |
| 6132 | 6133 | var f: f32 = 54.0 / 5; |
| ... | ... | @@ -6302,19 +6303,6 @@ test "coercion between unions and enums" { |
| 6302 | 6303 | {#code_end#} |
| 6303 | 6304 | {#see_also|union|enum#} |
| 6304 | 6305 | {#header_close#} |
| 6305 | {#header_open|Type Coercion: Zero Bit Types#} | |
| 6306 | <p>{#link|Zero Bit Types#} may be coerced to single-item {#link|Pointers#}, | |
| 6307 | regardless of const.</p> | |
| 6308 | <p>TODO document the reasoning for this</p> | |
| 6309 | <p>TODO document whether vice versa should work and why</p> | |
| 6310 | {#code_begin|test|coerce_zero_bit_types#} | |
| 6311 | test "coercion of zero bit types" { | |
| 6312 | var x: void = {}; | |
| 6313 | var y: *void = x; | |
| 6314 | _ = y; | |
| 6315 | } | |
| 6316 | {#code_end#} | |
| 6317 | {#header_close#} | |
| 6318 | 6306 | {#header_open|Type Coercion: undefined#} |
| 6319 | 6307 | <p>{#link|undefined#} can be cast to any type.</p> |
| 6320 | 6308 | {#header_close#} |
| ... | ... | @@ -6467,7 +6455,6 @@ test "peer type resolution: *const T and ?*T" { |
| 6467 | 6455 | <li>An {#link|enum#} with only 1 tag.</li> |
| 6468 | 6456 | <li>A {#link|struct#} with all fields being zero bit types.</li> |
| 6469 | 6457 | <li>A {#link|union#} with only 1 field which is a zero bit type.</li> |
| 6470 | <li>{#link|Pointers to Zero Bit Types#} are themselves zero bit types.</li> | |
| 6471 | 6458 | </ul> |
| 6472 | 6459 | <p> |
| 6473 | 6460 | These types can only ever have one possible value, and thus |
| ... | ... | @@ -6527,7 +6514,7 @@ test "turn HashMap into a set with void" { |
| 6527 | 6514 | <p> |
| 6528 | 6515 | Expressions of type {#syntax#}void{#endsyntax#} are the only ones whose value can be ignored. For example: |
| 6529 | 6516 | </p> |
| 6530 | {#code_begin|test_err|expression value is ignored#} | |
| 6517 | {#code_begin|test_err|ignored#} | |
| 6531 | 6518 | test "ignoring expression value" { |
| 6532 | 6519 | foo(); |
| 6533 | 6520 | } |
| ... | ... | @@ -6553,37 +6540,6 @@ fn foo() i32 { |
| 6553 | 6540 | } |
| 6554 | 6541 | {#code_end#} |
| 6555 | 6542 | {#header_close#} |
| 6556 | ||
| 6557 | {#header_open|Pointers to Zero Bit Types#} | |
| 6558 | <p>Pointers to zero bit types also have zero bits. They always compare equal to each other:</p> | |
| 6559 | {#code_begin|test|pointers_to_zero_bits#} | |
| 6560 | const std = @import("std"); | |
| 6561 | const expect = std.testing.expect; | |
| 6562 | ||
| 6563 | test "pointer to empty struct" { | |
| 6564 | const Empty = struct {}; | |
| 6565 | var a = Empty{}; | |
| 6566 | var b = Empty{}; | |
| 6567 | var ptr_a = &a; | |
| 6568 | var ptr_b = &b; | |
| 6569 | comptime try expect(ptr_a == ptr_b); | |
| 6570 | } | |
| 6571 | {#code_end#} | |
| 6572 | <p>The type being pointed to can only ever be one value; therefore loads and stores are | |
| 6573 | never generated. {#link|ptrToInt#} and {#link|intToPtr#} are not allowed:</p> | |
| 6574 | {#code_begin|test_err#} | |
| 6575 | const Empty = struct {}; | |
| 6576 | ||
| 6577 | test "@ptrToInt for pointer to zero bit type" { | |
| 6578 | var a = Empty{}; | |
| 6579 | _ = @ptrToInt(&a); | |
| 6580 | } | |
| 6581 | ||
| 6582 | test "@intToPtr for pointer to zero bit type" { | |
| 6583 | _ = @intToPtr(*Empty, 0x1); | |
| 6584 | } | |
| 6585 | {#code_end#} | |
| 6586 | {#header_close#} | |
| 6587 | 6543 | {#header_close#} |
| 6588 | 6544 | |
| 6589 | 6545 | {#header_open|Result Location Semantics#} |
| ... | ... | @@ -6666,7 +6622,7 @@ fn gimmeTheBiggerInteger(a: u64, b: u64) u64 { |
| 6666 | 6622 | <p> |
| 6667 | 6623 | For example, if we were to introduce another function to the above snippet: |
| 6668 | 6624 | </p> |
| 6669 | {#code_begin|test_err|values of type 'type' must be comptime known#} | |
| 6625 | {#code_begin|test_err|unable to resolve comptime value#} | |
| 6670 | 6626 | fn max(comptime T: type, a: T, b: T) T { |
| 6671 | 6627 | return if (a > b) a else b; |
| 6672 | 6628 | } |
| ... | ... | @@ -6692,7 +6648,7 @@ fn foo(condition: bool) void { |
| 6692 | 6648 | <p> |
| 6693 | 6649 | For example: |
| 6694 | 6650 | </p> |
| 6695 | {#code_begin|test_err|operator not allowed for type 'bool'#} | |
| 6651 | {#code_begin|test_err|operator > not allowed for type 'bool'#} | |
| 6696 | 6652 | fn max(comptime T: type, a: T, b: T) T { |
| 6697 | 6653 | return if (a > b) a else b; |
| 6698 | 6654 | } |
| ... | ... | @@ -6837,7 +6793,7 @@ fn performFn(start_value: i32) i32 { |
| 6837 | 6793 | use a {#syntax#}comptime{#endsyntax#} expression to guarantee that the expression will be evaluated at compile-time. |
| 6838 | 6794 | If this cannot be accomplished, the compiler will emit an error. For example: |
| 6839 | 6795 | </p> |
| 6840 | {#code_begin|test_err|unable to evaluate constant expression#} | |
| 6796 | {#code_begin|test_err|comptime call of extern function#} | |
| 6841 | 6797 | extern fn exit() noreturn; |
| 6842 | 6798 | |
| 6843 | 6799 | test "foo" { |
| ... | ... | @@ -6889,7 +6845,7 @@ test "fibonacci" { |
| 6889 | 6845 | <p> |
| 6890 | 6846 | Imagine if we had forgotten the base case of the recursive function and tried to run the tests: |
| 6891 | 6847 | </p> |
| 6892 | {#code_begin|test_err|operation caused overflow#} | |
| 6848 | {#code_begin|test_err|overflow of integer type#} | |
| 6893 | 6849 | const expect = @import("std").testing.expect; |
| 6894 | 6850 | |
| 6895 | 6851 | fn fibonacci(index: u32) u32 { |
| ... | ... | @@ -6913,7 +6869,8 @@ test "fibonacci" { |
| 6913 | 6869 | But what would have happened if we used a signed integer? |
| 6914 | 6870 | </p> |
| 6915 | 6871 | {#code_begin|test_err|evaluation exceeded 1000 backwards branches#} |
| 6916 | const expect = @import("std").testing.expect; | |
| 6872 | {#backend_stage1#} | |
| 6873 | const assert = @import("std").debug.assert; | |
| 6917 | 6874 | |
| 6918 | 6875 | fn fibonacci(index: i32) i32 { |
| 6919 | 6876 | //if (index < 2) return index; |
| ... | ... | @@ -6922,7 +6879,7 @@ fn fibonacci(index: i32) i32 { |
| 6922 | 6879 | |
| 6923 | 6880 | test "fibonacci" { |
| 6924 | 6881 | comptime { |
| 6925 | try expect(fibonacci(7) == 13); | |
| 6882 | try assert(fibonacci(7) == 13); | |
| 6926 | 6883 | } |
| 6927 | 6884 | } |
| 6928 | 6885 | {#code_end#} |
| ... | ... | @@ -6935,8 +6892,8 @@ test "fibonacci" { |
| 6935 | 6892 | <p> |
| 6936 | 6893 | What if we fix the base case, but put the wrong value in the {#syntax#}expect{#endsyntax#} line? |
| 6937 | 6894 | </p> |
| 6938 | {#code_begin|test_err|test "fibonacci"... FAIL (TestUnexpectedResult)#} | |
| 6939 | const expect = @import("std").testing.expect; | |
| 6895 | {#code_begin|test_err|reached unreachable#} | |
| 6896 | const assert = @import("std").debug.assert; | |
| 6940 | 6897 | |
| 6941 | 6898 | fn fibonacci(index: i32) i32 { |
| 6942 | 6899 | if (index < 2) return index; |
| ... | ... | @@ -6945,16 +6902,10 @@ fn fibonacci(index: i32) i32 { |
| 6945 | 6902 | |
| 6946 | 6903 | test "fibonacci" { |
| 6947 | 6904 | comptime { |
| 6948 | try expect(fibonacci(7) == 99999); | |
| 6905 | try assert(fibonacci(7) == 99999); | |
| 6949 | 6906 | } |
| 6950 | 6907 | } |
| 6951 | 6908 | {#code_end#} |
| 6952 | <p> | |
| 6953 | What happened is Zig started interpreting the {#syntax#}expect{#endsyntax#} function with the | |
| 6954 | parameter {#syntax#}ok{#endsyntax#} set to {#syntax#}false{#endsyntax#}. When the interpreter hit | |
| 6955 | {#syntax#}@panic{#endsyntax#} it emitted a compile error because a panic during compile | |
| 6956 | causes a compile error if it is detected at compile-time. | |
| 6957 | </p> | |
| 6958 | 6909 | |
| 6959 | 6910 | <p> |
| 6960 | 6911 | At container level (outside of any function), all expressions are implicitly |
| ... | ... | @@ -7280,6 +7231,7 @@ pub fn main() void { |
| 7280 | 7231 | </p> |
| 7281 | 7232 | {#code_begin|exe#} |
| 7282 | 7233 | {#target_linux_x86_64#} |
| 7234 | {#backend_stage1#} | |
| 7283 | 7235 | pub fn main() noreturn { |
| 7284 | 7236 | const msg = "hello world\n"; |
| 7285 | 7237 | _ = syscall3(SYS_write, STDOUT_FILENO, @ptrToInt(msg), msg.len); |
| ... | ... | @@ -7497,6 +7449,7 @@ test "global assembly" { |
| 7497 | 7449 | or resumer (in the case of subsequent suspensions). |
| 7498 | 7450 | </p> |
| 7499 | 7451 | {#code_begin|test|suspend_no_resume#} |
| 7452 | {#backend_stage1#} | |
| 7500 | 7453 | const std = @import("std"); |
| 7501 | 7454 | const expect = std.testing.expect; |
| 7502 | 7455 | |
| ... | ... | @@ -7524,6 +7477,7 @@ fn func() void { |
| 7524 | 7477 | {#link|@frame#} provides access to the async function frame pointer. |
| 7525 | 7478 | </p> |
| 7526 | 7479 | {#code_begin|test|async_suspend_block#} |
| 7480 | {#backend_stage1#} | |
| 7527 | 7481 | const std = @import("std"); |
| 7528 | 7482 | const expect = std.testing.expect; |
| 7529 | 7483 | |
| ... | ... | @@ -7562,6 +7516,7 @@ fn testSuspendBlock() void { |
| 7562 | 7516 | never returns to its resumer and continues executing. |
| 7563 | 7517 | </p> |
| 7564 | 7518 | {#code_begin|test|resume_from_suspend#} |
| 7519 | {#backend_stage1#} | |
| 7565 | 7520 | const std = @import("std"); |
| 7566 | 7521 | const expect = std.testing.expect; |
| 7567 | 7522 | |
| ... | ... | @@ -7598,6 +7553,7 @@ fn testResumeFromSuspend(my_result: *i32) void { |
| 7598 | 7553 | and the return value of the async function would be lost. |
| 7599 | 7554 | </p> |
| 7600 | 7555 | {#code_begin|test|async_await#} |
| 7556 | {#backend_stage1#} | |
| 7601 | 7557 | const std = @import("std"); |
| 7602 | 7558 | const expect = std.testing.expect; |
| 7603 | 7559 | |
| ... | ... | @@ -7642,6 +7598,7 @@ fn func() void { |
| 7642 | 7598 | return value directly from the target function's frame. |
| 7643 | 7599 | </p> |
| 7644 | 7600 | {#code_begin|test|async_await_sequence#} |
| 7601 | {#backend_stage1#} | |
| 7645 | 7602 | const std = @import("std"); |
| 7646 | 7603 | const expect = std.testing.expect; |
| 7647 | 7604 | |
| ... | ... | @@ -7695,6 +7652,7 @@ fn seq(c: u8) void { |
| 7695 | 7652 | {#syntax#}async{#endsyntax#}/{#syntax#}await{#endsyntax#} usage: |
| 7696 | 7653 | </p> |
| 7697 | 7654 | {#code_begin|exe|async#} |
| 7655 | {#backend_stage1#} | |
| 7698 | 7656 | const std = @import("std"); |
| 7699 | 7657 | const Allocator = std.mem.Allocator; |
| 7700 | 7658 | |
| ... | ... | @@ -7773,6 +7731,7 @@ fn readFile(allocator: Allocator, filename: []const u8) ![]u8 { |
| 7773 | 7731 | observe the same behavior, with one tiny difference: |
| 7774 | 7732 | </p> |
| 7775 | 7733 | {#code_begin|exe|blocking#} |
| 7734 | {#backend_stage1#} | |
| 7776 | 7735 | const std = @import("std"); |
| 7777 | 7736 | const Allocator = std.mem.Allocator; |
| 7778 | 7737 | |
| ... | ... | @@ -7910,6 +7869,7 @@ comptime { |
| 7910 | 7869 | {#syntax#}await{#endsyntax#} will copy the result from {#syntax#}result_ptr{#endsyntax#}. |
| 7911 | 7870 | </p> |
| 7912 | 7871 | {#code_begin|test|async_struct_field_fn_pointer#} |
| 7872 | {#backend_stage1#} | |
| 7913 | 7873 | const std = @import("std"); |
| 7914 | 7874 | const expect = std.testing.expect; |
| 7915 | 7875 | |
| ... | ... | @@ -8677,6 +8637,7 @@ test "decl access by string" { |
| 8677 | 8637 | allows one to, for example, heap-allocate an async function frame: |
| 8678 | 8638 | </p> |
| 8679 | 8639 | {#code_begin|test|heap_allocated_frame#} |
| 8640 | {#backend_stage1#} | |
| 8680 | 8641 | const std = @import("std"); |
| 8681 | 8642 | |
| 8682 | 8643 | test "heap allocated frame" { |
| ... | ... | @@ -9423,12 +9384,6 @@ const std = @import("std"); |
| 9423 | 9384 | const expect = std.testing.expect; |
| 9424 | 9385 | |
| 9425 | 9386 | test "vector @reduce" { |
| 9426 | // This test regressed with LLVM 14: | |
| 9427 | // https://github.com/llvm/llvm-project/issues/55522 | |
| 9428 | // We'll skip this test unless the self-hosted compiler is being used. | |
| 9429 | // After LLVM 15 is released we can delete this line. | |
| 9430 | if (@import("builtin").zig_backend == .stage1) return; | |
| 9431 | ||
| 9432 | 9387 | const value = @Vector(4, i32){ 1, -1, 1, -1 }; |
| 9433 | 9388 | const result = value > @splat(4, @as(i32, 0)); |
| 9434 | 9389 | // result is { true, false, true, false }; |
| ... | ... | @@ -9938,7 +9893,7 @@ pub fn main() void { |
| 9938 | 9893 | {#header_close#} |
| 9939 | 9894 | {#header_open|Index out of Bounds#} |
| 9940 | 9895 | <p>At compile-time:</p> |
| 9941 | {#code_begin|test_err|index 5 outside array of size 5#} | |
| 9896 | {#code_begin|test_err|index 5 outside array of length 5#} | |
| 9942 | 9897 | comptime { |
| 9943 | 9898 | const array: [5]u8 = "hello".*; |
| 9944 | 9899 | const garbage = array[5]; |
| ... | ... | @@ -9959,9 +9914,9 @@ fn foo(x: []const u8) u8 { |
| 9959 | 9914 | {#header_close#} |
| 9960 | 9915 | {#header_open|Cast Negative Number to Unsigned Integer#} |
| 9961 | 9916 | <p>At compile-time:</p> |
| 9962 | {#code_begin|test_err|attempt to cast negative value to unsigned integer#} | |
| 9917 | {#code_begin|test_err|type 'u32' cannot represent integer value '-1'#} | |
| 9963 | 9918 | comptime { |
| 9964 | const value: i32 = -1; | |
| 9919 | var value: i32 = -1; | |
| 9965 | 9920 | const unsigned = @intCast(u32, value); |
| 9966 | 9921 | _ = unsigned; |
| 9967 | 9922 | } |
| ... | ... | @@ -9982,7 +9937,7 @@ pub fn main() void { |
| 9982 | 9937 | {#header_close#} |
| 9983 | 9938 | {#header_open|Cast Truncates Data#} |
| 9984 | 9939 | <p>At compile-time:</p> |
| 9985 | {#code_begin|test_err|cast from 'u16' to 'u8' truncates bits#} | |
| 9940 | {#code_begin|test_err|type 'u8' cannot represent integer value '300'#} | |
| 9986 | 9941 | comptime { |
| 9987 | 9942 | const spartan_count: u16 = 300; |
| 9988 | 9943 | const byte = @intCast(u8, spartan_count); |
| ... | ... | @@ -10017,7 +9972,7 @@ pub fn main() void { |
| 10017 | 9972 | <li>{#link|@divExact#} (division)</li> |
| 10018 | 9973 | </ul> |
| 10019 | 9974 | <p>Example with addition at compile-time:</p> |
| 10020 | {#code_begin|test_err|operation caused overflow#} | |
| 9975 | {#code_begin|test_err|overflow of integer type 'u8' with value '256'#} | |
| 10021 | 9976 | comptime { |
| 10022 | 9977 | var byte: u8 = 255; |
| 10023 | 9978 | byte += 1; |
| ... | ... | @@ -10118,6 +10073,7 @@ test "wraparound addition and subtraction" { |
| 10118 | 10073 | {#header_open|Exact Left Shift Overflow#} |
| 10119 | 10074 | <p>At compile-time:</p> |
| 10120 | 10075 | {#code_begin|test_err|operation caused overflow#} |
| 10076 | {#backend_stage1#} | |
| 10121 | 10077 | comptime { |
| 10122 | 10078 | const x = @shlExact(@as(u8, 0b01010101), 2); |
| 10123 | 10079 | _ = x; |
| ... | ... | @@ -10137,6 +10093,7 @@ pub fn main() void { |
| 10137 | 10093 | {#header_open|Exact Right Shift Overflow#} |
| 10138 | 10094 | <p>At compile-time:</p> |
| 10139 | 10095 | {#code_begin|test_err|exact shift shifted out 1 bits#} |
| 10096 | {#backend_stage1#} | |
| 10140 | 10097 | comptime { |
| 10141 | 10098 | const x = @shrExact(@as(u8, 0b10101010), 2); |
| 10142 | 10099 | _ = x; |
| ... | ... | @@ -10200,6 +10157,7 @@ pub fn main() void { |
| 10200 | 10157 | {#header_open|Exact Division Remainder#} |
| 10201 | 10158 | <p>At compile-time:</p> |
| 10202 | 10159 | {#code_begin|test_err|exact division had a remainder#} |
| 10160 | {#backend_stage1#} | |
| 10203 | 10161 | comptime { |
| 10204 | 10162 | const a: u32 = 10; |
| 10205 | 10163 | const b: u32 = 3; |
| ... | ... | @@ -10302,7 +10260,7 @@ fn getNumberOrFail() !i32 { |
| 10302 | 10260 | {#header_close#} |
| 10303 | 10261 | {#header_open|Invalid Error Code#} |
| 10304 | 10262 | <p>At compile-time:</p> |
| 10305 | {#code_begin|test_err|integer value 11 represents no error#} | |
| 10263 | {#code_begin|test_err|integer value '11' represents no error#} | |
| 10306 | 10264 | comptime { |
| 10307 | 10265 | const err = error.AnError; |
| 10308 | 10266 | const number = @errorToInt(err) + 10; |
| ... | ... | @@ -10324,7 +10282,7 @@ pub fn main() void { |
| 10324 | 10282 | {#header_close#} |
| 10325 | 10283 | {#header_open|Invalid Enum Cast#} |
| 10326 | 10284 | <p>At compile-time:</p> |
| 10327 | {#code_begin|test_err|has no tag matching integer value 3#} | |
| 10285 | {#code_begin|test_err|enum 'test.Foo' has no tag with value '3'#} | |
| 10328 | 10286 | const Foo = enum { |
| 10329 | 10287 | a, |
| 10330 | 10288 | b, |
| ... | ... | @@ -10356,7 +10314,7 @@ pub fn main() void { |
| 10356 | 10314 | |
| 10357 | 10315 | {#header_open|Invalid Error Set Cast#} |
| 10358 | 10316 | <p>At compile-time:</p> |
| 10359 | {#code_begin|test_err|error.B not a member of error set 'Set2'#} | |
| 10317 | {#code_begin|test_err|'error.B' not a member of error set 'error{A,C}'#} | |
| 10360 | 10318 | const Set1 = error{ |
| 10361 | 10319 | A, |
| 10362 | 10320 | B, |
| ... | ... | @@ -10417,7 +10375,7 @@ fn foo(bytes: []u8) u32 { |
| 10417 | 10375 | {#header_close#} |
| 10418 | 10376 | {#header_open|Wrong Union Field Access#} |
| 10419 | 10377 | <p>At compile-time:</p> |
| 10420 | {#code_begin|test_err|accessing union field 'float' while field 'int' is set#} | |
| 10378 | {#code_begin|test_err|access of union field 'float' while field 'int' is active#} | |
| 10421 | 10379 | comptime { |
| 10422 | 10380 | var f = Foo{ .int = 42 }; |
| 10423 | 10381 | f.float = 12.34; |
| ... | ... | @@ -10509,6 +10467,7 @@ fn bar(f: *Foo) void { |
| 10509 | 10467 | </p> |
| 10510 | 10468 | <p>At compile-time:</p> |
| 10511 | 10469 | {#code_begin|test_err|null pointer casted to type#} |
| 10470 | {#backend_stage1#} | |
| 10512 | 10471 | comptime { |
| 10513 | 10472 | const opt_ptr: ?*i32 = null; |
| 10514 | 10473 | const ptr = @ptrCast(*i32, opt_ptr); |
| ... | ... | @@ -10551,7 +10510,8 @@ const expect = std.testing.expect; |
| 10551 | 10510 | |
| 10552 | 10511 | test "using an allocator" { |
| 10553 | 10512 | var buffer: [100]u8 = undefined; |
| 10554 | const allocator = std.heap.FixedBufferAllocator.init(&buffer).allocator(); | |
| 10513 | var fba = std.heap.FixedBufferAllocator.init(&buffer); | |
| 10514 | const allocator = fba.allocator(); | |
| 10555 | 10515 | const result = try concat(allocator, "foo", "bar"); |
| 10556 | 10516 | try expect(std.mem.eql(u8, "foobar", result)); |
| 10557 | 10517 | } |
| ... | ... | @@ -10647,7 +10607,7 @@ pub fn main() !void { |
| 10647 | 10607 | <p>String literals such as {#syntax#}"foo"{#endsyntax#} are in the global constant data section. |
| 10648 | 10608 | This is why it is an error to pass a string literal to a mutable slice, like this: |
| 10649 | 10609 | </p> |
| 10650 | {#code_begin|test_err|cannot cast pointer to array literal to slice type '[]u8'#} | |
| 10610 | {#code_begin|test_err|expected type '[]u8', found '*const [5:0]u8'#} | |
| 10651 | 10611 | fn foo(s: []u8) void { |
| 10652 | 10612 | _ = s; |
| 10653 | 10613 | } |
lib/std/builtin.zig+1-1| ... | ... | @@ -866,7 +866,7 @@ pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn { |
| 866 | 866 | |
| 867 | 867 | pub fn panicOutOfBounds(index: usize, len: usize) noreturn { |
| 868 | 868 | @setCold(true); |
| 869 | std.debug.panic("attempt to index out of bound: index {d}, len {d}", .{ index, len }); | |
| 869 | std.debug.panic("index out of bounds: index {d}, len {d}", .{ index, len }); | |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | pub noinline fn returnError(st: *StackTrace) void { |
lib/std/coff.zig+1-1| ... | ... | @@ -383,7 +383,7 @@ const OptionalHeader = struct { |
| 383 | 383 | image_base: u64, |
| 384 | 384 | }; |
| 385 | 385 | |
| 386 | const DebugDirectoryEntry = packed struct { | |
| 386 | const DebugDirectoryEntry = extern struct { | |
| 387 | 387 | characteristiccs: u32, |
| 388 | 388 | time_date_stamp: u32, |
| 389 | 389 | major_version: u16, |
lib/std/os/linux/bpf.zig+1-1| ... | ... | @@ -458,7 +458,7 @@ pub const Insn = packed struct { |
| 458 | 458 | else |
| 459 | 459 | ImmOrReg{ .imm = src }; |
| 460 | 460 | |
| 461 | const src_type = switch (imm_or_reg) { | |
| 461 | const src_type: u8 = switch (imm_or_reg) { | |
| 462 | 462 | .imm => K, |
| 463 | 463 | .reg => X, |
| 464 | 464 | }; |
lib/std/os/windows.zig+1-1| ... | ... | @@ -1802,7 +1802,7 @@ pub const PathSpace = struct { |
| 1802 | 1802 | data: [PATH_MAX_WIDE:0]u16, |
| 1803 | 1803 | len: usize, |
| 1804 | 1804 | |
| 1805 | pub fn span(self: PathSpace) [:0]const u16 { | |
| 1805 | pub fn span(self: *const PathSpace) [:0]const u16 { | |
| 1806 | 1806 | return self.data[0..self.len :0]; |
| 1807 | 1807 | } |
| 1808 | 1808 | }; |
src/Compilation.zig+8-48| ... | ... | @@ -1040,24 +1040,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1040 | 1040 | const comp = try arena.create(Compilation); |
| 1041 | 1041 | const root_name = try arena.dupeZ(u8, options.root_name); |
| 1042 | 1042 | |
| 1043 | const use_stage1 = options.use_stage1 orelse blk: { | |
| 1044 | // Even though we may have no Zig code to compile (depending on `options.main_pkg`), | |
| 1045 | // we may need to use stage1 for building compiler-rt and other dependencies. | |
| 1046 | ||
| 1047 | if (build_options.omit_stage2) | |
| 1048 | break :blk true; | |
| 1049 | if (options.use_llvm) |use_llvm| { | |
| 1050 | if (!use_llvm) { | |
| 1051 | break :blk false; | |
| 1052 | } | |
| 1053 | } | |
| 1054 | ||
| 1055 | // If LLVM does not support the target, then we can't use it. | |
| 1056 | if (!target_util.hasLlvmSupport(options.target, options.target.ofmt)) | |
| 1057 | break :blk false; | |
| 1058 | ||
| 1059 | break :blk build_options.is_stage1; | |
| 1060 | }; | |
| 1043 | const use_stage1 = options.use_stage1 orelse false; | |
| 1061 | 1044 | |
| 1062 | 1045 | const cache_mode = if (use_stage1 and !options.disable_lld_caching) |
| 1063 | 1046 | CacheMode.whole |
| ... | ... | @@ -1248,7 +1231,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1248 | 1231 | break :blk lm; |
| 1249 | 1232 | } else default_link_mode; |
| 1250 | 1233 | |
| 1251 | const dll_export_fns = if (options.dll_export_fns) |explicit| explicit else is_dyn_lib or options.rdynamic; | |
| 1234 | const dll_export_fns = options.dll_export_fns orelse (is_dyn_lib or options.rdynamic); | |
| 1252 | 1235 | |
| 1253 | 1236 | const libc_dirs = try detectLibCIncludeDirs( |
| 1254 | 1237 | arena, |
| ... | ... | @@ -2213,8 +2196,7 @@ pub fn update(comp: *Compilation) !void { |
| 2213 | 2196 | comp.c_object_work_queue.writeItemAssumeCapacity(key); |
| 2214 | 2197 | } |
| 2215 | 2198 | |
| 2216 | const use_stage1 = build_options.omit_stage2 or | |
| 2217 | (build_options.is_stage1 and comp.bin_file.options.use_stage1); | |
| 2199 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | |
| 2218 | 2200 | if (comp.bin_file.options.module) |module| { |
| 2219 | 2201 | module.compile_log_text.shrinkAndFree(module.gpa, 0); |
| 2220 | 2202 | module.generation += 1; |
| ... | ... | @@ -2390,8 +2372,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 2390 | 2372 | }; |
| 2391 | 2373 | comp.link_error_flags = comp.bin_file.errorFlags(); |
| 2392 | 2374 | |
| 2393 | const use_stage1 = build_options.omit_stage2 or | |
| 2394 | (build_options.is_stage1 and comp.bin_file.options.use_stage1); | |
| 2375 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | |
| 2395 | 2376 | if (!use_stage1) { |
| 2396 | 2377 | if (comp.bin_file.options.module) |module| { |
| 2397 | 2378 | try link.File.C.flushEmitH(module); |
| ... | ... | @@ -2849,7 +2830,7 @@ pub fn performAllTheWork( |
| 2849 | 2830 | comp.work_queue_wait_group.reset(); |
| 2850 | 2831 | defer comp.work_queue_wait_group.wait(); |
| 2851 | 2832 | |
| 2852 | const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1; | |
| 2833 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | |
| 2853 | 2834 | |
| 2854 | 2835 | { |
| 2855 | 2836 | const astgen_frame = tracy.namedFrame("astgen"); |
| ... | ... | @@ -2952,9 +2933,6 @@ pub fn performAllTheWork( |
| 2952 | 2933 | fn processOneJob(comp: *Compilation, job: Job) !void { |
| 2953 | 2934 | switch (job) { |
| 2954 | 2935 | .codegen_decl => |decl_index| { |
| 2955 | if (build_options.omit_stage2) | |
| 2956 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 2957 | ||
| 2958 | 2936 | const module = comp.bin_file.options.module.?; |
| 2959 | 2937 | const decl = module.declPtr(decl_index); |
| 2960 | 2938 | |
| ... | ... | @@ -2989,9 +2967,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 2989 | 2967 | } |
| 2990 | 2968 | }, |
| 2991 | 2969 | .codegen_func => |func| { |
| 2992 | if (build_options.omit_stage2) | |
| 2993 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 2994 | ||
| 2995 | 2970 | const named_frame = tracy.namedFrame("codegen_func"); |
| 2996 | 2971 | defer named_frame.end(); |
| 2997 | 2972 | |
| ... | ... | @@ -3002,9 +2977,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 3002 | 2977 | }; |
| 3003 | 2978 | }, |
| 3004 | 2979 | .emit_h_decl => |decl_index| { |
| 3005 | if (build_options.omit_stage2) | |
| 3006 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 3007 | ||
| 3008 | 2980 | const module = comp.bin_file.options.module.?; |
| 3009 | 2981 | const decl = module.declPtr(decl_index); |
| 3010 | 2982 | |
| ... | ... | @@ -3063,9 +3035,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 3063 | 3035 | } |
| 3064 | 3036 | }, |
| 3065 | 3037 | .analyze_decl => |decl_index| { |
| 3066 | if (build_options.omit_stage2) | |
| 3067 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 3068 | ||
| 3069 | 3038 | const module = comp.bin_file.options.module.?; |
| 3070 | 3039 | module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) { |
| 3071 | 3040 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -3073,9 +3042,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 3073 | 3042 | }; |
| 3074 | 3043 | }, |
| 3075 | 3044 | .update_embed_file => |embed_file| { |
| 3076 | if (build_options.omit_stage2) | |
| 3077 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 3078 | ||
| 3079 | 3045 | const named_frame = tracy.namedFrame("update_embed_file"); |
| 3080 | 3046 | defer named_frame.end(); |
| 3081 | 3047 | |
| ... | ... | @@ -3086,9 +3052,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 3086 | 3052 | }; |
| 3087 | 3053 | }, |
| 3088 | 3054 | .update_line_number => |decl_index| { |
| 3089 | if (build_options.omit_stage2) | |
| 3090 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 3091 | ||
| 3092 | 3055 | const named_frame = tracy.namedFrame("update_line_number"); |
| 3093 | 3056 | defer named_frame.end(); |
| 3094 | 3057 | |
| ... | ... | @@ -3107,9 +3070,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 3107 | 3070 | }; |
| 3108 | 3071 | }, |
| 3109 | 3072 | .analyze_pkg => |pkg| { |
| 3110 | if (build_options.omit_stage2) | |
| 3111 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 3112 | ||
| 3113 | 3073 | const named_frame = tracy.namedFrame("analyze_pkg"); |
| 3114 | 3074 | defer named_frame.end(); |
| 3115 | 3075 | |
| ... | ... | @@ -3455,7 +3415,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 3455 | 3415 | var man = comp.obtainCObjectCacheManifest(); |
| 3456 | 3416 | defer man.deinit(); |
| 3457 | 3417 | |
| 3458 | const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1; | |
| 3418 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | |
| 3459 | 3419 | |
| 3460 | 3420 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects |
| 3461 | 3421 | man.hash.add(use_stage1); |
| ... | ... | @@ -4770,7 +4730,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca |
| 4770 | 4730 | |
| 4771 | 4731 | const target = comp.getTarget(); |
| 4772 | 4732 | const generic_arch_name = target.cpu.arch.genericName(); |
| 4773 | const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1; | |
| 4733 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | |
| 4774 | 4734 | |
| 4775 | 4735 | const zig_backend: std.builtin.CompilerBackend = blk: { |
| 4776 | 4736 | if (use_stage1) break :blk .stage1; |
| ... | ... | @@ -5057,7 +5017,7 @@ fn buildOutputFromZig( |
| 5057 | 5017 | .link_mode = .Static, |
| 5058 | 5018 | .function_sections = true, |
| 5059 | 5019 | .no_builtin = true, |
| 5060 | .use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1, | |
| 5020 | .use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1, | |
| 5061 | 5021 | .want_sanitize_c = false, |
| 5062 | 5022 | .want_stack_check = false, |
| 5063 | 5023 | .want_stack_protector = 0, |
src/Module.zig+4| ... | ... | @@ -6529,3 +6529,7 @@ pub fn addGlobalAssembly(mod: *Module, decl_index: Decl.Index, source: []const u |
| 6529 | 6529 | |
| 6530 | 6530 | mod.global_assembly.putAssumeCapacityNoClobber(decl_index, duped_source); |
| 6531 | 6531 | } |
| 6532 | ||
| 6533 | pub fn wantDllExports(mod: Module) bool { | |
| 6534 | return mod.comp.bin_file.options.dll_export_fns and mod.getTarget().os.tag == .windows; | |
| 6535 | } |
src/Sema.zig-7| ... | ... | @@ -27358,9 +27358,6 @@ pub fn resolveTypeLayout( |
| 27358 | 27358 | src: LazySrcLoc, |
| 27359 | 27359 | ty: Type, |
| 27360 | 27360 | ) CompileError!void { |
| 27361 | if (build_options.omit_stage2) | |
| 27362 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 27363 | ||
| 27364 | 27361 | switch (ty.zigTypeTag()) { |
| 27365 | 27362 | .Struct => return sema.resolveStructLayout(block, src, ty), |
| 27366 | 27363 | .Union => return sema.resolveUnionLayout(block, src, ty), |
| ... | ... | @@ -27699,8 +27696,6 @@ fn resolveUnionFully( |
| 27699 | 27696 | } |
| 27700 | 27697 | |
| 27701 | 27698 | pub fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type { |
| 27702 | if (build_options.omit_stage2) | |
| 27703 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 27704 | 27699 | switch (ty.tag()) { |
| 27705 | 27700 | .@"struct" => { |
| 27706 | 27701 | const struct_obj = ty.castTag(.@"struct").?.data; |
| ... | ... | @@ -29323,8 +29318,6 @@ fn typePtrOrOptionalPtrTy( |
| 29323 | 29318 | /// TODO merge these implementations together with the "advanced"/sema_kit pattern seen |
| 29324 | 29319 | /// elsewhere in value.zig |
| 29325 | 29320 | pub fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool { |
| 29326 | if (build_options.omit_stage2) | |
| 29327 | @panic("sadly stage2 is omitted from this build to save memory on the CI server"); | |
| 29328 | 29321 | return switch (ty.tag()) { |
| 29329 | 29322 | .u1, |
| 29330 | 29323 | .u8, |
src/codegen/llvm.zig+3| ... | ... | @@ -1103,6 +1103,7 @@ pub const Object = struct { |
| 1103 | 1103 | } |
| 1104 | 1104 | llvm_global.setUnnamedAddr(.False); |
| 1105 | 1105 | llvm_global.setLinkage(.External); |
| 1106 | if (module.wantDllExports()) llvm_global.setDLLStorageClass(.Default); | |
| 1106 | 1107 | if (self.di_map.get(decl)) |di_node| { |
| 1107 | 1108 | if (try decl.isFunction()) { |
| 1108 | 1109 | const di_func = @ptrCast(*llvm.DISubprogram, di_node); |
| ... | ... | @@ -1128,6 +1129,7 @@ pub const Object = struct { |
| 1128 | 1129 | const exp_name = exports[0].options.name; |
| 1129 | 1130 | llvm_global.setValueName2(exp_name.ptr, exp_name.len); |
| 1130 | 1131 | llvm_global.setUnnamedAddr(.False); |
| 1132 | if (module.wantDllExports()) llvm_global.setDLLStorageClass(.DLLExport); | |
| 1131 | 1133 | if (self.di_map.get(decl)) |di_node| { |
| 1132 | 1134 | if (try decl.isFunction()) { |
| 1133 | 1135 | const di_func = @ptrCast(*llvm.DISubprogram, di_node); |
| ... | ... | @@ -1187,6 +1189,7 @@ pub const Object = struct { |
| 1187 | 1189 | defer module.gpa.free(fqn); |
| 1188 | 1190 | llvm_global.setValueName2(fqn.ptr, fqn.len); |
| 1189 | 1191 | llvm_global.setLinkage(.Internal); |
| 1192 | if (module.wantDllExports()) llvm_global.setDLLStorageClass(.Default); | |
| 1190 | 1193 | llvm_global.setUnnamedAddr(.True); |
| 1191 | 1194 | if (decl.val.castTag(.variable)) |variable| { |
| 1192 | 1195 | const single_threaded = module.comp.bin_file.options.single_threaded; |
src/codegen/llvm/bindings.zig+9| ... | ... | @@ -223,6 +223,9 @@ pub const Value = opaque { |
| 223 | 223 | pub const setInitializer = LLVMSetInitializer; |
| 224 | 224 | extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void; |
| 225 | 225 | |
| 226 | pub const setDLLStorageClass = LLVMSetDLLStorageClass; | |
| 227 | extern fn LLVMSetDLLStorageClass(Global: *const Value, Class: DLLStorageClass) void; | |
| 228 | ||
| 226 | 229 | pub const addCase = LLVMAddCase; |
| 227 | 230 | extern fn LLVMAddCase(Switch: *const Value, OnVal: *const Value, Dest: *const BasicBlock) void; |
| 228 | 231 | |
| ... | ... | @@ -1482,6 +1485,12 @@ pub const CallAttr = enum(c_int) { |
| 1482 | 1485 | AlwaysInline, |
| 1483 | 1486 | }; |
| 1484 | 1487 | |
| 1488 | pub const DLLStorageClass = enum(c_uint) { | |
| 1489 | Default, | |
| 1490 | DLLImport, | |
| 1491 | DLLExport, | |
| 1492 | }; | |
| 1493 | ||
| 1485 | 1494 | pub const address_space = struct { |
| 1486 | 1495 | pub const default: c_uint = 0; |
| 1487 | 1496 |
src/config.zig.in+1-2| ... | ... | @@ -8,6 +8,5 @@ pub const enable_logging: bool = @ZIG_ENABLE_LOGGING_BOOL@; |
| 8 | 8 | pub const enable_link_snapshots: bool = false; |
| 9 | 9 | pub const enable_tracy = false; |
| 10 | 10 | pub const value_tracing = false; |
| 11 | pub const is_stage1 = true; | |
| 11 | pub const have_stage1 = true; | |
| 12 | 12 | pub const skip_non_native = false; |
| 13 | pub const omit_stage2: bool = @ZIG_OMIT_STAGE2_BOOL@; |
src/link.zig+2-2| ... | ... | @@ -279,7 +279,7 @@ pub const File = struct { |
| 279 | 279 | return &(try MachO.openPath(allocator, options)).base; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | const use_stage1 = build_options.is_stage1 and options.use_stage1; | |
| 282 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | |
| 283 | 283 | if (use_stage1 or options.emit == null) { |
| 284 | 284 | return switch (options.target.ofmt) { |
| 285 | 285 | .coff => &(try Coff.createEmpty(allocator, options)).base, |
| ... | ... | @@ -817,7 +817,7 @@ pub const File = struct { |
| 817 | 817 | // If there is no Zig code to compile, then we should skip flushing the output file |
| 818 | 818 | // because it will not be part of the linker line anyway. |
| 819 | 819 | const module_obj_path: ?[]const u8 = if (base.options.module) |module| blk: { |
| 820 | const use_stage1 = build_options.is_stage1 and base.options.use_stage1; | |
| 820 | const use_stage1 = build_options.have_stage1 and base.options.use_stage1; | |
| 821 | 821 | if (use_stage1) { |
| 822 | 822 | const obj_basename = try std.zig.binNameAlloc(arena, .{ |
| 823 | 823 | .root_name = base.options.root_name, |
src/link/Coff.zig+2-2| ... | ... | @@ -411,7 +411,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { |
| 411 | 411 | }; |
| 412 | 412 | |
| 413 | 413 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 414 | const use_stage1 = build_options.is_stage1 and options.use_stage1; | |
| 414 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | |
| 415 | 415 | if (use_llvm and !use_stage1) { |
| 416 | 416 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 417 | 417 | } |
| ... | ... | @@ -949,7 +949,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 949 | 949 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 950 | 950 | // will not be part of the linker line anyway. |
| 951 | 951 | const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: { |
| 952 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; | |
| 952 | const use_stage1 = build_options.have_stage1 and self.base.options.use_stage1; | |
| 953 | 953 | if (use_stage1) { |
| 954 | 954 | const obj_basename = try std.zig.binNameAlloc(arena, .{ |
| 955 | 955 | .root_name = self.base.options.root_name, |
src/link/Elf.zig+1-1| ... | ... | @@ -328,7 +328,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { |
| 328 | 328 | .page_size = page_size, |
| 329 | 329 | }; |
| 330 | 330 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 331 | const use_stage1 = build_options.is_stage1 and options.use_stage1; | |
| 331 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | |
| 332 | 332 | if (use_llvm and !use_stage1) { |
| 333 | 333 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 334 | 334 | } |
src/link/MachO.zig+2-2| ... | ... | @@ -272,7 +272,7 @@ pub const Export = struct { |
| 272 | 272 | pub fn openPath(allocator: Allocator, options: link.Options) !*MachO { |
| 273 | 273 | assert(options.target.ofmt == .macho); |
| 274 | 274 | |
| 275 | const use_stage1 = build_options.is_stage1 and options.use_stage1; | |
| 275 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | |
| 276 | 276 | if (use_stage1 or options.emit == null) { |
| 277 | 277 | return createEmpty(allocator, options); |
| 278 | 278 | } |
| ... | ... | @@ -363,7 +363,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 363 | 363 | const cpu_arch = options.target.cpu.arch; |
| 364 | 364 | const page_size: u16 = if (cpu_arch == .aarch64) 0x4000 else 0x1000; |
| 365 | 365 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 366 | const use_stage1 = build_options.is_stage1 and options.use_stage1; | |
| 366 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | |
| 367 | 367 | |
| 368 | 368 | const self = try gpa.create(MachO); |
| 369 | 369 | errdefer gpa.destroy(self); |
src/link/Wasm.zig+3-3| ... | ... | @@ -356,7 +356,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Wasm { |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 359 | const use_stage1 = build_options.is_stage1 and options.use_stage1; | |
| 359 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | |
| 360 | 360 | if (use_llvm and !use_stage1) { |
| 361 | 361 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 362 | 362 | } |
| ... | ... | @@ -2593,7 +2593,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 2593 | 2593 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 2594 | 2594 | // will not be part of the linker line anyway. |
| 2595 | 2595 | const module_obj_path: ?[]const u8 = if (self.base.options.module) |mod| blk: { |
| 2596 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; | |
| 2596 | const use_stage1 = build_options.have_stage1 and self.base.options.use_stage1; | |
| 2597 | 2597 | if (use_stage1) { |
| 2598 | 2598 | const obj_basename = try std.zig.binNameAlloc(arena, .{ |
| 2599 | 2599 | .root_name = self.base.options.root_name, |
| ... | ... | @@ -2803,7 +2803,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 2803 | 2803 | if (self.base.options.module) |mod| { |
| 2804 | 2804 | // when we use stage1, we use the exports that stage1 provided us. |
| 2805 | 2805 | // For stage2, we can directly retrieve them from the module. |
| 2806 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; | |
| 2806 | const use_stage1 = build_options.have_stage1 and self.base.options.use_stage1; | |
| 2807 | 2807 | if (use_stage1) { |
| 2808 | 2808 | for (comp.export_symbol_names.items) |symbol_name| { |
| 2809 | 2809 | try argv.append(try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name})); |
src/main.zig+1-1| ... | ... | @@ -2989,7 +2989,7 @@ fn buildOutputType( |
| 2989 | 2989 | return std.io.getStdOut().writeAll(try comp.generateBuiltinZigSource(arena)); |
| 2990 | 2990 | } |
| 2991 | 2991 | if (arg_mode == .translate_c) { |
| 2992 | const stage1_mode = use_stage1 orelse build_options.is_stage1; | |
| 2992 | const stage1_mode = use_stage1 orelse false; | |
| 2993 | 2993 | return cmdTranslateC(comp, arena, have_enable_cache, stage1_mode); |
| 2994 | 2994 | } |
| 2995 | 2995 |
src/stage1.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ const target_util = @import("target.zig"); |
| 18 | 18 | |
| 19 | 19 | comptime { |
| 20 | 20 | assert(builtin.link_libc); |
| 21 | assert(build_options.is_stage1); | |
| 21 | assert(build_options.have_stage1); | |
| 22 | 22 | assert(build_options.have_llvm); |
| 23 | 23 | if (!builtin.is_test) { |
| 24 | 24 | @export(main, .{ .name = "main" }); |
src/test.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ const skip_stage1 = builtin.zig_backend != .stage1 or build_options.skip_stage1; |
| 25 | 25 | const hr = "=" ** 80; |
| 26 | 26 | |
| 27 | 27 | test { |
| 28 | if (build_options.is_stage1) { | |
| 28 | if (build_options.have_stage1) { | |
| 29 | 29 | @import("stage1.zig").os_init(); |
| 30 | 30 | } |
| 31 | 31 |
test/cases/safety/empty slice with sentinel out of bounds.zig	+1-1| ... | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| 4 | 4 | _ = stack_trace; |
| 5 | if (std.mem.eql(u8, message, "attempt to index out of bound: index 1, len 0")) { | |
| 5 | if (std.mem.eql(u8, message, "index out of bounds: index 1, len 0")) { | |
| 6 | 6 | std.process.exit(0); |
| 7 | 7 | } |
| 8 | 8 | std.process.exit(1); |
test/cases/safety/out of bounds slice access.zig	+3-3| ... | ... | @@ -2,20 +2,20 @@ const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| 4 | 4 | _ = stack_trace; |
| 5 | if (std.mem.eql(u8, message, "attempt to index out of bound: index 4, len 4")) { | |
| 5 | if (std.mem.eql(u8, message, "index out of bounds: index 4, len 4")) { | |
| 6 | 6 | std.process.exit(0); |
| 7 | 7 | } |
| 8 | 8 | std.process.exit(1); |
| 9 | 9 | } |
| 10 | 10 | pub fn main() !void { |
| 11 | const a = [_]i32{1, 2, 3, 4}; | |
| 11 | const a = [_]i32{ 1, 2, 3, 4 }; | |
| 12 | 12 | baz(bar(&a)); |
| 13 | 13 | return error.TestFailed; |
| 14 | 14 | } |
| 15 | 15 | fn bar(a: []const i32) i32 { |
| 16 | 16 | return a[4]; |
| 17 | 17 | } |
| 18 | fn baz(_: i32) void { } | |
| 18 | fn baz(_: i32) void {} | |
| 19 | 19 | // run |
| 20 | 20 | // backend=llvm |
| 21 | 21 | // target=native |
test/cases/safety/slice with sentinel out of bounds - runtime len.zig	+1-1| ... | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| 4 | 4 | _ = stack_trace; |
| 5 | if (std.mem.eql(u8, message, "attempt to index out of bound: index 5, len 4")) { | |
| 5 | if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) { | |
| 6 | 6 | std.process.exit(0); |
| 7 | 7 | } |
| 8 | 8 | std.process.exit(1); |
test/cases/safety/slice with sentinel out of bounds.zig	+1-1| ... | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { |
| 4 | 4 | _ = stack_trace; |
| 5 | if (std.mem.eql(u8, message, "attempt to index out of bound: index 5, len 4")) { | |
| 5 | if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) { | |
| 6 | 6 | std.process.exit(0); |
| 7 | 7 | } |
| 8 | 8 | std.process.exit(1); |
test/tests.zig+5-6| ... | ... | @@ -605,7 +605,6 @@ pub fn addPkgTests( |
| 605 | 605 | skip_libc: bool, |
| 606 | 606 | skip_stage1: bool, |
| 607 | 607 | skip_stage2: bool, |
| 608 | is_stage1: bool, | |
| 609 | 608 | ) *build.Step { |
| 610 | 609 | const step = b.step(b.fmt("test-{s}", .{name}), desc); |
| 611 | 610 | |
| ... | ... | @@ -634,7 +633,7 @@ pub fn addPkgTests( |
| 634 | 633 | if (test_target.backend) |backend| switch (backend) { |
| 635 | 634 | .stage1 => if (skip_stage1) continue, |
| 636 | 635 | else => if (skip_stage2) continue, |
| 637 | } else if (is_stage1 and skip_stage1) continue; | |
| 636 | } else if (skip_stage2) continue; | |
| 638 | 637 | |
| 639 | 638 | const want_this_mode = for (modes) |m| { |
| 640 | 639 | if (m == test_target.mode) break true; |
| ... | ... | @@ -924,7 +923,7 @@ pub const StackTracesContext = struct { |
| 924 | 923 | pos = marks[i] + delim.len; |
| 925 | 924 | } |
| 926 | 925 | // locate source basename |
| 927 | pos = mem.lastIndexOfScalar(u8, line[0..marks[0]], fs.path.sep) orelse { | |
| 926 | pos = mem.lastIndexOfAny(u8, line[0..marks[0]], "\\/") orelse { | |
| 928 | 927 | // unexpected pattern: emit raw line and cont |
| 929 | 928 | try buf.appendSlice(line); |
| 930 | 929 | try buf.appendSlice("\n"); |
| ... | ... | @@ -936,9 +935,9 @@ pub const StackTracesContext = struct { |
| 936 | 935 | try buf.appendSlice(line[pos + 1 .. marks[2] + delims[2].len]); |
| 937 | 936 | try buf.appendSlice(" [address]"); |
| 938 | 937 | if (self.mode == .Debug) { |
| 939 | if (mem.lastIndexOfScalar(u8, line[marks[4]..marks[5]], '.')) |idot| { | |
| 940 | // On certain platforms (windows) or possibly depending on how we choose to link main | |
| 941 | // the object file extension may be present so we simply strip any extension. | |
| 938 | // On certain platforms (windows) or possibly depending on how we choose to link main | |
| 939 | // the object file extension may be present so we simply strip any extension. | |
| 940 | if (mem.indexOfScalar(u8, line[marks[4]..marks[5]], '.')) |idot| { | |
| 942 | 941 | try buf.appendSlice(line[marks[3] .. marks[4] + idot]); |
| 943 | 942 | try buf.appendSlice(line[marks[5]..]); |
| 944 | 943 | } else { |