Skip to content

[Clang] Major build regression due to OOM on windows #119781

Closed
@h-vetinari

Description

@h-vetinari

I've been building the LLVM 20 stack from main in conda-forge (mainly for testing #110217), and I've run into a regression that makes it impossible for us to build clang in our infrastructure. Granted, our free agents from azure-pipelines are quite puny (2 cores, 7-8GB memory, 6h time limit), but this has sufficed for many years to piece together LLVM, even though we have to slice things into several pieces (e.g. libllvm, clang, mlir, compiler-rt, libcxx, openmp, lld, etc.), both to stay under the 6h timeout, but also for packaging reasons.

Following the various stages of #110217, I've built sets of packages based off the following commits:

(The ✅ / ❌ here only refer to building clang on windows, the other plaforms were fine)

After reproducing the problem 5+ times (happens 100% of the time), the failure looks as follows:

[144/2145] Building CXX object lib\Basic\CMakeFiles\obj.clangBasic.dir\Targets.cpp.obj
##[warning]Free memory is lower than 5%; Currently used: 95.37%
##[warning]Free memory is lower than 5%; Currently used: 97.49%
##[warning]Free disk space on D:\ is lower than 5%; Currently used: 95.05%
##[warning]Free disk space on D:\ is lower than 5%; Currently used: 95.05%
[145/2145] Building CXX object lib\Basic\CMakeFiles\obj.clangBasic.dir\Targets\AArch64.cpp.obj
FAILED: lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.obj 
C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I%SRC_DIR%\clang\build\lib\Basic -I%SRC_DIR%\clang\lib\Basic -I%SRC_DIR%\clang\include -I%SRC_DIR%\clang\build\include -I%PREFIX%\Library\include -MD  /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR /showIncludes /Folib\Basic\CMakeFiles\obj.clangBasic.dir\Targets\AArch64.cpp.obj /Fdlib\Basic\CMakeFiles\obj.clangBasic.dir\ /FS -c %SRC_DIR%\clang\lib\Basic\Targets\AArch64.cpp
%SRC_DIR%\clang\build\include\clang/Basic/arm_sve_builtins.inc(7787): fatal error C1060: compiler is out of heap space
ninja: build stopped: subcommand failed.

This is despite already using a ~16GB swapfile, and having reduced parallelism to -j1. It might be that somehing in include/clang/Basic/arm_sve_builtins.inc goes haywire? I wasn't able to check as that file is generated and not checked-in.

The problem is that we cannot even easily switch to compile with clang, because that creates a cycle from the POV of our build tool (clang building clang). Of course, that tool could be improved, and there are possible work-arounds, but it's still a pretty major regression IMO if even a single-threaded build cannot build clang with 8GB memory (+16GB swap) anymore.

FWIW, our build looks roughly as follows (against an existing libllvm & libcxx compiled from the same version or commit):

mkdir build
cd build

set "CXX=cl.exe"
set "CC=cl.exe"
cmake -G "Ninja" ^
    -DCMAKE_BUILD_TYPE="Release" ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% ^
    -DCLANG_FORCE_MATCHING_LIBCLANG_SOVERSION=OFF ^
    -DCLANG_INCLUDE_TESTS=OFF ^
    -DCLANG_INCLUDE_DOCS=OFF ^
    -DLLVM_INCLUDE_TESTS=OFF ^
    -DLLVM_INCLUDE_DOCS=OFF ^
    -DLLVM_ENABLE_LIBXML2=FORCE_ON ^
    -DLLVM_ENABLE_ZLIB=FORCE_ON ^
    -DLLVM_ENABLE_ZSTD=FORCE_ON ^
    -DPython3_EXECUTABLE=%BUILD_PREFIX%\python ^
    ../clang
if %ERRORLEVEL% neq 0 exit 1

:: also tried with -j1; still OOMs
ninja -j%CPU_COUNT%
if %ERRORLEVEL% neq 0 exit 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    build-problemclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions