MinGW build failure due to too many sections
Closed this issue · 2 comments
ascii-parser.cc generates too many sections and started to fail to compile with mingw(tested gcc version 10-win32 20220113 (GCC) )
/usr/bin/ccache /usr/bin/x86_64-w64-mingw32-g++-posix -DTINYUSDZ_USE_USDOBJ -DTINYUSDZ_USE_USDVOX -DTINYUSDZ_WITH_AUDIO -DTINYUSDZ_WITH_COLORIO -DTINYUSDZ_WITH_EXR -DTINYUSDZ_WITH_OPENSUBDIV @CMakeFiles/tinyusdz_static.dir/includes_CXX.rsp -fno-exceptions -std=c++14 -MD -MT CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj -MF CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj.d -o CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj -c /home/syoyo/work/tinyusdz/src/ascii-parser.cc /usr/bin/x86_64-w64-mingw32-as: CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj: too many sections (49543) /tmp/ccDaFAT8.s: Assembler messages: /tmp/ccDaFAT8.s: Fatal error: can't write 3887 bytes to section .text of CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj: 'file too big' /usr/bin/x86_64-w64-mingw32-as: CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj: too many sections (49543) /tmp/ccDaFAT8.s: Fatal error: CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj: file too big make[2]: *** [CMakeFiles/tinyusdz_static.dir/build.make:140: CMakeFiles/tinyusdz_static.dir/src/ascii-parser.cc.obj] Error 1
Maybe related to assimp/assimp#177
Solution
- Add bigobj flag as done in MSVC https://github.com/syoyo/tinyusdz/blob/39f0eec4b88b63c331749c183a7f417af8c54f50/CMakeLists.txt#L517
- Clean up code(remove template code as much as possible) and split source file
ascii-parser.cc
to reduce sections generated.
One of the source of the issue is here: https://github.com/syoyo/tinyusdz/blob/39f0eec4b88b63c331749c183a7f417af8c54f50/src/ascii-parser.cc#L6729
Removing PARSE_TYPE
goes compile ok.
Still linking takes too much time so it'd be better to do split a source file or investigate further to reduce sections generated in the object file.
Split ascii-parser.cc files into multiple files to work around this issue.
Good side effect is we now don't need /bigobj
flag in MSVC build.
https://github.com/syoyo/tinyusdz/blob/2645cf722b99005320fe02712d448b87bcc783f9/CMakeLists.txt#L520
TODO: Use less template code in TimeSample and merge ascii-parser related .cc files into a single file.