| author | |
| committer | |
| log | 56e9575e827208b3df5c90472826f52bfc8342c0 |
| tree | c6d113eef8fc045f45b7e2adcaf4e99e5e3b6ab6 |
| parent | 9ea253b9c4085b9f577c4d7634da69b2d40d6cce |
| parent | eee500c0b59487b78294696160a976f20fe64829 |
| signature |
CI: more stage2 test coverage9 files changed, 123 insertions(+), 127 deletions(-)
build.zig+11-6| ... | ... | @@ -129,6 +129,7 @@ pub fn build(b: *Builder) !void { |
| 129 | 129 | const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false; |
| 130 | 130 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; |
| 131 | 131 | const strip = b.option(bool, "strip", "Omit debug information") orelse false; |
| 132 | const use_zig0 = b.option(bool, "zig0", "Bootstrap using zig0") orelse false; | |
| 132 | 133 | |
| 133 | 134 | 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: { |
| 134 | 135 | if (strip) break :blk @as(u32, 0); |
| ... | ... | @@ -136,7 +137,11 @@ pub fn build(b: *Builder) !void { |
| 136 | 137 | break :blk 4; |
| 137 | 138 | }; |
| 138 | 139 | |
| 139 | const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig"; | |
| 140 | const main_file: ?[]const u8 = mf: { | |
| 141 | if (!is_stage1) break :mf "src/main.zig"; | |
| 142 | if (use_zig0) break :mf null; | |
| 143 | break :mf "src/stage1.zig"; | |
| 144 | }; | |
| 140 | 145 | |
| 141 | 146 | const exe = b.addExecutable("zig", main_file); |
| 142 | 147 | exe.strip = strip; |
| ... | ... | @@ -311,8 +316,10 @@ pub fn build(b: *Builder) !void { |
| 311 | 316 | zig1_obj.addArg("-fsingle-threaded"); |
| 312 | 317 | } |
| 313 | 318 | |
| 314 | exe.step.dependOn(&zig1_obj.step); | |
| 315 | exe.addObjectFile(zig1_obj_path); | |
| 319 | if (use_zig0) { | |
| 320 | exe.step.dependOn(&zig1_obj.step); | |
| 321 | exe.addObjectFile(zig1_obj_path); | |
| 322 | } | |
| 316 | 323 | |
| 317 | 324 | // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case |
| 318 | 325 | // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that |
| ... | ... | @@ -559,9 +566,7 @@ fn addCmakeCfgOptionsToExe( |
| 559 | 566 | } |
| 560 | 567 | } |
| 561 | 568 | |
| 562 | fn addStaticLlvmOptionsToExe( | |
| 563 | exe: *std.build.LibExeObjStep, | |
| 564 | ) !void { | |
| 569 | fn addStaticLlvmOptionsToExe(exe: *std.build.LibExeObjStep) !void { | |
| 565 | 570 | // Adds the Zig C++ sources which both stage1 and stage2 need. |
| 566 | 571 | // |
| 567 | 572 | // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling |
ci/azure/macos_script+5-2| ... | ... | @@ -55,8 +55,11 @@ make $JOBS install |
| 55 | 55 | cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig" |
| 56 | 56 | make $JOBS install |
| 57 | 57 | |
| 58 | # TODO figure out why this causes a segmentation fault | |
| 59 | # release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test | |
| 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 test ../test/behavior.zig -I../test -fLLVM | |
| 62 | stage2/bin/zig test ../test/behavior.zig -I../test | |
| 60 | 63 | |
| 61 | 64 | release/bin/zig build test-toolchain -Denable-macos-sdk |
| 62 | 65 | release/bin/zig build test-std |
ci/azure/windows_script.bat deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | @echo on | |
| 2 | SET "SRCROOT=%cd%" | |
| 3 | SET "PREVPATH=%PATH%" | |
| 4 | SET "PREVMSYSTEM=%MSYSTEM%" | |
| 5 | ||
| 6 | set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" | |
| 7 | SET "MSYSTEM=MINGW64" | |
| 8 | bash -lc "cd ${SRCROOT} && ci/azure/windows_script" || exit /b |
ci/zinc/drone.yml-12| ... | ... | @@ -9,19 +9,7 @@ workspace: |
| 9 | 9 | path: /workspace |
| 10 | 10 | |
| 11 | 11 | steps: |
| 12 | - name: probe | |
| 13 | image: ci/debian-amd64:11.1-3 | |
| 14 | commands: | |
| 15 | - ./ci/zinc/linux_probe.sh | |
| 16 | ||
| 17 | - name: build | |
| 18 | image: ci/debian-amd64:11.1-3 | |
| 19 | commands: | |
| 20 | - ./ci/zinc/linux_build.sh | |
| 21 | ||
| 22 | 12 | - name: test |
| 23 | depends_on: | |
| 24 | - build | |
| 25 | 13 | image: ci/debian-amd64:11.1-3 |
| 26 | 14 | commands: |
| 27 | 15 | - ./ci/zinc/linux_test.sh |
ci/zinc/linux_base.sh-1| ... | ... | @@ -17,7 +17,6 @@ set -x |
| 17 | 17 | set -e |
| 18 | 18 | |
| 19 | 19 | ARCH="$(uname -m)" |
| 20 | JOBS="-j$(nproc)" | |
| 21 | 20 | |
| 22 | 21 | DEPS_LOCAL="/deps/local" |
| 23 | 22 | WORKSPACE="$DRONE_WORKSPACE" |
ci/zinc/linux_build.sh deleted-72| ... | ... | @@ -1,72 +0,0 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | 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 | # Build debug zig. | |
| 14 | echo "BUILD debug zig with zig:$($ZIG version)" | |
| 15 | ||
| 16 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 17 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 18 | ||
| 19 | mkdir _debug | |
| 20 | cd _debug | |
| 21 | cmake .. \ | |
| 22 | -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ | |
| 23 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 24 | -DCMAKE_BUILD_TYPE=Debug \ | |
| 25 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 26 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 27 | -DZIG_STATIC=ON \ | |
| 28 | -GNinja | |
| 29 | ||
| 30 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | |
| 31 | # so that installation and testing do not get affected by them. | |
| 32 | unset CC | |
| 33 | unset CXX | |
| 34 | ||
| 35 | ninja $JOBS install | |
| 36 | ||
| 37 | ZIG=$DEBUG_STAGING/bin/zig | |
| 38 | ||
| 39 | # Here we rebuild zig but this time using the Zig binary we just now produced to | |
| 40 | # build zig1.o rather than relying on the one built with stage0. See | |
| 41 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 42 | cmake .. -DZIG_EXECUTABLE="$ZIG" | |
| 43 | ninja $JOBS install | |
| 44 | ||
| 45 | cd $WORKSPACE | |
| 46 | ||
| 47 | # Build release zig. | |
| 48 | echo "BUILD release zig with zig:$($ZIG version)" | |
| 49 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 50 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 51 | mkdir _release | |
| 52 | cd _release | |
| 53 | cmake .. \ | |
| 54 | -DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \ | |
| 55 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 56 | -DCMAKE_BUILD_TYPE=Release \ | |
| 57 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 58 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 59 | -DZIG_STATIC=ON \ | |
| 60 | -GNinja | |
| 61 | unset CC | |
| 62 | unset CXX | |
| 63 | ninja $JOBS install | |
| 64 | ||
| 65 | cd $WORKSPACE | |
| 66 | ||
| 67 | # Look for non-conforming code formatting. | |
| 68 | # Formatting errors can be fixed by running `zig fmt` on the files printed here. | |
| 69 | $ZIG fmt --check . | |
| 70 | ||
| 71 | # Explicit exit helps show last command duration. | |
| 72 | exit |
ci/zinc/linux_probe.sh deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | # Probe CPU/brand details. | |
| 6 | echo "lscpu:" | |
| 7 | (lscpu | sed 's,^, : ,') 1>&2 | |
| 8 | ||
| 9 | # Explicit exit helps show last command duration. | |
| 10 | exit |
ci/zinc/linux_test.sh+70-9| ... | ... | @@ -2,15 +2,65 @@ |
| 2 | 2 | |
| 3 | 3 | . ./ci/zinc/linux_base.sh |
| 4 | 4 | |
| 5 | ZIG=$DEBUG_STAGING/bin/zig | |
| 5 | ZIG="$DEPS_LOCAL/bin/zig" | |
| 6 | TARGET="${ARCH}-linux-musl" | |
| 7 | MCPU="baseline" | |
| 6 | 8 | |
| 7 | $ZIG test test/behavior.zig -fno-stage1 -I test -fLLVM | |
| 8 | $ZIG test test/behavior.zig -fno-stage1 -I test -fLLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin | |
| 9 | $ZIG test test/behavior.zig -fno-stage1 -I test -ofmt=c | |
| 10 | $ZIG test test/behavior.zig -fno-stage1 -I test -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin | |
| 11 | $ZIG test test/behavior.zig -fno-stage1 -I test -target arm-linux --test-cmd qemu-arm --test-cmd-bin | |
| 12 | $ZIG test test/behavior.zig -fno-stage1 -I test -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin | |
| 13 | $ZIG test test/behavior.zig -fno-stage1 -I test | |
| 9 | # Make the `zig version` number consistent. | |
| 10 | # This will affect the cmake command below. | |
| 11 | git config core.abbrev 9 | |
| 12 | ||
| 13 | echo "BUILD debug zig with zig:$($ZIG version)" | |
| 14 | ||
| 15 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 16 | export CXX="$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 | 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="$ZIG" | |
| 42 | ninja install | |
| 43 | ||
| 44 | cd $WORKSPACE | |
| 45 | ||
| 46 | # Look for non-conforming code formatting. | |
| 47 | # Formatting errors can be fixed by running `zig fmt` on the files printed here. | |
| 48 | $ZIG fmt --check . | |
| 49 | ||
| 50 | # Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. | |
| 51 | $ZIG build -p stage2 -Denable-llvm -Duse-zig-libcxx | |
| 52 | ||
| 53 | stage2/bin/zig test test/behavior.zig -I test -fLLVM | |
| 54 | stage2/bin/zig test test/behavior.zig -I test | |
| 55 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin | |
| 56 | stage2/bin/zig test test/behavior.zig -I test -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin | |
| 57 | stage2/bin/zig test test/behavior.zig -I test -ofmt=c | |
| 58 | stage2/bin/zig test test/behavior.zig -I test -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin | |
| 59 | stage2/bin/zig test test/behavior.zig -I test -target arm-linux --test-cmd qemu-arm --test-cmd-bin | |
| 60 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-macos --test-no-exec | |
| 61 | stage2/bin/zig test test/behavior.zig -I test -target aarch64-macos --test-no-exec | |
| 62 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target x86_64-macos --test-no-exec | |
| 63 | stage2/bin/zig test test/behavior.zig -I test -target x86_64-macos --test-no-exec | |
| 14 | 64 | |
| 15 | 65 | $ZIG build test-behavior -fqemu -fwasmtime |
| 16 | 66 | $ZIG build test-compiler-rt -fqemu -fwasmtime |
| ... | ... | @@ -31,7 +81,7 @@ $ZIG build test-fmt -fqemu -fwasmtime |
| 31 | 81 | $ZIG build test-stage2 -fqemu -fwasmtime |
| 32 | 82 | |
| 33 | 83 | # Produce the experimental std lib documentation. |
| 34 | mkdir -p $RELEASE_STAGING/docs/std | |
| 84 | mkdir -p "$RELEASE_STAGING/docs/std" | |
| 35 | 85 | $ZIG test lib/std/std.zig \ |
| 36 | 86 | --zig-lib-dir lib \ |
| 37 | 87 | -femit-docs=$RELEASE_STAGING/docs/std \ |
| ... | ... | @@ -40,5 +90,16 @@ $ZIG test lib/std/std.zig \ |
| 40 | 90 | # Look for HTML errors. |
| 41 | 91 | tidy --drop-empty-elements no -qe zig-cache/langref.html |
| 42 | 92 | |
| 93 | # Build release zig. | |
| 94 | $ZIG build \ | |
| 95 | --prefix "$RELEASE_STAGING" \ | |
| 96 | --search-prefix "$DEPS_LOCAL" \ | |
| 97 | -Denable-llvm \ | |
| 98 | -Duse-zig-libcxx \ | |
| 99 | -Drelease \ | |
| 100 | -Dstrip \ | |
| 101 | -Dtarget="$TARGET" \ | |
| 102 | -Dstage1 | |
| 103 | ||
| 43 | 104 | # Explicit exit helps show last command duration. |
| 44 | 105 | exit |
src/main.zig+37-7| ... | ... | @@ -2008,28 +2008,34 @@ fn buildOutputType( |
| 2008 | 2008 | // are part of libc or libc++. We remove them from the list and communicate their |
| 2009 | 2009 | // existence via flags instead. |
| 2010 | 2010 | { |
| 2011 | // Similarly, if any libs in this list are statically provided, we remove | |
| 2012 | // them from this list and populate the link_objects array instead. | |
| 2013 | const sep = fs.path.sep_str; | |
| 2014 | var test_path = std.ArrayList(u8).init(gpa); | |
| 2015 | defer test_path.deinit(); | |
| 2016 | ||
| 2011 | 2017 | var i: usize = 0; |
| 2012 | while (i < system_libs.count()) { | |
| 2018 | syslib: while (i < system_libs.count()) { | |
| 2013 | 2019 | const lib_name = system_libs.keys()[i]; |
| 2014 | 2020 | |
| 2015 | 2021 | if (target_util.is_libc_lib_name(target_info.target, lib_name)) { |
| 2016 | 2022 | link_libc = true; |
| 2017 | _ = system_libs.orderedRemove(lib_name); | |
| 2023 | system_libs.orderedRemoveAt(i); | |
| 2018 | 2024 | continue; |
| 2019 | 2025 | } |
| 2020 | 2026 | if (target_util.is_libcpp_lib_name(target_info.target, lib_name)) { |
| 2021 | 2027 | link_libcpp = true; |
| 2022 | _ = system_libs.orderedRemove(lib_name); | |
| 2028 | system_libs.orderedRemoveAt(i); | |
| 2023 | 2029 | continue; |
| 2024 | 2030 | } |
| 2025 | 2031 | if (mem.eql(u8, lib_name, "unwind")) { |
| 2026 | 2032 | link_libunwind = true; |
| 2027 | _ = system_libs.orderedRemove(lib_name); | |
| 2033 | system_libs.orderedRemoveAt(i); | |
| 2028 | 2034 | continue; |
| 2029 | 2035 | } |
| 2030 | 2036 | if (target_util.is_compiler_rt_lib_name(target_info.target, lib_name)) { |
| 2031 | 2037 | std.log.warn("ignoring superfluous library '{s}': this dependency is fulfilled instead by compiler-rt which zig unconditionally provides", .{lib_name}); |
| 2032 | _ = system_libs.orderedRemove(lib_name); | |
| 2038 | system_libs.orderedRemoveAt(i); | |
| 2033 | 2039 | continue; |
| 2034 | 2040 | } |
| 2035 | 2041 | if (std.fs.path.isAbsolute(lib_name)) { |
| ... | ... | @@ -2038,10 +2044,32 @@ fn buildOutputType( |
| 2038 | 2044 | if (target_info.target.os.tag == .wasi) { |
| 2039 | 2045 | if (wasi_libc.getEmulatedLibCRTFile(lib_name)) |crt_file| { |
| 2040 | 2046 | try wasi_emulated_libs.append(crt_file); |
| 2041 | _ = system_libs.orderedRemove(lib_name); | |
| 2047 | system_libs.orderedRemoveAt(i); | |
| 2042 | 2048 | continue; |
| 2043 | 2049 | } |
| 2044 | 2050 | } |
| 2051 | ||
| 2052 | for (lib_dirs.items) |lib_dir_path| { | |
| 2053 | test_path.clearRetainingCapacity(); | |
| 2054 | try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{ | |
| 2055 | lib_dir_path, | |
| 2056 | target_info.target.libPrefix(), | |
| 2057 | lib_name, | |
| 2058 | target_info.target.staticLibSuffix(), | |
| 2059 | }); | |
| 2060 | fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 2061 | error.FileNotFound => continue, | |
| 2062 | else => |e| fatal("unable to search for static library '{s}': {s}", .{ | |
| 2063 | test_path.items, @errorName(e), | |
| 2064 | }), | |
| 2065 | }; | |
| 2066 | try link_objects.append(.{ .path = try arena.dupe(u8, test_path.items) }); | |
| 2067 | system_libs.orderedRemoveAt(i); | |
| 2068 | continue :syslib; | |
| 2069 | } | |
| 2070 | ||
| 2071 | std.log.scoped(.cli).debug("depending on system for -l{s}", .{lib_name}); | |
| 2072 | ||
| 2045 | 2073 | i += 1; |
| 2046 | 2074 | } |
| 2047 | 2075 | } |
| ... | ... | @@ -2068,7 +2096,9 @@ fn buildOutputType( |
| 2068 | 2096 | want_native_include_dirs = true; |
| 2069 | 2097 | } |
| 2070 | 2098 | |
| 2071 | if (sysroot == null and cross_target.isNativeOs() and (system_libs.count() != 0 or want_native_include_dirs)) { | |
| 2099 | if (sysroot == null and cross_target.isNativeOs() and | |
| 2100 | (system_libs.count() != 0 or want_native_include_dirs)) | |
| 2101 | { | |
| 2072 | 2102 | const paths = std.zig.system.NativePaths.detect(arena, target_info) catch |err| { |
| 2073 | 2103 | fatal("unable to detect native system paths: {s}", .{@errorName(err)}); |
| 2074 | 2104 | }; |