Skip to content

Commit 2b9ff4a

Browse files
fanquakehebasto
andcommitted
build: use -mbig-obj for mingw-w64 Debug builds
Windows cross builds using `-O0` currently fail to compile, as some objects have too many sections. As a convenience, add `-mbig-obj` to our compile flags when using the `Debug` build type, so that if someone tries to build this way, it will work. This would also be needed if we switched the depends flags to -O0. `-mbig-obj` > On PE/COFF target this option forces the use of big object > file format, which allows more than 32768 sections. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
1 parent d73f37d commit 2b9ff4a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@ if(WIN32)
298298
try_append_linker_flag("-Wl,--major-subsystem-version,6" TARGET core_interface)
299299
try_append_linker_flag("-Wl,--minor-subsystem-version,2" TARGET core_interface)
300300
endif()
301+
302+
# Workaround producing large object files, which cannot be handled by the assembler.
303+
# More likely to happen with no, or lower levels of optimisation.
304+
# See discussion in https://github.com/bitcoin/bitcoin/issues/28109.
305+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
306+
try_append_cxx_flags("/bigobj" TARGET core_interface_debug SKIP_LINK)
307+
else()
308+
try_append_cxx_flags("-Wa,-mbig-obj" TARGET core_interface_debug SKIP_LINK)
309+
endif()
301310
endif()
302311

303312
# Use 64-bit off_t on 32-bit Linux.

0 commit comments

Comments
 (0)