This relands 07c3b97e (D96945) which was reverted by commit f4935483. The two-stage compilation successfully tests passes on my machine.