Skip to content

Improve incremental compile time with explicit template instantiation.

By not including the *T_impl.hh files in the corresponding *T.hh files,
but only providing explicit template declarations and instantiations for
the types we use them for, we can avoid recompilation of code that
(indirectly) depends on the *T.hh files, which turn out to be many.

This still leaves a lot of re-linking with libACG, but at least it's
much faster than before.

The motivation for this MR are a few render bugs I tried to work on, but the extreme amount of recompilation for simple changes in _impl.hh files made it very painful.

This is identical to https://www.graphics.rwth-aachen.de:9000/OpenFlipper-Free/OpenFlipper/-/tree/feature/explicit_template_instantiation except for fixing the botched commit title (Don't really want to increase compile times), which has CI here: https://www.graphics.rwth-aachen.de:9000/OpenFlipper-Free/OpenFlipper-Free/-/pipelines/14683

This still causes a re-link for all libraries that link to libACG, which I tried to alleviate by putting the instantiations into the Type-OpenMesh libraries (cleaner anyways to have the instantiations for types wherever the need for them arises), however I couldn't resolve the resulting linker errors. As most stuff links to them anyways, it might not make a big difference after all.

Unfortunately the build fails on MSVC 2015:

81>e:\gitlab\builds\jyir6yd5\0\openflipper-free\openflipper-free\openflipper\libs_required\acg\gl\DrawMeshT_impl.hh(1842): error C2244: 'ACG::DrawMeshT<Mesh>::updatePerHalfedgeBuffers': unable to match function definition to an existing declaration (compiling source file E:\gitlab\builds\jYir6YD5\0\OpenFlipper-Free\OpenFlipper-Free\OpenFlipper\libs_required\ACG\GL\DrawMeshT_impl.cc)
81>  e:\gitlab\builds\jyir6yd5\0\openflipper-free\openflipper-free\openflipper\libs_required\acg\gl\DrawMeshT_impl.hh(1788): note: see declaration of 'ACG::DrawMeshT<Mesh>::updatePerHalfedgeBuffers' (compiling source file E:\gitlab\builds\jYir6YD5\0\OpenFlipper-Free\OpenFlipper-Free\OpenFlipper\libs_required\ACG\GL\DrawMeshT_impl.cc)
81>  e:\gitlab\builds\jyir6yd5\0\openflipper-free\openflipper-free\openflipper\libs_required\acg\gl\DrawMeshT_impl.hh(1842): note: definition (compiling source file E:\gitlab\builds\jYir6YD5\0\OpenFlipper-Free\OpenFlipper-Free\OpenFlipper\libs_required\ACG\GL\DrawMeshT_impl.cc)
81>  e:\gitlab\builds\jyir6yd5\0\openflipper-free\openflipper-free\openflipper\libs_required\acg\gl\DrawMeshT_impl.hh(1842): note: 'void ACG::DrawMeshT<Mesh>::updatePerHalfedgeBuffers(void)' (compiling source file E:\gitlab\builds\jYir6YD5\0\OpenFlipper-Free\OpenFlipper-Free\OpenFlipper\libs_required\ACG\GL\DrawMeshT_impl.cc)
81>  e:\gitlab\builds\jyir6yd5\0\openflipper-free\openflipper-free\openflipper\libs_required\acg\gl\DrawMeshT_impl.hh(1842): note: existing declarations (compiling source file E:\gitlab\builds\jYir6YD5\0\OpenFlipper-Free\OpenFlipper-Free\OpenFlipper\libs_required\ACG\GL\DrawMeshT_impl.cc)
81>  e:\gitlab\builds\jyir6yd5\0\openflipper-free\openflipper-free\openflipper\libs_required\acg\gl\DrawMeshT_impl.hh(1842): note: 'void ACG::DrawMeshT<Mesh>::updatePerHalfedgeBuffers(void)' (compiling source file E:\gitlab\builds\jYir6YD5\0\OpenFlipper-Free\OpenFlipper-Free\OpenFlipper\libs_required\ACG\GL\DrawMeshT_impl.cc)

and more errors like it.

As it compiles fine in MSVC 2017, I suspect a compiler bug. Do we really have to support such an old compiler or could this be an opportunity to drop support for it? Not sure how to work around this bug.

Edited by Martin Heistermann

Merge request reports