Fix MSVC Ninja build by adding /Zc:inline on MSVC #7335
+5
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, Open3D fails to compile on MSVC with the Ninja generator (Visual Studio CMake's default) with a "fatal error LNK1189: library limit of 65535 objects exceeded" when linking
Open3D.dll
. Comparing the export.def files of the Ninja and VS Generator builds shows tens-of-thousands of more exports for the Ninja build (most of them Eigen-related). Also, all the individual compiled .obj files (e.g.Indexer.obj
) are about 50-100% larger in file size on Ninja compared to the VS Generator.It turns out the issue is that MSBuild adds
/Zc:inline
by default to thecl
command-line call (without it being present in CMake's CXX flags!), but of course Ninja won't do such "magic". So the flag needs to be added explicitly for Open3D to compile with other generators.Note that
/Zc:inline
does not steer inlining behaviour (as the name might suggest), it merely "Removes unreferenced data or functions", as described by its documentation (https://learn.microsoft.com/en-us/cpp/build/reference/zc-inline-remove-unreferenced-comdat?view=msvc-170).Type
Motivation and Context
See above.
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
See above.