cotire icon indicating copy to clipboard operation
cotire copied to clipboard

share precompiled header between targets

Open onqtam opened this issue 8 years ago • 8 comments

I am about to have ~100 small .dll's (with just a few source files or even just one) in which I plan to use the same manually maintained pch. There are hacks (atleast for MSVC) to compile the pch once and with some copying and compiler flags to have all the targets use it - see here.

I was wondering if cotire could abstract this somehow on all platforms/compilers? Has this problem been raised before?

EDIT: I just saw that this is listed as a known issue in README.md...

onqtam avatar Jul 16 '15 16:07 onqtam

Can't somehow precompiled header output directories be the same so intermediate files (and the pch itself) get reused? Something like this:

add_executable(SHARED game game.cpp)
set_target_properties(game PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "pch.h")
cotire(game)

add_library(SHARED dll dll.cpp)
set_target_properties(dll PROPERTIES COTIRE_CXX_PRECOMPILED_HEADER_FROM_TARGET game)
cotire(dll)

Or...

add_executable(SHARED game game.cpp)
set_target_properties(game PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "pch.h")
set_target_properties(game PROPERTIES COTIRE_CXX_PRECOMPILED_HEADER_PATH "some/shared/path")
cotire(game)

add_library(SHARED dll dll.cpp)
set_target_properties(game PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "pch.h")
set_target_properties(game PROPERTIES COTIRE_CXX_PRECOMPILED_HEADER_PATH "some/shared/path")
cotire(dll)

Copying the pch would not be that appropriate if it's a 200mb pch for 100 targets...

onqtam avatar Jul 20 '15 18:07 onqtam

This would be extremely helpful. I have a 50mb PCH deduplicated 30 times because of this :(

jcelerier avatar Nov 12 '15 21:11 jcelerier

Would appreciate that too

mirkow avatar Dec 13 '15 15:12 mirkow

I wanted to do this for unit testing to share the boilerplate code between all the tests, this would be super useful considering the large amount of small binaries I have.

Ryp avatar Jun 24 '16 07:06 Ryp

Any updates on this? What's the benefit in sharing a generated prefix header, but not using the precompiled header?

sbrodehl avatar Jan 17 '18 21:01 sbrodehl

my life in a nutshell:

ls **/*.pch
 40M	API/OSSIA/cotire/ossia_CXX_prefix.hxx.pch
 58M	base/addons/iscore-addon-pd/cotire/score_addon_pd_CXX_prefix.hxx.pch
 58M	base/addons/iscore-addon-shaders/cotire/score_addon_shader_CXX_prefix.hxx.pch
 58M	base/lib/cotire/score_lib_base_CXX_prefix.hxx.pch
 58M	base/plugins/score-lib-device/cotire/score_lib_device_CXX_prefix.hxx.pch
 58M	base/plugins/score-lib-inspector/cotire/score_lib_inspector_CXX_prefix.hxx.pch
 58M	base/plugins/score-lib-process/cotire/score_lib_process_CXX_prefix.hxx.pch
 58M	base/plugins/score-lib-state/cotire/score_lib_state_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-automation/cotire/score_plugin_automation_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-curve/cotire/score_plugin_curve_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-deviceexplorer/cotire/score_plugin_deviceexplorer_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-engine/cotire/score_plugin_engine_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-inspector/cotire/score_plugin_inspector_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-js/cotire/score_plugin_js_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-loop/cotire/score_plugin_loop_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-mapping/cotire/score_plugin_mapping_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-media/cotire/score_plugin_media_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-midi/cotire/score_plugin_midi_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-pluginsettings/cotire/score_plugin_pluginsettings_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-recording/cotire/score_plugin_recording_CXX_prefix.hxx.pch
 58M	base/plugins/score-plugin-scenario/cotire/score_plugin_scenario_CXX_prefix.hxx.pch
1,2G	total

only because I wanted to separate my software in small plug-ins each with their own cmake target...

jcelerier avatar Jan 17 '18 22:01 jcelerier

58 MB for each pch?!?! ONLY?! you lucky bastard :D

onqtam avatar Jan 17 '18 22:01 onqtam

only because I hand-optimized them :p the auto-generated one was north of 130-140mb IIRC and was just making the build slower

jcelerier avatar Jan 17 '18 22:01 jcelerier