Gcc Equivalent of Ms's /Bigobj

GCC equivalent of MS's /bigobj

The solution is to add the option -Wa,-mbig-obj if your version of GCC supports that option. You probably only need it during the compilation step, not the linker step.

If your compiler does not support that option, you should look into using mingw-w64 and MSYS2.

How to set bigobj option when compiling C++ code in Visual Studio Code?

As user4581301 suggested, I had to not separate -Wa and -mbig-obj as two, independent options. Instead, I had to keep them as one option: -Wa,-mbig-obj. This ran into an error, but, per this answer, adding --% as the first argument, coupled with the aforementioned suggestion about the options, got my code finally compiling to an executable. Here is what the tasks.json looks like after the changes:

{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"--%",
"-g",
"-Wa,-mbig-obj",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

Penalty of the MSVS compiler flag /bigobj

The documentation does mention an important drawback to /bigobj:

Linkers that shipped prior to Visual C++ 2005 cannot read .obj files
that were produced with /bigobj.

So, setting this option by default would restrict the number of linkers that can consume the resulting object files. Better to activate it on a need-to basis.

mingw too many sections bug while compiling huge header file in Qt

Such huge header-only code is already bad design, i'd rather recommend to use another library, like muParser.

Your problem was already discussed in other threads, like this.

As you've already noticed, passing /bigobj to Microsoft's compiler
causes it to output a munged COFF format with up to 2^31 sections,
which "should be enough for anybody."

I've tested this new option with MinGW-w64 and it works. You need to
pass -Wa,-mbig-obj to gcc to opt-in to big objects (-Wa means pass
this option to the assembler). – Francis Gagné

What's the best g++ optimization level when building a debug target?

GCC 4.8 introduces a new optimization level: -Og for the best of both worlds.

-Og

Optimize debugging experience. -Og enables optimizations that do not interfere with
debugging. It should be the optimization level of choice for the standard
edit-compile-debug cycle
, offering a reasonable level of optimization while maintaining
fast compilation and a good debugging experience.

This way some optimization is done so you get better performance, better possibly-uninitialized variable detection and you can also step through a program in GDB without jumping back-and-forth through the function.



Related Topics



Leave a reply



Submit