Merge pull request #3980 from klauskiwi/for_2.3.y

Cherry-pick a couple of build fixes from master