Backport build fix from trunk