Global aspects of spontaneous compactification