Hi guys, I would like to let you in on some of the good stuff happening on the LLVM/Clang front. This wasn't me though, just forwarding the message as I get it. The main Win64 bug for LLVM/Clang is here: http://llvm.org/bugs/show_bug.cgi?id=9100
Here's some other, more specific things (reported by yours truly mostly): http://llvm.org/bugs/show_bug.cgi?id=9072 And the projects libc++ needs some love as well (I'm mostly looking at the xlocale.h issue and perhaps threading, because I thought someone here had an implementation of std::thread using Windows Vista+ primitives?) Thanks. Ruben ---------- Forwarded message ---------- From: NAKAMURA Takumi <[email protected]> Date: 2011/1/31 Subject: [Review request][Win64] Patches for Mingw-w64(and mingw64-clang) To: "amine.khaldi" <[email protected]>, Anton Korobeynikov <[email protected]>, Michael Spencer <[email protected]>, Óscar Fuentes <[email protected]>, Ruben Van Boxem <[email protected]> Cc: llvm-commits <[email protected]> Good evening, guys! Now I can build clang and llvm on Windows x64 with both mingw-w64-g++ and w64-clang. Here, some patches are, to build. Please take a look into them. I have checked on x86_64-centos5, mingw32(and msys), msvs10 and stage3-mingw64-clang(with my patches). ps. please see also; http://llvm.org/bugs/show_bug.cgi?id=9100 ...Takumi * 0001-Windows-Windows.h-mingw64-might-have-_WIN32_WINN.patch.txt [PR8848] I will honor predefined _WN32_WINNT on x64 compilers. * 0002-Windows-DynamicLibrary.inc-ELM_Callback-fix.patch.txt [PR8848] I split conditions. It would be easier to read, I suppose. * 0003-lib-Target-X86-X86JITInfo.cpp-Add-Win64-stuff.patch.txt It would be essential to run JIT on x64 with mingw64. * 0004-autoconf-define-HAVE_DECL_SETINFORMATIONJOBOBJEC.patch.txt * 0005-Regenerate-configure-and-config.h.in.patch.txt.gz * 0006-CMake-define-HAVE_DECL_SETINFORMATIONJOBOBJECT-f.patch.txt * 0007-Windows-Program.inc-Declare-SetInformationJobObj.patch.txt Ancient mingw32 might not have the declaration of SetInformationJobObject(). Autoconf and CMake can find the decl in windows.h(winbase.h). * 0008-Autoconf-may-check-symbols-in-libgcc.a-for-JIT-o.patch.txt * 0009-Regenerate-configure-and-include-llvm-Config-con.patch.txt.gz * 0010-CMake-may-check-symbols-in-libgcc.a-for-JIT-on-M.patch.txt * 0011-Windows-DynamicLibrary.inc-Split-explicit-symbol.patch.txt I know it would be gross, but I think it practical. Autoconf and CMake seeks symbols for JIT. FIXME: __cmpdi2 and __main would never be referred to by anyone, I guess. FIXME: Is there good way to extract symbols for JIT from lib/CodeGen/SelectionDAG/TargetLowering.cpp? * 0012-autoconf-Seek-strerror_s-with-AC_CHECK_DECLS.patch.txt * 0013-Regenerate-configure-and-include-llvm-Config-con.patch.txt.gz * 0014-CMake-Use-HAVE_DECL_STRERROR_S.patch.txt * 0015-lib-Support-Errno.cpp-Use-HAVE_DECL_STRERROR_S.patch.txt On mingw64, strerror_s() is defined in libs but not defined int string.h by default. AC_CHECK_DECL can inspect the declaration. I wish it would work even if strerror_s() were defined by default!
From 12a7fe6d728fadbcd0f1bee6a6f51e9446546ed1 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Tue, 7 Dec 2010 10:33:35 +0900 Subject: [PATCH 01/15] Windows/Windows.h: mingw64 might have _WIN32_WINNT. --- lib/Support/Windows/Windows.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/lib/Support/Windows/Windows.h b/lib/Support/Windows/Windows.h index 6e0b585..8eaaf31 100644 --- a/lib/Support/Windows/Windows.h +++ b/lib/Support/Windows/Windows.h @@ -17,9 +17,15 @@ //===----------------------------------------------------------------------===// // Require at least Windows 2000 API. +#ifdef _WIN32_WINNT +#if _WIN32_WINNT < 0x0500 +#error "We assume at least Windows 2000 API." +#endif +#else #define _WIN32_WINNT 0x0500 #define _WIN32_IE 0x0500 // MinGW at it again. #define WIN32_LEAN_AND_MEAN +#endif #include "llvm/Config/config.h" // Get build system configuration settings #include <Windows.h> -- 1.7.1.GIT
From 153aaa222fa30c42c6484743ea3e8b2926fbebe4 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Tue, 18 Jan 2011 15:30:58 +0900 Subject: [PATCH 14/15] CMake: Use HAVE_DECL_STRERROR_S. --- cmake/config-ix.cmake | 2 +- include/llvm/Config/config.h.cmake | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 7a4bc4b..4c7cce6 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -120,7 +120,7 @@ check_symbol_exists(sbrk unistd.h HAVE_SBRK) check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL) check_symbol_exists(strerror string.h HAVE_STRERROR) check_symbol_exists(strerror_r string.h HAVE_STRERROR_R) -check_symbol_exists(strerror_s string.h HAVE_STRERROR_S) +check_symbol_exists(strerror_s string.h HAVE_DECL_STRERROR_S) check_symbol_exists(memcpy string.h HAVE_MEMCPY) check_symbol_exists(memmove string.h HAVE_MEMMOVE) check_symbol_exists(setenv stdlib.h HAVE_SETENV) diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index af96713..bc19dbe 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -84,6 +84,10 @@ to 0 if you don't. */ #cmakedefine HAVE_DECL_SETINFORMATIONJOBOBJECT ${HAVE_DECL_SETINFORMATIONJOBOBJECT} +/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_STRERROR_S ${HAVE_DECL_STRERROR_S} + /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_DIRENT_H ${HAVE_DIRENT_H} @@ -390,9 +394,6 @@ /* Define to 1 if you have the `strerror_r' function. */ #cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R} -/* Define to 1 if you have the `strerror_s' function. */ -#cmakedefine HAVE_STRERROR_S ${HAVE_STRERROR_S} - /* Define to 1 if you have the <strings.h> header file. */ #cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H} -- 1.7.1.GIT
From 66d99c25103322e8b698ccf7cf34e814599eca9a Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 19:32:27 +0900 Subject: [PATCH 15/15] lib/Support/Errno.cpp: Use HAVE_DECL_STRERROR_S. --- lib/Support/Errno.cpp | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/Support/Errno.cpp b/lib/Support/Errno.cpp index 312d91e..c2a0f71 100644 --- a/lib/Support/Errno.cpp +++ b/lib/Support/Errno.cpp @@ -50,7 +50,7 @@ std::string StrError(int errnum) { # else strerror_r(errnum,buffer,MaxErrStrLen-1); # endif -#elif defined(HAVE_STRERROR_S) // Windows. +#elif HAVE_DECL_STRERROR_S // MSVCRT.DLL does not provide one. if (errnum) strerror_s(buffer, errnum); #elif defined(HAVE_STRERROR) -- 1.7.1.GIT
From 55a639b49c6f98ccd66ff28a2edc66c1b44264fc Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Tue, 7 Dec 2010 10:32:50 +0900 Subject: [PATCH 02/15] Windows/DynamicLibrary.inc: ELM_Callback fix --- lib/Support/Windows/DynamicLibrary.inc | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/lib/Support/Windows/DynamicLibrary.inc b/lib/Support/Windows/DynamicLibrary.inc index 5fad37a..5e10f77 100644 --- a/lib/Support/Windows/DynamicLibrary.inc +++ b/lib/Support/Windows/DynamicLibrary.inc @@ -55,7 +55,17 @@ extern "C" { // Use new callback if: // - Newer Visual Studio (comes with newer SDK). // - Visual Studio 2005 with Windows SDK 6.0+ -#if !defined(_MSC_VER) || _MSC_VER < 1500 && (!defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 6000) +#if defined(_MSC_VER) + #if _MSC_VER < 1500 && (!defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 6000) + #define OLD_ELM_CALLBACK_DECL 1 + #endif +#elif defined(__MINGW64__) + // Use new callback. +#elif defined(__MINGW32__) + #define OLD_ELM_CALLBACK_DECL 1 +#endif + +#ifdef OLD_ELM_CALLBACK_DECL static BOOL CALLBACK ELM_Callback(PSTR ModuleName, ModuleBaseType ModuleBase, ULONG ModuleSize, -- 1.7.1.GIT
From 4b332e7e9a52c34fcea820b903fad2b83d05c256 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Sun, 19 Dec 2010 15:20:08 +0900 Subject: [PATCH 03/15] lib/Target/X86/X86JITInfo.cpp: Add Win64 stuff. --- lib/Target/X86/X86JITInfo.cpp | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp index 759de77..127738d 100644 --- a/lib/Target/X86/X86JITInfo.cpp +++ b/lib/Target/X86/X86JITInfo.cpp @@ -127,9 +127,17 @@ extern "C" { "movaps %xmm6, 96(%rsp)\n" "movaps %xmm7, 112(%rsp)\n" // JIT callee +#ifdef _WIN64 + "subq $32, %rsp\n" + "movq %rbp, %rcx\n" // Pass prev frame and return address + "movq 8(%rbp), %rdx\n" + "call " ASMPREFIX "X86CompilationCallback2\n" + "addq $32, %rsp\n" +#else "movq %rbp, %rdi\n" // Pass prev frame and return address "movq 8(%rbp), %rsi\n" "call " ASMPREFIX "X86CompilationCallback2\n" +#endif // Restore all XMM arg registers "movaps 112(%rsp), %xmm7\n" "movaps 96(%rsp), %xmm6\n" -- 1.7.1.GIT
From 1b0da0721514257a220a196b8a7aee4e1ea25cc5 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 12:57:55 +0900 Subject: [PATCH 04/15] autoconf: define HAVE_DECL_SETINFORMATIONJOBOBJECT for SetInformationJobObject() on Mingw32. --- autoconf/configure.ac | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 0cc3d3e..cc39ee4 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1220,6 +1220,7 @@ AC_CHECK_LIB(m,sin) if test "$llvm_cv_os_type" = "MingW" ; then AC_CHECK_LIB(imagehlp, main) AC_CHECK_LIB(psapi, main) + AC_CHECK_DECLS([SetInformationJobObject],,,[#include <windows.h>]) fi dnl dlopen() is required for plugin support. -- 1.7.1.GIT
0005-Regenerate-configure-and-config.h.in.patch.txt.gz
Description: GNU Zip compressed data
From 823a234b5b05bde1f1c0106a359b34a43a3795c6 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 19:07:38 +0900 Subject: [PATCH 06/15] CMake: define HAVE_DECL_SETINFORMATIONJOBOBJECT for SetInformationJobObject() on Mingw32. --- cmake/config-ix.cmake | 1 + include/llvm/Config/config.h.cmake | 4 ++++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 4a87a23..68f52ca 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -126,6 +126,7 @@ check_symbol_exists(memmove string.h HAVE_MEMMOVE) check_symbol_exists(setenv stdlib.h HAVE_SETENV) if ( LLVM_ON_WIN32 ) check_symbol_exists(_chsize_s io.h HAVE__CHSIZE_S) + check_symbol_exists(SetInformationJobObject windows.h HAVE_DECL_SETINFORMATIONJOBOBJECT) endif() if( HAVE_ARGZ_H ) check_symbol_exists(argz_append argz.h HAVE_ARGZ_APPEND) diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index e017dd9..ec9c3d0 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -80,6 +80,10 @@ /* Define to 1 if you have the <ctype.h> header file. */ #cmakedefine HAVE_CTYPE_H ${HAVE_CTYPE_H} +/* Define to 1 if you have the declaration of `SetInformationJobObject', and + to 0 if you don't. */ +#cmakedefine HAVE_DECL_SETINFORMATIONJOBOBJECT ${HAVE_DECL_SETINFORMATIONJOBOBJECT} + /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_DIRENT_H ${HAVE_DIRENT_H} -- 1.7.1.GIT
From 09c38b3b6cce54d0afdbe8db6e4fdb48dc0e303a Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 12:59:30 +0900 Subject: [PATCH 07/15] Windows/Program.inc: Declare SetInformationJobObject() if decls not found in Windows.h. --- lib/Support/Windows/Program.inc | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc index 0b92c78..9fcbc8d 100644 --- a/lib/Support/Windows/Program.inc +++ b/lib/Support/Windows/Program.inc @@ -22,7 +22,8 @@ //=== and must not be UNIX code //===----------------------------------------------------------------------===// -#ifdef __MINGW32__ +#if defined(HAVE_DECL_SETINFORMATIONJOBOBJECT) +#if !HAVE_DECL_SETINFORMATIONJOBOBJECT // Ancient mingw32's w32api might not have this declaration. extern "C" BOOL WINAPI SetInformationJobObject(HANDLE hJob, @@ -30,6 +31,7 @@ BOOL WINAPI SetInformationJobObject(HANDLE hJob, LPVOID lpJobObjectInfo, DWORD cbJobObjectInfoLength); #endif +#endif namespace { struct Win32ProcessInfo { -- 1.7.1.GIT
From 3d56ccd8fd75869aebd0413f220b18747c3f2325 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 19:12:15 +0900 Subject: [PATCH 08/15] Autoconf may check symbols in libgcc.a for JIT on Mingw. --- autoconf/configure.ac | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index cc39ee4..225d0f6 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1398,6 +1398,28 @@ AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp]) AC_C_PRINTF_A AC_FUNC_RAND48 +dnl Check symbols in libgcc.a for JIT on Mingw. +if test "$llvm_cv_os_type" = "MingW" ; then + AC_CHECK_LIB(gcc,_alloca,AC_DEFINE([HAVE__ALLOCA],[1],[Have host's _alloca])) + AC_CHECK_LIB(gcc,__alloca,AC_DEFINE([HAVE___ALLOCA],[1],[Have host's __alloca])) + AC_CHECK_LIB(gcc,__chkstk,AC_DEFINE([HAVE___CHKSTK],[1],[Have host's __chkstk])) + AC_CHECK_LIB(gcc,___chkstk,AC_DEFINE([HAVE____CHKSTK],[1],[Have host's ___chkstk])) + + AC_CHECK_LIB(gcc,__ashldi3,AC_DEFINE([HAVE___ASHLDI3],[1],[Have host's __ashldi3])) + AC_CHECK_LIB(gcc,__ashrdi3,AC_DEFINE([HAVE___ASHRDI3],[1],[Have host's __ashrdi3])) + AC_CHECK_LIB(gcc,__divdi3,AC_DEFINE([HAVE___DIVDI3],[1],[Have host's __divdi3])) + AC_CHECK_LIB(gcc,__fixdfdi,AC_DEFINE([HAVE___FIXDFDI],[1],[Have host's __fixdfdi])) + AC_CHECK_LIB(gcc,__fixsfdi,AC_DEFINE([HAVE___FIXSFDI],[1],[Have host's __fixsfdi])) + AC_CHECK_LIB(gcc,__floatdidf,AC_DEFINE([HAVE___FLOATDIDF],[1],[Have host's __floatdidf])) + AC_CHECK_LIB(gcc,__lshrdi3,AC_DEFINE([HAVE___LSHRDI3],[1],[Have host's __lshrdi3])) + AC_CHECK_LIB(gcc,__moddi3,AC_DEFINE([HAVE___MODDI3],[1],[Have host's __moddi3])) + AC_CHECK_LIB(gcc,__udivdi3,AC_DEFINE([HAVE___UDIVDI3],[1],[Have host's __udivdi3])) + AC_CHECK_LIB(gcc,__umoddi3,AC_DEFINE([HAVE___UMODDI3],[1],[Have host's __umoddi3])) + + AC_CHECK_LIB(gcc,__main,AC_DEFINE([HAVE___MAIN],[1],[Have host's __main])) + AC_CHECK_LIB(gcc,__cmpdi2,AC_DEFINE([HAVE___CMPDI2],[1],[Have host's __cmpdi2])) +fi + dnl Check for variations in the Standard C++ library and STL. These macros are dnl provided by LLVM in the autoconf/m4 directory. AC_FUNC_ISNAN -- 1.7.1.GIT
0009-Regenerate-configure-and-include-llvm-Config-con.patch.txt.gz
Description: GNU Zip compressed data
From 33ebabb9345eb70761513af5cd3d0f5b2edfdd65 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 17:56:13 +0900 Subject: [PATCH 10/15] CMake may check symbols in libgcc.a for JIT on Mingw. --- cmake/config-ix.cmake | 20 +++++++++++++++ include/llvm/Config/config.h.cmake | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 0 deletions(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 68f52ca..7a4bc4b 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -127,6 +127,26 @@ check_symbol_exists(setenv stdlib.h HAVE_SETENV) if ( LLVM_ON_WIN32 ) check_symbol_exists(_chsize_s io.h HAVE__CHSIZE_S) check_symbol_exists(SetInformationJobObject windows.h HAVE_DECL_SETINFORMATIONJOBOBJECT) + + check_function_exists(_alloca HAVE__ALLOCA) + check_function_exists(__alloca HAVE___ALLOCA) + check_function_exists(__chkstk HAVE___CHKSTK) + check_function_exists(___chkstk HAVE____CHKSTK) + + check_function_exists(__ashldi3 HAVE___ASHLDI3) + check_function_exists(__ashrdi3 HAVE___ASHRDI3) + check_function_exists(__divdi3 HAVE___DIVDI3) + check_function_exists(__fixdfdi HAVE___FIXDFDI) + check_function_exists(__fixsfdi HAVE___FIXSFDI) + check_function_exists(__floatdidf HAVE___FLOATDIDF) + check_function_exists(__lshrdi3 HAVE___LSHRDI3) + check_function_exists(__moddi3 HAVE___MODDI3) + check_function_exists(__udivdi3 HAVE___UDIVDI3) + check_function_exists(__umoddi3 HAVE___UMODDI3) + + check_function_exists(__main HAVE___MAIN) + check_function_exists(__cmpdi2 HAVE___CMPDI2) + endif() if( HAVE_ARGZ_H ) check_symbol_exists(argz_append argz.h HAVE_ARGZ_APPEND) diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index ec9c3d0..af96713 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -470,9 +470,57 @@ /* Define if the xdot.py program is available */ #undef HAVE_XDOT_PY +/* Have host's _alloca */ +#cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA} + +/* Have host's __alloca */ +#cmakedefine HAVE___ALLOCA ${HAVE___ALLOCA} + +/* Have host's __ashldi3 */ +#cmakedefine HAVE___ASHLDI3 ${HAVE___ASHLDI3} + +/* Have host's __ashrdi3 */ +#cmakedefine HAVE___ASHRDI3 ${HAVE___ASHRDI3} + +/* Have host's __chkstk */ +#cmakedefine HAVE___CHKSTK ${HAVE___CHKSTK} + +/* Have host's __cmpdi2 */ +#cmakedefine HAVE___CMPDI2 ${HAVE___CMPDI2} + +/* Have host's __divdi3 */ +#cmakedefine HAVE___DIVDI3 ${HAVE___DIVDI3} + /* Define to 1 if you have the `__dso_handle' function. */ #undef HAVE___DSO_HANDLE +/* Have host's __fixdfdi */ +#cmakedefine HAVE___FIXDFDI ${HAVE___FIXDFDI} + +/* Have host's __fixsfdi */ +#cmakedefine HAVE___FIXSFDI ${HAVE___FIXSFDI} + +/* Have host's __floatdidf */ +#cmakedefine HAVE___FLOATDIDF ${HAVE___FLOATDIDF} + +/* Have host's __lshrdi3 */ +#cmakedefine HAVE___LSHRDI3 ${HAVE___LSHRDI3} + +/* Have host's __main */ +#cmakedefine HAVE___MAIN ${HAVE___MAIN} + +/* Have host's __moddi3 */ +#cmakedefine HAVE___MODDI3 ${HAVE___MODDI3} + +/* Have host's __udivdi3 */ +#cmakedefine HAVE___UDIVDI3 ${HAVE___UDIVDI3} + +/* Have host's __umoddi3 */ +#cmakedefine HAVE___UMODDI3 ${HAVE___UMODDI3} + +/* Have host's ___chkstk */ +#cmakedefine HAVE____CHKSTK ${HAVE____CHKSTK} + /* Linker version detected at compile time. */ #undef HOST_LINK_VERSION -- 1.7.1.GIT
From 57913b045463a1f0e831bd03868bd4bd5378b517 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Mon, 31 Jan 2011 11:27:12 +0900 Subject: [PATCH 11/15] Windows/DynamicLibrary.inc: Split explicit symbols into explicit_symbols.inc. --- lib/Support/Windows/DynamicLibrary.inc | 77 +++++++----------------------- lib/Support/Windows/explicit_symbols.inc | 66 +++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 lib/Support/Windows/explicit_symbols.inc diff --git a/lib/Support/Windows/DynamicLibrary.inc b/lib/Support/Windows/DynamicLibrary.inc index 5e10f77..2c14366 100644 --- a/lib/Support/Windows/DynamicLibrary.inc +++ b/lib/Support/Windows/DynamicLibrary.inc @@ -120,35 +120,14 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *filename, // Stack probing routines are in the support library (e.g. libgcc), but we don't // have dynamic linking on windows. Provide a hook. -#if defined(__MINGW32__) || defined (_MSC_VER) - #define EXPLICIT_SYMBOL(SYM) \ - if (!strcmp(symbolName, #SYM)) return (void*)&SYM - #define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) \ - if (!strcmp(symbolName, #SYMFROM)) return (void*)&SYMTO - #define EXPLICIT_SYMBOL_DEF(SYM) \ - extern "C" { extern void *SYM; } - - #if defined(__MINGW32__) - EXPLICIT_SYMBOL_DEF(_alloca) - EXPLICIT_SYMBOL_DEF(__main) - EXPLICIT_SYMBOL_DEF(__ashldi3) - EXPLICIT_SYMBOL_DEF(__ashrdi3) - EXPLICIT_SYMBOL_DEF(__cmpdi2) - EXPLICIT_SYMBOL_DEF(__divdi3) - EXPLICIT_SYMBOL_DEF(__fixdfdi) - EXPLICIT_SYMBOL_DEF(__fixsfdi) - EXPLICIT_SYMBOL_DEF(__fixunsdfdi) - EXPLICIT_SYMBOL_DEF(__fixunssfdi) - EXPLICIT_SYMBOL_DEF(__floatdidf) - EXPLICIT_SYMBOL_DEF(__floatdisf) - EXPLICIT_SYMBOL_DEF(__lshrdi3) - EXPLICIT_SYMBOL_DEF(__moddi3) - EXPLICIT_SYMBOL_DEF(__udivdi3) - EXPLICIT_SYMBOL_DEF(__umoddi3) - #elif defined(_MSC_VER) - EXPLICIT_SYMBOL_DEF(_alloca_probe) - #endif -#endif +#define EXPLICIT_SYMBOL(SYM) \ + extern "C" { extern void *SYM; } +#define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) EXPLICIT_SYMBOL(SYMTO) + +#include "explicit_symbols.inc" + +#undef EXPLICIT_SYMBOL +#undef EXPLICIT_SYMBOL2 void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { // First check symbols added via AddSymbol(). @@ -169,39 +148,17 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { } } -#if defined(__MINGW32__) - { - EXPLICIT_SYMBOL(_alloca); - EXPLICIT_SYMBOL(__main); - EXPLICIT_SYMBOL(__ashldi3); - EXPLICIT_SYMBOL(__ashrdi3); - EXPLICIT_SYMBOL(__cmpdi2); - EXPLICIT_SYMBOL(__divdi3); - EXPLICIT_SYMBOL(__fixdfdi); - EXPLICIT_SYMBOL(__fixsfdi); - EXPLICIT_SYMBOL(__fixunsdfdi); - EXPLICIT_SYMBOL(__fixunssfdi); - EXPLICIT_SYMBOL(__floatdidf); - EXPLICIT_SYMBOL(__floatdisf); - EXPLICIT_SYMBOL(__lshrdi3); - EXPLICIT_SYMBOL(__moddi3); - EXPLICIT_SYMBOL(__udivdi3); - EXPLICIT_SYMBOL(__umoddi3); - - EXPLICIT_SYMBOL2(alloca, _alloca); -#undef EXPLICIT_SYMBOL -#undef EXPLICIT_SYMBOL2 -#undef EXPLICIT_SYMBOL_DEF - } -#elif defined(_MSC_VER) + #define EXPLICIT_SYMBOL(SYM) \ + if (!strcmp(symbolName, #SYM)) return (void*)&SYM; + #define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) \ + if (!strcmp(symbolName, #SYMFROM)) return (void*)&SYMTO; + { - EXPLICIT_SYMBOL2(alloca, _alloca_probe); - EXPLICIT_SYMBOL2(_alloca, _alloca_probe); -#undef EXPLICIT_SYMBOL -#undef EXPLICIT_SYMBOL2 -#undef EXPLICIT_SYMBOL_DEF + #include "explicit_symbols.inc" } -#endif + + #undef EXPLICIT_SYMBOL + #undef EXPLICIT_SYMBOL2 return 0; } diff --git a/lib/Support/Windows/explicit_symbols.inc b/lib/Support/Windows/explicit_symbols.inc new file mode 100644 index 0000000..84862d6 --- /dev/null +++ b/lib/Support/Windows/explicit_symbols.inc @@ -0,0 +1,66 @@ +/* in libgcc.a */ + +#ifdef HAVE__ALLOCA + EXPLICIT_SYMBOL(_alloca) + EXPLICIT_SYMBOL2(alloca, _alloca); +#endif +#ifdef HAVE___ALLOCA + EXPLICIT_SYMBOL(__alloca) +#endif +#ifdef HAVE___CHKSTK + EXPLICIT_SYMBOL(__chkstk) +#endif +#ifdef HAVE____CHKSTK + EXPLICIT_SYMBOL(___chkstk) +#endif +#ifdef HAVE___MAIN + EXPLICIT_SYMBOL(__main) // FIXME: Don't call it. +#endif + +#ifdef HAVE___ASHLDI3 + EXPLICIT_SYMBOL(__ashldi3) +#endif +#ifdef HAVE___ASHRDI3 + EXPLICIT_SYMBOL(__ashrdi3) +#endif +#ifdef HAVE___CMPDI2 // FIXME: unused + EXPLICIT_SYMBOL(__cmpdi2) +#endif +#ifdef HAVE___DIVDI3 + EXPLICIT_SYMBOL(__divdi3) +#endif +#ifdef HAVE___FIXDFDI + EXPLICIT_SYMBOL(__fixdfdi) +#endif +#ifdef HAVE___FIXSFDI + EXPLICIT_SYMBOL(__fixsfdi) +#endif +#ifdef HAVE___FIXUNSDFDI + EXPLICIT_SYMBOL(__fixunsdfdi) +#endif +#ifdef HAVE___FIXUNSSFDI + EXPLICIT_SYMBOL(__fixunssfdi) +#endif +#ifdef HAVE___FLOATDIDF + EXPLICIT_SYMBOL(__floatdidf) +#endif +#ifdef HAVE___FLOATDISF + EXPLICIT_SYMBOL(__floatdisf) +#endif +#ifdef HAVE___LSHRDI3 + EXPLICIT_SYMBOL(__lshrdi3) +#endif +#ifdef HAVE___MODDI3 + EXPLICIT_SYMBOL(__moddi3) +#endif +#ifdef HAVE___UDIVDI3 + EXPLICIT_SYMBOL(__udivdi3) +#endif +#ifdef HAVE___UMODDI3 + EXPLICIT_SYMBOL(__umoddi3) +#endif + +/* msvcrt */ +#if defined(_MSC_VER) + EXPLICIT_SYMBOL2(alloca, _alloca_probe); +#endif -- 1.7.1.GIT
From c38b409680ac55e7ecd3152ed786dee7f681a299 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi <[email protected]> Date: Tue, 18 Jan 2011 15:30:58 +0900 Subject: [PATCH 12/15] autoconf: Seek strerror_s() with AC_CHECK_DECLS. AC_CHECK_FUNCS seeks a symbol only in libs. We should check decl in string.h. With recent Mingw, *_s() stuff would be enabled by MINGW_HAS_SECURE_API. --- autoconf/configure.ac | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 225d0f6..72eae40 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1392,12 +1392,15 @@ AC_CHECK_FUNCS([powf fmodf strtof round ]) AC_CHECK_FUNCS([getpagesize getrusage getrlimit setrlimit gettimeofday ]) AC_CHECK_FUNCS([isatty mkdtemp mkstemp ]) AC_CHECK_FUNCS([mktemp posix_spawn realpath sbrk setrlimit strdup ]) -AC_CHECK_FUNCS([strerror strerror_r strerror_s setenv ]) +AC_CHECK_FUNCS([strerror strerror_r setenv ]) AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ]) AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp]) AC_C_PRINTF_A AC_FUNC_RAND48 +dnl Check the declaration of strerror_s(). It is not provided by default on Mingw. +AC_CHECK_DECLS([strerror_s]) + dnl Check symbols in libgcc.a for JIT on Mingw. if test "$llvm_cv_os_type" = "MingW" ; then AC_CHECK_LIB(gcc,_alloca,AC_DEFINE([HAVE__ALLOCA],[1],[Have host's _alloca])) -- 1.7.1.GIT
0013-Regenerate-configure-and-include-llvm-Config-con.patch.txt.gz
Description: GNU Zip compressed data
------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
