From b8a2d224a8743095d36bb9a109ea881376f7f6f7 Mon Sep 17 00:00:00 2001 From: Yaxun Liu Date: Wed, 29 Aug 2018 20:39:22 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340967 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/InitPreprocessor.cpp | 1 + test/Preprocessor/predefined-macros.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 01a74d1290..3a488bb853 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -1128,6 +1128,7 @@ static void InitializePredefinedAuxMacros(const TargetInfo &AuxTI, 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) diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c index 9296b1cf5a..71c3166689 100644 --- a/test/Preprocessor/predefined-macros.c +++ b/test/Preprocessor/predefined-macros.c @@ -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 -- 2.40.0