Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Penalty of the MSVS compiler flag /bigobj

The basic Google search bigobj issue shows that a lot of people are experiencing the Fatal Error C1128: "number of sections exceeded object file format limit : compile with /bigobj". The error has more chance to occur if one heavily uses a library of C++ templates, like Boost libraries or CGAL libraries.

That error is strange, because it gives the solution to itself: set the compiler flag /bigobj!

So here is my question: why is not that flag set by default? There must be a penalty of using that flag, otherwise it would be set by default. That penalty is not documented in MSDN. Does anybody have a clue?

I ask the question because I wonder if the configuration system of CGAL should not set /bigobj by default.

like image 670
lrineau Avatar asked Feb 27 '13 11:02

lrineau


2 Answers

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.

like image 54
Frédéric Hamidi Avatar answered Nov 14 '22 03:11

Frédéric Hamidi


why is not that flag set by default? There must be a penalty of using that flag, otherwise it would be set by default.

My quick informal experiment shows .obj files to be about 2% larger with /bigobj than without. So it's a small penalty but it's not zero.

Someone submitted a feature request to make /bigobj the default; see https://developercommunity.visualstudio.com/t/Enable-bigobj-by-default/1031214.

like image 38
Conrad Poelman Avatar answered Nov 14 '22 04:11

Conrad Poelman