Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -1158,8 +1158,16 @@ // Install things like __POWERPC__, __GNUC__, etc into the macro table. if (InitOpts.UsePredefines) { + // CUDA and OpenMP handle preprocessing differently. CUDA wants to see + // identical preprocessed output (as close to it as possible), so it + // provides full set of predefined macros for both sides of compilation. + if (LangOpts.CUDA && PP.getAuxTargetInfo()) + InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts, + Builder); InitializePredefinedMacros(PP.getTargetInfo(), LangOpts, FEOpts, Builder); - if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo()) + // OpenMP relies on selectively picking predefined macros to work around the + // bits of host includes it can't compile during device-side compilation. + if (LangOpts.OpenMPIsDevice && PP.getAuxTargetInfo()) InitializePredefinedAuxMacros(*PP.getAuxTargetInfo(), LangOpts, Builder); // Install definitions to make Objective-C++ ARC work well with various