From 2fe8a482159762724df93225bd70abbd0c2c5930 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 4 Jan 2021 14:59:18 -0700 Subject: [PATCH] ci: omit stage2 backend from stage1 on Windows to avoid out-of-memory on the CI runs. --- CMakeLists.txt | 7 +++++++ build.zig | 3 ++- ci/azure/windows_msvc_script.bat | 5 +++-- src/Compilation.zig | 6 ++++++ src/config.zig.in | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 291a2f7839..2ed25b93d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,7 @@ set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary") set(ZIG_PREFER_LLVM_CONFIG off CACHE BOOL "(when cross compiling) use llvm-config to find target llvm dependencies if needed") set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread") +set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1") find_package(llvm) find_package(clang) @@ -587,6 +588,12 @@ if(MSVC) endif() endif() +if(ZIG_OMIT_STAGE2) + set(ZIG_OMIT_STAGE2_BOOL "true") +else() + set(ZIG_OMIT_STAGE2_BOOL "false") +endif() + configure_file ( "${CMAKE_SOURCE_DIR}/src/stage1/config.h.in" "${ZIG_CONFIG_H_OUT}" diff --git a/build.zig b/build.zig index ce412beef0..77d1b573fd 100644 --- a/build.zig +++ b/build.zig @@ -125,7 +125,6 @@ pub fn build(b: *Builder) !void { try addCmakeCfgOptionsToExe(b, cfg, tracy, test_stage2); } else { // Here we are -Denable-llvm but no cmake integration. - try addStaticLlvmOptionsToExe(exe); try addStaticLlvmOptionsToExe(test_stage2); } @@ -194,6 +193,7 @@ pub fn build(b: *Builder) !void { exe.addBuildOption([]const []const u8, "log_scopes", log_scopes); exe.addBuildOption(bool, "enable_tracy", tracy != null); exe.addBuildOption(bool, "is_stage1", is_stage1); + exe.addBuildOption(bool, "omit_stage2", false); if (tracy) |tracy_path| { const client_cpp = fs.path.join( b.allocator, @@ -216,6 +216,7 @@ pub fn build(b: *Builder) !void { test_stage2.addBuildOption(bool, "skip_non_native", skip_non_native); test_stage2.addBuildOption(bool, "is_stage1", is_stage1); + test_stage2.addBuildOption(bool, "omit_stage2", false); test_stage2.addBuildOption(bool, "have_llvm", enable_llvm); test_stage2.addBuildOption(bool, "enable_qemu", is_qemu_enabled); test_stage2.addBuildOption(bool, "enable_wine", is_wine_enabled); diff --git a/ci/azure/windows_msvc_script.bat b/ci/azure/windows_msvc_script.bat index cd5e3d5bca..9d28eccd0b 100644 --- a/ci/azure/windows_msvc_script.bat +++ b/ci/azure/windows_msvc_script.bat @@ -23,11 +23,12 @@ git.exe fetch --tags mkdir %ZIGBUILDDIR% cd %ZIGBUILDDIR% -cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release || exit /b +cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-behavior -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-stage2 -Dskip-non-native || exit /b +REM Disabled to prevent OOM +REM "%ZIGINSTALLDIR%\bin\zig.exe" build test-stage2 -Dskip-non-native || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-fmt -Dskip-non-native || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-compiler-rt -Dskip-non-native || exit /b diff --git a/src/Compilation.zig b/src/Compilation.zig index 2ba76d0f5e..9912520437 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1461,6 +1461,8 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor => continue, .complete, .codegen_failure_retryable => { + if (build_options.omit_stage2) + @panic("sadly stage2 is omitted from this build to save memory on the CI server"); const module = self.bin_file.options.module.?; if (decl.typed_value.most_recent.typed_value.val.castTag(.function)) |payload| { const func = payload.data; @@ -1532,6 +1534,8 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor }, }, .analyze_decl => |decl| { + if (build_options.omit_stage2) + @panic("sadly stage2 is omitted from this build to save memory on the CI server"); const module = self.bin_file.options.module.?; module.ensureDeclAnalyzed(decl) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, @@ -1539,6 +1543,8 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor }; }, .update_line_number => |decl| { + if (build_options.omit_stage2) + @panic("sadly stage2 is omitted from this build to save memory on the CI server"); const module = self.bin_file.options.module.?; self.bin_file.updateDeclLineNumber(module, decl) catch |err| { try module.failed_decls.ensureCapacity(module.gpa, module.failed_decls.items().len + 1); diff --git a/src/config.zig.in b/src/config.zig.in index 0dbd3f3c91..b672581ea4 100644 --- a/src/config.zig.in +++ b/src/config.zig.in @@ -5,3 +5,4 @@ pub const log_scopes: []const []const u8 = &[_][]const u8{}; pub const enable_tracy = false; pub const is_stage1 = true; pub const skip_non_native = false; +pub const omit_stage2: bool = @ZIG_OMIT_STAGE2_BOOL@;