Author: yaxunl Date: Wed Aug 29 13:39:22 2018 New Revision: 340967 URL: http://llvm.org/viewvc/llvm-project?rev=340967&view=rev Log: Add predefined macro __gnu_linux__ for proper aux-triple
Clang predefine macro __linx__ for aux-triple with Linux OS but does not predefine macro __gnu_linux__. This causes some compilation error for certain applications, e.g. Eigen. This patch fixes that. Differential Revision: https://reviews.llvm.org/D51441 Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Preprocessor/predefined-macros.c Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=340967&r1=340966&r2=340967&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Aug 29 13:39:22 2018 @@ -1128,6 +1128,7 @@ static void InitializePredefinedAuxMacro if (AuxTriple.getOS() == llvm::Triple::Linux) { Builder.defineMacro("__ELF__"); Builder.defineMacro("__linux__"); + Builder.defineMacro("__gnu_linux__"); // Used in features.h. If this is omitted, math.h doesn't declare float // versions of the functions in bits/mathcalls.h. if (LangOpts.CPlusPlus) Modified: cfe/trunk/test/Preprocessor/predefined-macros.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=340967&r1=340966&r2=340967&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/predefined-macros.c (original) +++ cfe/trunk/test/Preprocessor/predefined-macros.c Wed Aug 29 13:39:22 2018 @@ -183,9 +183,11 @@ // CHECK-HIP: #define __HIP__ 1 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device \ +// RUN: -aux-triple x86_64-unknown-linux -fcuda-is-device \ // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV // CHECK-HIP-DEV-NOT: #define __CUDA_ARCH__ // CHECK-HIP-DEV: #define __HIPCC__ 1 // CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1 // CHECK-HIP-DEV: #define __HIP__ 1 +// CHECK_HIP-DEV: #define __linux__ 1 +// CHECK_HIP-DEV: #define __gnu_linux__ 1 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits