Skip to content

Commit e4c3c6c

Browse files
committedAug 30, 2018
Reverted the "[CUDA/OpenMP] Define only some host macros during device compilation"
The changes were breaking CUDA compilation. Reverted revisions: r340681 D50845 [CUDA/OpenMP] Define only some host macros during device compilation r340772 D51312 [OpenMP][NVPTX] Use appropriate _CALL_ELF macro when offloading r340967 D51441 Add predefined macro __gnu_linux__ for proper aux-triple llvm-svn: 341115
1 parent 3572b0b commit e4c3c6c

File tree

1 file changed

+6
-46
lines changed

1 file changed

+6
-46
lines changed
 

‎clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,50 +1099,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
10991099
TI.getTargetDefines(LangOpts, Builder);
11001100
}
11011101

1102-
/// Initialize macros based on AuxTargetInfo.
1103-
static void InitializePredefinedAuxMacros(const TargetInfo &AuxTI,
1104-
const LangOptions &LangOpts,
1105-
MacroBuilder &Builder) {
1106-
auto AuxTriple = AuxTI.getTriple();
1107-
1108-
// Define basic target macros needed by at least bits/wordsize.h and
1109-
// bits/mathinline.h.
1110-
// On PowerPC, explicitely set _CALL_ELF macro needed for gnu/stubs.h.
1111-
switch (AuxTriple.getArch()) {
1112-
case llvm::Triple::x86_64:
1113-
Builder.defineMacro("__x86_64__");
1114-
break;
1115-
case llvm::Triple::ppc64:
1116-
Builder.defineMacro("__powerpc64__");
1117-
Builder.defineMacro("_CALL_ELF", "1");
1118-
break;
1119-
case llvm::Triple::ppc64le:
1120-
Builder.defineMacro("__powerpc64__");
1121-
Builder.defineMacro("_CALL_ELF", "2");
1122-
break;
1123-
default:
1124-
break;
1125-
}
1126-
1127-
// libc++ needs to find out the object file format and threading API.
1128-
if (AuxTriple.getOS() == llvm::Triple::Linux) {
1129-
Builder.defineMacro("__ELF__");
1130-
Builder.defineMacro("__linux__");
1131-
Builder.defineMacro("__gnu_linux__");
1132-
// Used in features.h. If this is omitted, math.h doesn't declare float
1133-
// versions of the functions in bits/mathcalls.h.
1134-
if (LangOpts.CPlusPlus)
1135-
Builder.defineMacro("_GNU_SOURCE");
1136-
} else if (AuxTriple.isOSDarwin()) {
1137-
Builder.defineMacro("__APPLE__");
1138-
Builder.defineMacro("__MACH__");
1139-
} else if (AuxTriple.isOSWindows()) {
1140-
Builder.defineMacro("_WIN32");
1141-
if (AuxTriple.isWindowsGNUEnvironment())
1142-
Builder.defineMacro("__MINGW32__");
1143-
}
1144-
}
1145-
11461102
/// InitializePreprocessor - Initialize the preprocessor getting it and the
11471103
/// environment ready to process a single file. This returns true on error.
11481104
///
@@ -1164,9 +1120,13 @@ void clang::InitializePreprocessor(
11641120

11651121
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
11661122
if (InitOpts.UsePredefines) {
1167-
InitializePredefinedMacros(PP.getTargetInfo(), LangOpts, FEOpts, Builder);
1123+
// FIXME: This will create multiple definitions for most of the predefined
1124+
// macros. This is not the right way to handle this.
11681125
if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo())
1169-
InitializePredefinedAuxMacros(*PP.getAuxTargetInfo(), LangOpts, Builder);
1126+
InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts,
1127+
Builder);
1128+
1129+
InitializePredefinedMacros(PP.getTargetInfo(), LangOpts, FEOpts, Builder);
11701130

11711131
// Install definitions to make Objective-C++ ARC work well with various
11721132
// C++ Standard Library implementations.

0 commit comments

Comments
 (0)
Please sign in to comment.