Matthew proposed a patch for this here: https://lists.gnu.org/r/emacs-devel/2017-12/msg00903.html which I am attaching in git form (see first attached patch). I also propose the second attached patch as a followup. It makes some of the newly-added features "private" (since they don't seem to be generally useful) and moves the low-level initialization code from emacs.c to process.c which is a more-natural home for it.