From 507aae4a1a3db498ece2a3a89d74e9e24d952923 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 7 Aug 2022 23:10:57 -0700 Subject: make self-hosted the default compiler stage1 is available behind the -fstage1 flag. closes #89 --- ci/azure/build.zig | 10 +++++----- ci/azure/macos_script | 17 ++++++----------- ci/azure/pipelines.yml | 4 +--- ci/srht/freebsd_script | 9 +++++---- ci/zinc/linux_test.sh | 48 +++++++++++++++++++++++------------------------- 5 files changed, 40 insertions(+), 48 deletions(-) (limited to 'ci') diff --git a/ci/azure/build.zig b/ci/azure/build.zig index 053065b699..00f1cce2bd 100644 --- a/ci/azure/build.zig +++ b/ci/azure/build.zig @@ -37,9 +37,9 @@ pub fn build(b: *Builder) !void { const docs_step = b.step("docs", "Build documentation"); docs_step.dependOn(&docgen_cmd.step); - const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false; + const have_stage1 = b.option(bool, "enable-stage1", "Include the stage1 compiler behind a feature flag") orelse false; const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; - const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm); + const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (have_stage1 or static_llvm); const llvm_has_m68k = b.option( bool, "llvm-has-m68k", @@ -101,7 +101,7 @@ pub fn build(b: *Builder) !void { break :blk 4; }; - const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig"; + const main_file: ?[]const u8 = if (have_stage1) null else "src/main.zig"; const exe = b.addExecutable("zig", main_file); exe.strip = strip; @@ -190,7 +190,7 @@ pub fn build(b: *Builder) !void { if (enable_llvm) { const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); - if (is_stage1) { + if (have_stage1) { const softfloat = b.addStaticLibrary("softfloat", null); softfloat.setBuildMode(.ReleaseFast); softfloat.setTarget(target); @@ -298,7 +298,7 @@ pub fn build(b: *Builder) !void { exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); exe_options.addOption(bool, "value_tracing", value_tracing); - exe_options.addOption(bool, "is_stage1", is_stage1); + exe_options.addOption(bool, "have_stage1", have_stage1); if (tracy) |tracy_path| { const client_cpp = fs.path.join( b.allocator, diff --git a/ci/azure/macos_script b/ci/azure/macos_script index b244a73869..d0ad9171ee 100755 --- a/ci/azure/macos_script +++ b/ci/azure/macos_script @@ -34,7 +34,7 @@ git fetch --tags mkdir build cd build cmake .. \ - -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \ + -DCMAKE_INSTALL_PREFIX="$(pwd)/stage2" \ -DCMAKE_PREFIX_PATH="$PREFIX" \ -DCMAKE_BUILD_TYPE=Release \ -DZIG_TARGET_TRIPLE="$TARGET" \ @@ -52,23 +52,18 @@ make $JOBS install # Here we rebuild zig but this time using the Zig binary we just now produced to # build zig1.o rather than relying on the one built with stage0. See # https://github.com/ziglang/zig/issues/6830 for more details. -cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig" +cmake .. -DZIG_EXECUTABLE="$(pwd)/stage2/bin/zig" make $JOBS install -# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. -release/bin/zig build -p stage2 -Denable-llvm +stage2/bin/zig build -p release -Denable-llvm -Denable-stage1 -stage2/bin/zig build test-behavior - -# TODO: upgrade these to test stage2 instead of stage1 -# TODO: upgrade these to test stage3 instead of stage2 -release/bin/zig build test-behavior -Denable-macos-sdk -Domit-stage2 release/bin/zig build test-compiler-rt -Denable-macos-sdk +release/bin/zig build test-behavior -Denable-macos-sdk release/bin/zig build test-std -Denable-macos-sdk release/bin/zig build test-universal-libc -Denable-macos-sdk release/bin/zig build test-compare-output -Denable-macos-sdk release/bin/zig build test-standalone -Denable-macos-sdk -release/bin/zig build test-stack-traces -Denable-macos-sdk +release/bin/zig build test-stack-traces -Denable-macos-sdk -fstage1 release/bin/zig build test-cli -Denable-macos-sdk release/bin/zig build test-asm-link -Denable-macos-sdk release/bin/zig build test-translate-c -Denable-macos-sdk @@ -76,7 +71,7 @@ release/bin/zig build test-run-translated-c -Denable-macos-sdk release/bin/zig build docs -Denable-macos-sdk release/bin/zig build test-fmt -Denable-macos-sdk release/bin/zig build test-cases -Denable-macos-sdk -Dsingle-threaded -release/bin/zig build test-link -Denable-macos-sdk -Domit-stage2 +release/bin/zig build test-link -Denable-macos-sdk if [ "${BUILD_REASON}" != "PullRequest" ]; then mv ../LICENSE release/ diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 5d208b31a2..16804a0a2b 100644 --- a/ci/azure/pipelines.yml +++ b/ci/azure/pipelines.yml @@ -68,9 +68,7 @@ jobs: & "${ZIGPREFIXPATH}/bin/zig.exe" build ` --prefix "$ZIGINSTALLDIR" ` --search-prefix "$ZIGPREFIXPATH" ` - -Dstage1 ` - <# stage2 is omitted until we resolve https://github.com/ziglang/zig/issues/6485 #> ` - -Domit-stage2 ` + -Denable-stage1 ` -Dstatic-llvm ` -Drelease ` -Dstrip ` diff --git a/ci/srht/freebsd_script b/ci/srht/freebsd_script index 9fd7c0be65..9c77c7d120 100755 --- a/ci/srht/freebsd_script +++ b/ci/srht/freebsd_script @@ -38,10 +38,11 @@ cmake .. \ -GNinja samu install -# TODO ld.lld: error: undefined symbol: main -# >>> referenced by crt1_c.c:75 (/usr/src/lib/csu/amd64/crt1_c.c:75) -# >>> /usr/lib/crt1.o:(_start) -#release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test +# Here we rebuild zig but this time using the Zig binary we just now produced to +# build zig1.o rather than relying on the one built with stage0. This makes it +# a stage3 build rather than a stage2 build. +cmake .. -DZIG_EXECUTABLE="$PREFIX/bin/zig" +samu install # Here we skip some tests to save time. release/bin/zig build test -Dskip-stage1 -Dskip-non-native diff --git a/ci/zinc/linux_test.sh b/ci/zinc/linux_test.sh index 3a54e82c38..1b280fbae5 100755 --- a/ci/zinc/linux_test.sh +++ b/ci/zinc/linux_test.sh @@ -33,41 +33,39 @@ unset CXX ninja install -STAGE1_ZIG="$DEBUG_STAGING/bin/zig" - # Here we rebuild zig but this time using the Zig binary we just now produced to # build zig1.o rather than relying on the one built with stage0. See # https://github.com/ziglang/zig/issues/6830 for more details. -cmake .. -DZIG_EXECUTABLE="$STAGE1_ZIG" +cmake .. -DZIG_EXECUTABLE="$DEBUG_STAGING/bin/zig" ninja install cd $WORKSPACE +"$DEBUG_STAGING/bin/zig" build -p stage3 -Denable-stage1 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" + +# simultaneously test building self-hosted without LLVM and with 32-bit arm +stage3/bin/zig build -Dtarget=arm-linux-musleabihf + echo "Looking for non-conforming code formatting..." echo "Formatting errors can be fixed by running 'zig fmt' on the files printed here." -$STAGE1_ZIG fmt --check . --exclude test/cases/ - -$STAGE1_ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" -stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" -stage3/bin/zig build # test building self-hosted without LLVM -stage3/bin/zig build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm - -stage3/bin/zig build test-compiler-rt -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-behavior -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-std -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-universal-libc -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-compare-output -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-asm-link -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-fmt -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-translate-c -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-run-translated-c -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-standalone -fqemu -fwasmtime -Denable-llvm -stage3/bin/zig build test-cli -fqemu -fwasmtime -Denable-llvm +stage3/bin/zig fmt --check . --exclude test/cases/ + +stage3/bin/zig build test-compiler-rt -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-behavior -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-std -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-universal-libc -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-compare-output -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-asm-link -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-fmt -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-translate-c -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-run-translated-c -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-standalone -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-cli -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" stage3/bin/zig build test-cases -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" -stage3/bin/zig build test-link -fqemu -fwasmtime -Denable-llvm +stage3/bin/zig build test-link -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build docs -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" -$STAGE1_ZIG build test-stack-traces -fqemu -fwasmtime -$STAGE1_ZIG build docs -fqemu -fwasmtime +stage3/bin/zig build test-stack-traces -fqemu -fwasmtime -fstage1 # Produce the experimental std lib documentation. mkdir -p "$RELEASE_STAGING/docs/std" @@ -87,7 +85,7 @@ stage3/bin/zig build \ -Drelease \ -Dstrip \ -Dtarget="$TARGET" \ - -Dstage1 + -Denable-stage1 # Explicit exit helps show last command duration. exit -- cgit v1.2.3