Fix unexpected build failures on Mac and Solaris. #4122