forked from OSchip/llvm-project
Add detection of __dso_handle presence during configure. Use this information in the
JITer (short path is added for darwin). This is needed to properly JIT llvm-gcc-4.2-built binaries, since cxa_atexit is enabled by default on much more targets. llvm-svn: 40600
This commit is contained in:
parent
dff9d69cfb
commit
7ac2521021
|
@ -766,6 +766,9 @@ dnl=== SECTION 9: Additional checks, variables, etc.
|
||||||
dnl===
|
dnl===
|
||||||
dnl===-----------------------------------------------------------------------===
|
dnl===-----------------------------------------------------------------------===
|
||||||
|
|
||||||
|
dnl Check, whether __dso_handle is present
|
||||||
|
AC_CHECK_FUNCS([__dso_handle])
|
||||||
|
|
||||||
dnl See if the llvm-gcc executable can compile to LLVM assembly
|
dnl See if the llvm-gcc executable can compile to LLVM assembly
|
||||||
AC_CACHE_CHECK([whether llvm-gcc is sane],[llvm_cv_llvmgcc_sanity],
|
AC_CACHE_CHECK([whether llvm-gcc is sane],[llvm_cv_llvmgcc_sanity],
|
||||||
[llvm_cv_llvmgcc_sanity="no"
|
[llvm_cv_llvmgcc_sanity="no"
|
||||||
|
|
|
@ -437,6 +437,9 @@
|
||||||
/* Define to 1 if you have the <windows.h> header file. */
|
/* Define to 1 if you have the <windows.h> header file. */
|
||||||
#undef HAVE_WINDOWS_H
|
#undef HAVE_WINDOWS_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `__dso_handle' function. */
|
||||||
|
#undef HAVE___DSO_HANDLE
|
||||||
|
|
||||||
/* Installation directory for binary executables */
|
/* Installation directory for binary executables */
|
||||||
#undef LLVM_BINDIR
|
#undef LLVM_BINDIR
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,29 @@
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetJITInfo.h"
|
#include "llvm/Target/TargetJITInfo.h"
|
||||||
|
|
||||||
|
#include "llvm/Config/config.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <AvailabilityMacros.h>
|
// Apple gcc defaults to -fuse-cxa-atexit (i.e. calls __cxa_atexit instead
|
||||||
#if defined(MAC_OS_X_VERSION_10_4) && \
|
// of atexit). It passes the address of linker generated symbol __dso_handle
|
||||||
((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
|
// to the function.
|
||||||
(MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \
|
// This configuration change happened at version 5330.
|
||||||
__APPLE_CC__ >= 5330))
|
# include <AvailabilityMacros.h>
|
||||||
// __dso_handle is resolved by Mac OS X dynamic linker.
|
# if defined(MAC_OS_X_VERSION_10_4) && \
|
||||||
extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
|
((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
|
||||||
|
(MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \
|
||||||
|
__APPLE_CC__ >= 5330))
|
||||||
|
# ifndef HAVE___DSO_HANDLE
|
||||||
|
# define HAVE___DSO_HANDLE 1
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE___DSO_HANDLE
|
||||||
|
extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct RegisterJIT {
|
static struct RegisterJIT {
|
||||||
|
@ -302,14 +314,7 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) {
|
||||||
|
|
||||||
// If the global is external, just remember the address.
|
// If the global is external, just remember the address.
|
||||||
if (GV->isDeclaration()) {
|
if (GV->isDeclaration()) {
|
||||||
#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_4) && \
|
#if HAVE___DSO_HANDLE
|
||||||
((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
|
|
||||||
(MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \
|
|
||||||
__APPLE_CC__ >= 5330))
|
|
||||||
// Apple gcc defaults to -fuse-cxa-atexit (i.e. calls __cxa_atexit instead
|
|
||||||
// of atexit). It passes the address of linker generated symbol __dso_handle
|
|
||||||
// to the function.
|
|
||||||
// This configuration change happened at version 5330.
|
|
||||||
if (GV->getName() == "__dso_handle")
|
if (GV->getName() == "__dso_handle")
|
||||||
return (void*)&__dso_handle;
|
return (void*)&__dso_handle;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue