dbuild tweaks

Forward port to master of #3639.