bruno created this revision.
bruno added reviewers: rsmith, echristo.
bruno added subscribers: cfe-commits, friss.
Herald added a subscriber: mehdi_amini.
When building with -fno-gnu-inline-asm and -fmodules on Darwin, the compilation
might fail if some of the implicit modules try to use gnu asm inline. For
example, the issue happens when building _Builtin_intrinsics because of inline
asm in cpuid.h
Add __CLANG_NO_GNU_INLINE_ASM macro when -fno-gnu-inline-asm is used and allow
the user to ifdef asm inline's if desired.
https://reviews.llvm.org/D23859
Files:
lib/Frontend/InitPreprocessor.cpp
lib/Headers/cpuid.h
test/Driver/inline-asm.c
Index: test/Driver/inline-asm.c
===
--- test/Driver/inline-asm.c
+++ test/Driver/inline-asm.c
@@ -22,3 +22,9 @@
// RUN: FileCheck --check-prefix=CHECK-NO-GNU-INLINE-ASM %s
// CHECK-NO-GNU-INLINE-ASM: "-fno-gnu-inline-asm"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -fno-gnu-inline-asm -dM -E %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-NO-GNU-INLINE-ASM-DEFINE %s
+
+// CHECK-NO-GNU-INLINE-ASM-DEFINE: #define __CLANG_NO_GNU_INLINE_ASM 1
Index: lib/Headers/cpuid.h
===
--- lib/Headers/cpuid.h
+++ lib/Headers/cpuid.h
@@ -152,6 +152,8 @@
#define bit_SMEP0x0080
#define bit_ENH_MOVSB 0x0200
+#ifndef __CLANG_NO_GNU_INLINE_ASM
+
#if __i386__
#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \
__asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
@@ -213,3 +215,5 @@
*__sig = __ebx;
return __eax;
}
+
+#endif /* __CLANG_NO_GNU_INLINE_ASM */
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -952,6 +952,9 @@
Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
}
+ if (!LangOpts.GNUAsm)
+Builder.defineMacro("__CLANG_NO_GNU_INLINE_ASM");
+
// OpenCL definitions.
if (LangOpts.OpenCL) {
#define OPENCLEXT(Ext) \
Index: test/Driver/inline-asm.c
===
--- test/Driver/inline-asm.c
+++ test/Driver/inline-asm.c
@@ -22,3 +22,9 @@
// RUN: FileCheck --check-prefix=CHECK-NO-GNU-INLINE-ASM %s
// CHECK-NO-GNU-INLINE-ASM: "-fno-gnu-inline-asm"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -fno-gnu-inline-asm -dM -E %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-NO-GNU-INLINE-ASM-DEFINE %s
+
+// CHECK-NO-GNU-INLINE-ASM-DEFINE: #define __CLANG_NO_GNU_INLINE_ASM 1
Index: lib/Headers/cpuid.h
===
--- lib/Headers/cpuid.h
+++ lib/Headers/cpuid.h
@@ -152,6 +152,8 @@
#define bit_SMEP0x0080
#define bit_ENH_MOVSB 0x0200
+#ifndef __CLANG_NO_GNU_INLINE_ASM
+
#if __i386__
#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \
__asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
@@ -213,3 +215,5 @@
*__sig = __ebx;
return __eax;
}
+
+#endif /* __CLANG_NO_GNU_INLINE_ASM */
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -952,6 +952,9 @@
Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
}
+ if (!LangOpts.GNUAsm)
+Builder.defineMacro("__CLANG_NO_GNU_INLINE_ASM");
+
// OpenCL definitions.
if (LangOpts.OpenCL) {
#define OPENCLEXT(Ext) \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits