summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-08-30 18:34:48 +0000
committerEric Christopher <echristo@apple.com>2010-08-30 18:34:48 +0000
commit753f3265dafdcfeec07b561ca278524c35477583 (patch)
treec8adfeeb491b48394175af2929c2ba38323604ae /include
parent2027362e8d99df1780ba604cff624b116a4e6ecf (diff)
downloadllvm-753f3265dafdcfeec07b561ca278524c35477583.tar.gz
llvm-753f3265dafdcfeec07b561ca278524c35477583.tar.bz2
llvm-753f3265dafdcfeec07b561ca278524c35477583.tar.xz
Fix LLVM target initialization to deal with sociopathic outside projects
that like to randomly define things like "X86", regenerate autoconf bits and update cmake. Fixes PR7852. Patch by Xerxes RĂ„nby! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm-c/Target.h11
-rw-r--r--include/llvm/Config/config.h.cmake16
-rw-r--r--include/llvm/Config/config.h.in10
-rw-r--r--include/llvm/Config/llvm-config.h.cmake12
-rw-r--r--include/llvm/Config/llvm-config.h.in10
-rw-r--r--include/llvm/Target/TargetSelect.h20
6 files changed, 44 insertions, 35 deletions
diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h
index 29bd6fec9a..2cd15c3fa3 100644
--- a/include/llvm-c/Target.h
+++ b/include/llvm-c/Target.h
@@ -64,15 +64,10 @@ static inline void LLVMInitializeAllTargets(void) {
for JIT applications to ensure that the target gets linked in correctly. */
static inline LLVMBool LLVMInitializeNativeTarget(void) {
/* If we have a native target, initialize it to ensure it is linked in. */
-#ifdef LLVM_NATIVE_ARCH
-#define DoInit2(TARG) \
- LLVMInitialize ## TARG ## Info (); \
- LLVMInitialize ## TARG ()
-#define DoInit(T) DoInit2(T)
- DoInit(LLVM_NATIVE_ARCH);
+#ifdef LLVM_NATIVE_TARGET
+ LLVM_NATIVE_TARGETINFO();
+ LLVM_NATIVE_TARGET();
return 0;
-#undef DoInit
-#undef DoInit2
#else
return 1;
#endif
diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake
index 81e6ab5748..e8feabffda 100644
--- a/include/llvm/Config/config.h.cmake
+++ b/include/llvm/Config/config.h.cmake
@@ -626,10 +626,16 @@
/* Define to a function implementing strdup */
#cmakedefine strdup ${strdup}
-/* Native LLVM architecture */
-#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}Target
-
-/* Native LLVM architecture, short name */
-#cmakedefine LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH}
+/* LLVM architecture name for the native architecture, if available */
+#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
+
+/* LLVM name for the native Target init function, if available */
+#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target
+
+/* LLVM name for the native TargetInfo init function, if available */
+#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo
+
+/* LLVM name for the native AsmPrinter init function, if available */
+#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter
#endif
diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in
index 911f9877ba..d62da1ab03 100644
--- a/include/llvm/Config/config.h.in
+++ b/include/llvm/Config/config.h.in
@@ -500,8 +500,14 @@
/* LLVM architecture name for the native architecture, if available */
#undef LLVM_NATIVE_ARCH
-/* Short LLVM architecture name for the native architecture, if available */
-#undef LLVM_NATIVE_ARCHNAME
+/* LLVM name for the native AsmPrinter init function, if available */
+#undef LLVM_NATIVE_ASMPRINTER
+
+/* LLVM name for the native Target init function, if available */
+#undef LLVM_NATIVE_TARGET
+
+/* LLVM name for the native TargetInfo init function, if available */
+#undef LLVM_NATIVE_TARGETINFO
/* Define if this is Unixish platform */
#undef LLVM_ON_UNIX
diff --git a/include/llvm/Config/llvm-config.h.cmake b/include/llvm/Config/llvm-config.h.cmake
index b68592a64a..8469bcc606 100644
--- a/include/llvm/Config/llvm-config.h.cmake
+++ b/include/llvm/Config/llvm-config.h.cmake
@@ -50,10 +50,16 @@
#cmakedefine LLVM_MULTITHREADED
/* LLVM architecture name for the native architecture, if available */
-#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}Target
+#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
-/* Short LLVM architecture name for the native architecture, if available */
-#cmakedefine LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH}
+/* LLVM name for the native Target init function, if available */
+#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target
+
+/* LLVM name for the native TargetInfo init function, if available */
+#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo
+
+/* LLVM name for the native AsmPrinter init function, if available */
+#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter
/* Define if this is Unixish platform */
#cmakedefine LLVM_ON_UNIX
diff --git a/include/llvm/Config/llvm-config.h.in b/include/llvm/Config/llvm-config.h.in
index f35859ea04..e7a04ee91b 100644
--- a/include/llvm/Config/llvm-config.h.in
+++ b/include/llvm/Config/llvm-config.h.in
@@ -52,8 +52,14 @@
/* LLVM architecture name for the native architecture, if available */
#undef LLVM_NATIVE_ARCH
-/* Short LLVM architecture name for the native architecture, if available */
-#undef LLVM_NATIVE_ARCHNAME
+/* LLVM name for the native Target init function, if available */
+#undef LLVM_NATIVE_TARGET
+
+/* LLVM name for the native TargetInfo init function, if available */
+#undef LLVM_NATIVE_TARGETINFO
+
+/* LLVM name for the native AsmPrinter init function, if available */
+#undef LLVM_NATIVE_ASMPRINTER
/* Define if this is Unixish platform */
#undef LLVM_ON_UNIX
diff --git a/include/llvm/Target/TargetSelect.h b/include/llvm/Target/TargetSelect.h
index ab6b62b74e..1891f87974 100644
--- a/include/llvm/Target/TargetSelect.h
+++ b/include/llvm/Target/TargetSelect.h
@@ -100,15 +100,10 @@ namespace llvm {
/// It is legal for a client to make multiple calls to this function.
inline bool InitializeNativeTarget() {
// If we have a native target, initialize it to ensure it is linked in.
-#ifdef LLVM_NATIVE_ARCHNAME
-#define DoInit2(TARG) \
- LLVMInitialize ## TARG ## Info (); \
- LLVMInitialize ## TARG ()
-#define DoInit(T) DoInit2(T)
- DoInit(LLVM_NATIVE_ARCH);
+#ifdef LLVM_NATIVE_TARGET
+ LLVM_NATIVE_TARGETINFO();
+ LLVM_NATIVE_TARGET();
return false;
-#undef DoInit
-#undef DoInit2
#else
return true;
#endif
@@ -118,14 +113,9 @@ namespace llvm {
/// this function to initialize the native target asm printer.
inline bool InitializeNativeTargetAsmPrinter() {
// If we have a native target, initialize the corresponding asm printer.
-#ifdef LLVM_NATIVE_ARCH
-#define DoInit2(TARG) \
- LLVMInitialize ## TARG ## AsmPrinter ();
-#define DoInit(T) DoInit2(T)
- DoInit(LLVM_NATIVE_ARCHNAME);
+#ifdef LLVM_NATIVE_ASMPRINTER
+ LLVM_NATIVE_ASMPRINTER();
return false;
-#undef DoInit
-#undef DoInit2
#else
return true;
#endif