mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
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
This commit is contained in:
@ -596,11 +596,17 @@ AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD)
|
|||||||
# If so, define LLVM_NATIVE_ARCH to that LLVM target.
|
# If so, define LLVM_NATIVE_ARCH to that LLVM target.
|
||||||
for a_target in $TARGETS_TO_BUILD; do
|
for a_target in $TARGETS_TO_BUILD; do
|
||||||
if test "$a_target" = "$LLVM_NATIVE_ARCH"; then
|
if test "$a_target" = "$LLVM_NATIVE_ARCH"; then
|
||||||
LLVM_NATIVE_ARCHTARGET="${LLVM_NATIVE_ARCH}Target"
|
AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH, $LLVM_NATIVE_ARCH,
|
||||||
AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCHNAME,$LLVM_NATIVE_ARCH,
|
|
||||||
[Short LLVM architecture name for the native architecture, if available])
|
|
||||||
AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH,$LLVM_NATIVE_ARCHTARGET,
|
|
||||||
[LLVM architecture name for the native architecture, if available])
|
[LLVM architecture name for the native architecture, if available])
|
||||||
|
LLVM_NATIVE_TARGET="LLVMInitialize${LLVM_NATIVE_ARCH}Target"
|
||||||
|
LLVM_NATIVE_TARGETINFO="LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo"
|
||||||
|
LLVM_NATIVE_ASMPRINTER="LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter"
|
||||||
|
AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGET, $LLVM_NATIVE_TARGET,
|
||||||
|
[LLVM name for the native Target init function, if available])
|
||||||
|
AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGETINFO, $LLVM_NATIVE_TARGETINFO,
|
||||||
|
[LLVM name for the native TargetInfo init function, if available])
|
||||||
|
AC_DEFINE_UNQUOTED(LLVM_NATIVE_ASMPRINTER, $LLVM_NATIVE_ASMPRINTER,
|
||||||
|
[LLVM name for the native AsmPrinter init function, if available])
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -207,7 +207,9 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (LLVM_NATIVE_ARCH)
|
if (LLVM_NATIVE_ARCH)
|
||||||
set(LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH})
|
set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target)
|
||||||
|
set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo)
|
||||||
|
set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter)
|
||||||
list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
|
list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
|
||||||
if (NATIVE_ARCH_IDX EQUAL -1)
|
if (NATIVE_ARCH_IDX EQUAL -1)
|
||||||
message(STATUS
|
message(STATUS
|
||||||
|
24
configure
vendored
24
configure
vendored
@ -1414,8 +1414,8 @@ Optional Features:
|
|||||||
--enable-targets Build specific host targets: all or
|
--enable-targets Build specific host targets: all or
|
||||||
target1,target2,... Valid targets are: host, x86,
|
target1,target2,... Valid targets are: host, x86,
|
||||||
x86_64, sparc, powerpc, alpha, arm, mips, spu,
|
x86_64, sparc, powerpc, alpha, arm, mips, spu,
|
||||||
pic16, xcore, msp430, systemz, blackfin, cbe,
|
pic16, xcore, msp430, systemz, blackfin, cbe, and
|
||||||
and cpp (default=all)
|
cpp (default=all)
|
||||||
--enable-cbe-printf-a Enable C Backend output with hex floating point via
|
--enable-cbe-printf-a Enable C Backend output with hex floating point via
|
||||||
%a (default is YES)
|
%a (default is YES)
|
||||||
--enable-bindings Build specific language bindings:
|
--enable-bindings Build specific language bindings:
|
||||||
@ -5007,15 +5007,27 @@ TARGETS_TO_BUILD=$TARGETS_TO_BUILD
|
|||||||
# If so, define LLVM_NATIVE_ARCH to that LLVM target.
|
# If so, define LLVM_NATIVE_ARCH to that LLVM target.
|
||||||
for a_target in $TARGETS_TO_BUILD; do
|
for a_target in $TARGETS_TO_BUILD; do
|
||||||
if test "$a_target" = "$LLVM_NATIVE_ARCH"; then
|
if test "$a_target" = "$LLVM_NATIVE_ARCH"; then
|
||||||
LLVM_NATIVE_ARCHTARGET="${LLVM_NATIVE_ARCH}Target"
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define LLVM_NATIVE_ARCHNAME $LLVM_NATIVE_ARCH
|
#define LLVM_NATIVE_ARCH $LLVM_NATIVE_ARCH
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
LLVM_NATIVE_TARGET="LLVMInitialize${LLVM_NATIVE_ARCH}Target"
|
||||||
|
LLVM_NATIVE_TARGETINFO="LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo"
|
||||||
|
LLVM_NATIVE_ASMPRINTER="LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter"
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define LLVM_NATIVE_TARGET $LLVM_NATIVE_TARGET
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define LLVM_NATIVE_ARCH $LLVM_NATIVE_ARCHTARGET
|
#define LLVM_NATIVE_TARGETINFO $LLVM_NATIVE_TARGETINFO
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define LLVM_NATIVE_ASMPRINTER $LLVM_NATIVE_ASMPRINTER
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@ -11377,7 +11389,7 @@ else
|
|||||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||||
lt_status=$lt_dlunknown
|
lt_status=$lt_dlunknown
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 11381 "configure"
|
#line 11392 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
#if HAVE_DLFCN_H
|
#if HAVE_DLFCN_H
|
||||||
|
@ -64,15 +64,10 @@ static inline void LLVMInitializeAllTargets(void) {
|
|||||||
for JIT applications to ensure that the target gets linked in correctly. */
|
for JIT applications to ensure that the target gets linked in correctly. */
|
||||||
static inline LLVMBool LLVMInitializeNativeTarget(void) {
|
static inline LLVMBool LLVMInitializeNativeTarget(void) {
|
||||||
/* If we have a native target, initialize it to ensure it is linked in. */
|
/* If we have a native target, initialize it to ensure it is linked in. */
|
||||||
#ifdef LLVM_NATIVE_ARCH
|
#ifdef LLVM_NATIVE_TARGET
|
||||||
#define DoInit2(TARG) \
|
LLVM_NATIVE_TARGETINFO();
|
||||||
LLVMInitialize ## TARG ## Info (); \
|
LLVM_NATIVE_TARGET();
|
||||||
LLVMInitialize ## TARG ()
|
|
||||||
#define DoInit(T) DoInit2(T)
|
|
||||||
DoInit(LLVM_NATIVE_ARCH);
|
|
||||||
return 0;
|
return 0;
|
||||||
#undef DoInit
|
|
||||||
#undef DoInit2
|
|
||||||
#else
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -626,10 +626,16 @@
|
|||||||
/* Define to a function implementing strdup */
|
/* Define to a function implementing strdup */
|
||||||
#cmakedefine strdup ${strdup}
|
#cmakedefine strdup ${strdup}
|
||||||
|
|
||||||
/* Native LLVM architecture */
|
/* LLVM architecture name for the native architecture, if available */
|
||||||
#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}Target
|
#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
|
||||||
|
|
||||||
/* Native LLVM architecture, short name */
|
/* LLVM name for the native Target init function, if available */
|
||||||
#cmakedefine LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH}
|
#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
|
#endif
|
||||||
|
@ -500,8 +500,14 @@
|
|||||||
/* LLVM architecture name for the native architecture, if available */
|
/* LLVM architecture name for the native architecture, if available */
|
||||||
#undef LLVM_NATIVE_ARCH
|
#undef LLVM_NATIVE_ARCH
|
||||||
|
|
||||||
/* Short LLVM architecture name for the native architecture, if available */
|
/* LLVM name for the native AsmPrinter init function, if available */
|
||||||
#undef LLVM_NATIVE_ARCHNAME
|
#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 */
|
/* Define if this is Unixish platform */
|
||||||
#undef LLVM_ON_UNIX
|
#undef LLVM_ON_UNIX
|
||||||
|
@ -50,10 +50,16 @@
|
|||||||
#cmakedefine LLVM_MULTITHREADED
|
#cmakedefine LLVM_MULTITHREADED
|
||||||
|
|
||||||
/* LLVM architecture name for the native architecture, if available */
|
/* 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 */
|
/* LLVM name for the native Target init function, if available */
|
||||||
#cmakedefine LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH}
|
#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 */
|
/* Define if this is Unixish platform */
|
||||||
#cmakedefine LLVM_ON_UNIX
|
#cmakedefine LLVM_ON_UNIX
|
||||||
|
@ -52,8 +52,14 @@
|
|||||||
/* LLVM architecture name for the native architecture, if available */
|
/* LLVM architecture name for the native architecture, if available */
|
||||||
#undef LLVM_NATIVE_ARCH
|
#undef LLVM_NATIVE_ARCH
|
||||||
|
|
||||||
/* Short LLVM architecture name for the native architecture, if available */
|
/* LLVM name for the native Target init function, if available */
|
||||||
#undef LLVM_NATIVE_ARCHNAME
|
#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 */
|
/* Define if this is Unixish platform */
|
||||||
#undef LLVM_ON_UNIX
|
#undef LLVM_ON_UNIX
|
||||||
|
@ -100,15 +100,10 @@ namespace llvm {
|
|||||||
/// It is legal for a client to make multiple calls to this function.
|
/// It is legal for a client to make multiple calls to this function.
|
||||||
inline bool InitializeNativeTarget() {
|
inline bool InitializeNativeTarget() {
|
||||||
// If we have a native target, initialize it to ensure it is linked in.
|
// If we have a native target, initialize it to ensure it is linked in.
|
||||||
#ifdef LLVM_NATIVE_ARCHNAME
|
#ifdef LLVM_NATIVE_TARGET
|
||||||
#define DoInit2(TARG) \
|
LLVM_NATIVE_TARGETINFO();
|
||||||
LLVMInitialize ## TARG ## Info (); \
|
LLVM_NATIVE_TARGET();
|
||||||
LLVMInitialize ## TARG ()
|
|
||||||
#define DoInit(T) DoInit2(T)
|
|
||||||
DoInit(LLVM_NATIVE_ARCH);
|
|
||||||
return false;
|
return false;
|
||||||
#undef DoInit
|
|
||||||
#undef DoInit2
|
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
@ -118,14 +113,9 @@ namespace llvm {
|
|||||||
/// this function to initialize the native target asm printer.
|
/// this function to initialize the native target asm printer.
|
||||||
inline bool InitializeNativeTargetAsmPrinter() {
|
inline bool InitializeNativeTargetAsmPrinter() {
|
||||||
// If we have a native target, initialize the corresponding asm printer.
|
// If we have a native target, initialize the corresponding asm printer.
|
||||||
#ifdef LLVM_NATIVE_ARCH
|
#ifdef LLVM_NATIVE_ASMPRINTER
|
||||||
#define DoInit2(TARG) \
|
LLVM_NATIVE_ASMPRINTER();
|
||||||
LLVMInitialize ## TARG ## AsmPrinter ();
|
|
||||||
#define DoInit(T) DoInit2(T)
|
|
||||||
DoInit(LLVM_NATIVE_ARCHNAME);
|
|
||||||
return false;
|
return false;
|
||||||
#undef DoInit
|
|
||||||
#undef DoInit2
|
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user