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

Add bigobj to msvc compile flags #1124

Closed
wants to merge 3 commits into from
Closed

Add bigobj to msvc compile flags #1124

wants to merge 3 commits into from

Conversation

mkaes
Copy link
Contributor

@mkaes mkaes commented Jan 29, 2024

Adding /bigobj to the compile options fixes an error when trying to compile soci using VS 2019

@vadz
Copy link
Member

vadz commented Feb 6, 2024

Thanks for the fix! I wonder if we could do it tests/CMakeLists.txt instead, as it only affects the (huge, due to common-tests.h inclusion) source file there? I imagine using /bigobj has some drawbacks, even if I'm not sure what they're, as otherwise I don't know why it wouldn't be turned on by default.

@mkaes
Copy link
Contributor Author

mkaes commented Feb 8, 2024

AFAIK there is not real drawback in enabling /bigobj.
The only drawback that the documentation mentions is

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

So I guess it is ok to enable it for all files.
Otherwise it must be enabled when needed for each file.

@vadz
Copy link
Member

vadz commented Feb 8, 2024

AFAIK there is not real drawback in enabling /bigobj.

A quick web search finds this SO answer which states that it results in a 2% size penalty for the object files using it. It's not a lot, but, still, why bloat SOCI objects size if it's only needed for the tests?

So I guess it is ok to enable it for all files. Otherwise it must be enabled when needed for each file.

Could it be enabled just in tests subdirectory as I suggested? If yes, this would be just as simple as doing it here and would be completely uncontroversial (who cares about the tests size...). Could you please test if that works? TIA!

@mkaes
Copy link
Contributor Author

mkaes commented Feb 9, 2024

I enabled the option only for the tests. If other files show the same issue in the future they need to be added afterwards.

I personally find the 2% size penalty a little exaggerated and it is only for the object files. So basically it is only disk space during compile.
That is the reason why I always use bigobj by default. Because as soon as you start using templates you will hit this issue.

@Krzmbrzl
Copy link
Contributor

That is the reason why I always use bigobj by default. Because as soon as you start using templates you will hit this issue.

I can only second this statement. This is my approach as well.
Besides, the size of object files should essentially be of no concern on this scale as modern hardware has more than enough disk space to fit in an extra 2% for bigger object files.
The thing that you get for having smaller object files is that you'll eventually run into (seemingly odd) compiler errors eventually 🤷

@vadz vadz closed this in 41303bf Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants