[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 29 11:11:21 PDT 2018


yaxunl updated this revision to Diff 163145.
yaxunl added a comment.

Revised by Artem's comments.


https://reviews.llvm.org/D51441

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/predefined-macros.c


Index: test/Preprocessor/predefined-macros.c
===================================================================
--- test/Preprocessor/predefined-macros.c
+++ 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
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1123,6 +1123,7 @@
   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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51441.163145.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180829/7fca9a21/attachment.bin>


More information about the cfe-commits mailing list