llvm.org GIT mirror llvm / 3b30a6e
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40600 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 12 years ago
3 changed file(s) with 26 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
765765 dnl===
766766 dnl===-----------------------------------------------------------------------===
767767
768 dnl Check, whether __dso_handle is present
769 AC_CHECK_FUNCS([__dso_handle])
770
768771 dnl See if the llvm-gcc executable can compile to LLVM assembly
769772 AC_CACHE_CHECK([whether llvm-gcc is sane],[llvm_cv_llvmgcc_sanity],
770773 [llvm_cv_llvmgcc_sanity="no"
435435
436436 /* Define to 1 if you have the header file. */
437437 #undef HAVE_WINDOWS_H
438
439 /* Define to 1 if you have the `__dso_handle' function. */
440 #undef HAVE___DSO_HANDLE
438441
439442 /* Installation directory for binary executables */
440443 #undef LLVM_BINDIR
2626 #include "llvm/Target/TargetData.h"
2727 #include "llvm/Target/TargetMachine.h"
2828 #include "llvm/Target/TargetJITInfo.h"
29
30 #include "llvm/Config/config.h"
31
2932 using namespace llvm;
3033
3134 #ifdef __APPLE__
32 #include
33 #if defined(MAC_OS_X_VERSION_10_4) && \
34 ((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
35 (MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \
36 __APPLE_CC__ >= 5330))
37 // __dso_handle is resolved by Mac OS X dynamic linker.
35 // Apple gcc defaults to -fuse-cxa-atexit (i.e. calls __cxa_atexit instead
36 // of atexit). It passes the address of linker generated symbol __dso_handle
37 // to the function.
38 // This configuration change happened at version 5330.
39 # include
40 # if defined(MAC_OS_X_VERSION_10_4) && \
41 ((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
42 (MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \
43 __APPLE_CC__ >= 5330))
44 # ifndef HAVE___DSO_HANDLE
45 # define HAVE___DSO_HANDLE 1
46 # endif
47 # endif
48 #endif
49
50 #if HAVE___DSO_HANDLE
3851 extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
39 #endif
4052 #endif
4153
4254 static struct RegisterJIT {
301313
302314 // If the global is external, just remember the address.
303315 if (GV->isDeclaration()) {
304 #if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_4) && \
305 ((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
306 (MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \
307 __APPLE_CC__ >= 5330))
308 // Apple gcc defaults to -fuse-cxa-atexit (i.e. calls __cxa_atexit instead
309 // of atexit). It passes the address of linker generated symbol __dso_handle
310 // to the function.
311 // This configuration change happened at version 5330.
316 #if HAVE___DSO_HANDLE
312317 if (GV->getName() == "__dso_handle")
313318 return (void*)&__dso_handle;
314319 #endif