Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14111] [Windows] Build swift from source fails with error C1128 and suggests param /bigobj #56497

Closed
swift-ci opened this issue Jan 26, 2021 · 8 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Windows Platform: Windows

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14111
Radar None
Original Reporter yostane (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Windows 10 Hyper-V VM (created with quick creator)

X64 command prompt for VS2019

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, Windows
Assignee @compnerd
Priority Medium

md5: 1a4a895f44ba36cc7b14ff8b2250c7ee

Issue Description:

Hello,

I'm trying to build swift from source by following this documentation https://github.com/apple/swift/blob/main/docs/WindowsBuild.md .

The command that builds the toolchain "ninja -C S:\b\1" fails on "tools/swift/lib/AST/CMakeFiles/swiftAST.dir/Decl.cpp.obj" because of the error: fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj

Shall I add this parameter to be able to build or did I miss something ?

Here is the complete error log:

S:\>ninja -C S:\b\1
ninja: Entering directory `S:\b\1'
[1/1501] Performing build step for 'libdispatch'
ninja: no work to do.
[2/1499] Building CXX object tools\swift\lib\AST\CMakeFiles\swiftAST.dir\Decl.cpp.obj
FAILED: tools/swift/lib/AST/CMakeFiles/swiftAST.dir/Decl.cpp.obj
C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DLLVM_ON_WIN32 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_USE_WINAPI_FAMILY_DESKTOP_APP -D_DLL -D_ENABLE_ATOMIC_ALIGNMENT_FIX -D_ENABLE_EXTENDED_ALIGNED_STORAGE=1 -D_HAS_EXCEPTIONS=0 -D_HAS_STATIC_RTTI=0 -D_MD -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\swift\lib\AST -IS:\swift\lib\AST -Itools\swift\include -IS:\swift\include -Iinclude -IS:\llvm-project\llvm\include -Itools\clang\include -IS:\llvm-project\llvm\..\clang\include -IS:\cmark\src -Itools\cmark\src -IS:\swift-corelibs-libdispatch\src\BlocksRuntime -IS:\swift-corelibs-libdispatch -I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\\include" -I"C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\um" /DWIN32 /D_WINDOWS   /Zc:inline /Zi /Zc:strictStrings /Oi /Zc:rvalueCast /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 -wd4324 -w14062 -we4238 /Gw /we4062 /wd4068 /permissive- -DOBJC_OLD_DISPATCH_PROTOTYPES=0 /MD /O2 /Ob2  /EHs-c- /GR- -UNDEBUG -DSWIFT_LLVM_SUPPORT_IS_AVAILABLE -O2 /GR- -U_DEBUG -std:c++14 /showIncludes /Fotools\swift\lib\AST\CMakeFiles\swiftAST.dir\Decl.cpp.obj /Fdtools\swift\lib\AST\CMakeFiles\swiftAST.dir\swiftAST.pdb /FS -c S:\swift\lib\AST\Decl.cpp
S:\swift\lib\AST\Decl.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj
ninja: build stopped: subcommand failed.
@typesanitizer
Copy link

cc @compnerd

@compnerd
Copy link
Collaborator

Its unclear to me actually; there was a point where I needed that as well. The reason that I hadn't "fixed" this was that I was intentionally waiting. I wanted the rebranch to complete as that had changes that would fix this. I don't seem to need the flags anymore (as it should be added). If you are hitting this stuff after syncing to the latest state of the tree, please let me know, and I can apply the fix for this that I have sitting around (I'll upload it as a draft just incase).

Edit: #35971 is a patch, but if updating the checkout to the latest state resolves the issue, we should just close it.

@swift-ci
Copy link
Collaborator Author

Comment by Yassine BENABBAS (JIRA)

OK thanks 🙂. I'll try compiling again after pulling the latest commits and I'll let you know the results.

@swift-ci
Copy link
Collaborator Author

Comment by Yassine BENABBAS (JIRA)

Hello. I don't have the message anymore and I passed the file that generates the error. I will close the ticket.

However, the RAM consumption become more and more big and it reaches a point where is uses about 60 GB of RAM. Do you have this problem also ?

@swift-ci
Copy link
Collaborator Author

Comment by Yassine BENABBAS (JIRA)

I don't have the issue with the newest commits

@compnerd
Copy link
Collaborator

Yes, that is expected - parallel builds are expensive in terms of RAM, especially if you are building with debug information. I tend to build without debug information and just read through the assembly which avoids excessive memory usage.

@swift-ci
Copy link
Collaborator Author

Comment by Stefan Springer (JIRA)

Get the error `compile with /bigobj` for different modules (CMAKE_BUILD_TYPE=Debug), so why not set an option globally? Or what is the solution besides starting the build process again and again?

UPDATE: answer by Saleem Abdulrasool: -D CMAKE_C_FLAGS="/bigobj" -D CMAKE_CXX_FLAGS="/bigobj" should set the flags globally.

FAILED: tools/clang/tools/extra/clang-tidy/modernize/CMakeFiles/obj.clangTidyModernizeModule.dir/LoopConvertCheck.cpp.obj ... /Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\obj.clangTidyModernizeModule.dir\LoopConvertCheck.cpp.obj /Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\obj.clangTidyModernizeModule.dir\ /FS -c S:\llvm-project\clang-tools-extra\clang-tidy\modernize\LoopConvertCheck.cpp S:\llvm-project\clang-tools-extra\clang-tidy\modernize\LoopConvertCheck.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj [3169/6194] Building CXX object tools\clang\tools\extra\cl...j.clangTidyModernizeModule.dir\ModernizeTidyModule.cpp.obj ninja: build stopped: subcommand failed.

@compnerd
Copy link
Collaborator

If clangTidyModernizeModule is hitting that, this should be reported to llvm.org. That is an upstream issue. I think that they actually would care about this as this indicates that we have triggered yet another way to generate a large number of weak symbols which is annoyingly expensive.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Windows Platform: Windows
Projects
None yet
Development

No branches or pull requests

3 participants