From a2beb4292102f82c900b91d6eecdbed10f55276c Mon Sep 17 00:00:00 2001 From: ktietz Date: Tue, 27 Apr 2010 17:48:58 +0000 Subject: [PATCH] 2010-04-27 Kai Tietz * collect2.c (TARGET_64BIT): Redefine to target's default. * tlink.c: Likewise. * config/i386/cygming.h (USER_LABEL_PREFIX): Define dependent to TARGET_64BIT and USE_MINGW64_LEADING_UNDERSCORES. * config/i386/i386.h (CRT_CALL_STATIC_FUNCTION): Use for underscoring __USER_LABEL_PREFIX__. * config/i386/mingw-w64.h (SUB_LINK_ENTRY): New macro. (SUB_LINK_ENTRY32): New. (SUB_LINK_ENTRY64): New. (LINK_SPEC): Replace entry point spec by SUB_LINK_ENTRY. * config/i386/mingw32 (SUB_LINK_ENTRY32): New. (SUB_LINK_ENTRY64): New. (SUB_LINK_ENTRY): New. (LINK_SPEC): Use SUB_LINK_ENTRY instead of hard-coded entry-point. (DWARF2_UNWIND_INFO): Error out for use of dw2 unwind when x64 target is choosen. * config.in (USE_MINGW64_LEADING_UNDERSCORES): New. * configure: Regenerated. * configure.ac (leading-mingw64-underscores): Option added. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158791 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 23 +++++++++++++++++++++++ gcc/collect2.c | 4 ++++ gcc/config.in | 6 ++++++ gcc/config/i386/cygming.h | 5 +++++ gcc/config/i386/i386.h | 9 ++++++--- gcc/config/i386/mingw-w64.h | 17 ++++++++++++++++- gcc/config/i386/mingw32.h | 22 +++++++++++++++++++++- gcc/configure | 18 ++++++++++++++++-- gcc/configure.ac | 8 ++++++++ gcc/tlink.c | 4 ++++ 10 files changed, 109 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6e7bf42293..eba2adab7af 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2010-04-27 Kai Tietz + + * collect2.c (TARGET_64BIT): Redefine to target's default. + * tlink.c: Likewise. + * config/i386/cygming.h (USER_LABEL_PREFIX): Define + dependent to TARGET_64BIT and USE_MINGW64_LEADING_UNDERSCORES. + * config/i386/i386.h (CRT_CALL_STATIC_FUNCTION): Use + for underscoring __USER_LABEL_PREFIX__. + * config/i386/mingw-w64.h (SUB_LINK_ENTRY): New macro. + (SUB_LINK_ENTRY32): New. + (SUB_LINK_ENTRY64): New. + (LINK_SPEC): Replace entry point spec by + SUB_LINK_ENTRY. + * config/i386/mingw32 (SUB_LINK_ENTRY32): New. + (SUB_LINK_ENTRY64): New. + (SUB_LINK_ENTRY): New. + (LINK_SPEC): Use SUB_LINK_ENTRY instead of hard-coded entry-point. + (DWARF2_UNWIND_INFO): Error out for use of dw2 unwind when + x64 target is choosen. + * config.in (USE_MINGW64_LEADING_UNDERSCORES): New. + * configure: Regenerated. + * configure.ac (leading-mingw64-underscores): Option added. + 2010-04-27 Jan Hubicka * doc/invoke.texi (-fipa-profile): Document. diff --git a/gcc/collect2.c b/gcc/collect2.c index ad66202642d..481f73990f9 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -35,6 +35,10 @@ along with GCC; see the file COPYING3. If not see # define SIGCHLD SIGCLD #endif +/* TARGET_64BIT may be defined to use driver specific functionality. */ +#undef TARGET_64BIT +#define TARGET_64BIT TARGET_64BIT_DEFAULT + #ifndef LIBRARY_PATH_ENV #define LIBRARY_PATH_ENV "LIBRARY_PATH" #endif diff --git a/gcc/config.in b/gcc/config.in index 9525625630f..7b04bbcb856 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1679,6 +1679,12 @@ #endif +/* Define if we should use leading underscore on 64 bit mingw targets */ +#ifndef USED_FOR_TARGET +#undef USE_MINGW64_LEADING_UNDERSCORES +#endif + + /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index a726bb4455e..71a5d8d99c9 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -39,6 +39,11 @@ along with GCC; see the file COPYING3. If not see #undef DEFAULT_ABI #define DEFAULT_ABI (TARGET_64BIT ? MS_ABI : SYSV_ABI) +#if ! defined (USE_MINGW64_LEADING_UNDERSCORES) +#undef USER_LABEL_PREFIX +#define USER_LABEL_PREFIX (TARGET_64BIT ? "" : "_") +#endif + #undef DBX_REGISTER_NUMBER #define DBX_REGISTER_NUMBER(n) \ (TARGET_64BIT ? dbx64_register_map[n] \ diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 4b83370c9a6..163cda189d0 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2148,9 +2148,12 @@ do { \ /* Switch to init or fini section via SECTION_OP, emit a call to FUNC, and switch back. For x86 we do this only to save a few bytes that would otherwise be unused in the text section. */ -#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ - asm (SECTION_OP "\n\t" \ - "call " USER_LABEL_PREFIX #FUNC "\n" \ +#define CRT_MKSTR2(VAL) #VAL +#define CRT_MKSTR(x) CRT_MKSTR2(x) + +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n\t" \ + "call " CRT_MKSTR(__USER_LABEL_PREFIX__) #FUNC "\n" \ TEXT_SECTION_ASM_OP); /* Print operand X (an rtx) in assembler syntax to file FILE. diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h index 85840826674..3aafb933dd4 100644 --- a/gcc/config/i386/mingw-w64.h +++ b/gcc/config/i386/mingw-w64.h @@ -39,6 +39,8 @@ along with GCC; see the file COPYING3. If not see #define ASM_SPEC "%{v:-v} %{n} %{T} %{Ym,*} %{Yd,*} \ %{Wa,*:%*} %{m32:--32} %{m64:--64}" +#undef SPEC_32 +#undef SPEC_64 #if TARGET_64BIT_DEFAULT #define SPEC_32 "m32" #define SPEC_64 "!m32" @@ -47,8 +49,21 @@ along with GCC; see the file COPYING3. If not see #define SPEC_64 "m64" #endif +#undef SUB_LINK_ENTRY32 +#undef SUB_LINK_ENTRY64 +#define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12" +#if defined(USE_MINGW64_LEADING_UNDERSCORES) +#define SUB_LINK_ENTRY64 "-e _DllMainCRTStartup" +#else +#define SUB_LINK_ENTRY64 "-e DllMainCRTStartup" +#endif + +#undef SUB_LINK_SPEC +#undef SUB_LINK_ENTRY #define SUB_LINK_SPEC "%{" SPEC_64 ":-m i386pep} %{" SPEC_32 ":-m i386pe}" +#define SUB_LINK_ENTRY "%{" SPEC_64 ":" SUB_LINK_ENTRY64 "} %{" SPEC_32 ":" SUB_LINK_ENTRY32 "}" +#undef MULTILIB_DEFAULTS #if TARGET_64BIT_DEFAULT #define MULTILIB_DEFAULTS { "m64" } #else @@ -61,5 +76,5 @@ along with GCC; see the file COPYING3. If not see %{shared: %{mdll: %eshared and mdll are not compatible}} \ %{shared: --shared} %{mdll:--dll} \ %{static:-Bstatic} %{!static:-Bdynamic} \ - %{shared|mdll: -e _DllMainCRTStartup@12 --enable-auto-image-base} \ + %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ %(shared_libgcc_undefs)" diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index 2e877d8d2f0..e08ea1cd90c 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -47,6 +47,22 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#undef SUB_LINK_ENTRY32 +#undef SUB_LINK_ENTRY64 +#define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12" +#if defined(USE_MINGW64_LEADING_UNDERSCORES) +#define SUB_LINK_ENTRY64 "-e _DllMainCRTStartup" +#else +#define SUB_LINK_ENTRY64 "-e DllMainCRTStartup" +#endif + +#undef SUB_LINK_ENTRY +#if TARGET_64BIT_DEFAULT +#define SUB_LINK_ENTRY SUB_LINK_ENTRY64 +#else +#define SUB_LINK_ENTRY SUB_LINK_ENTRY32 +#endif + /* Override the standard choice of /usr/include as the default prefix to try when searching for header files. */ #undef STANDARD_INCLUDE_DIR @@ -66,6 +82,10 @@ along with GCC; see the file COPYING3. If not see /* Weak symbols do not get resolved if using a Windows dll import lib. Make the unwind registration references strong undefs. */ #if DWARF2_UNWIND_INFO +/* DW2-unwind is just available for 32-bit mode. */ +#if TARGET_64BIT_DEFAULT +#error DW2 unwind is not available for 64-bit. +#endif #define SHARED_LIBGCC_UNDEFS_SPEC \ "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}" #else @@ -81,7 +101,7 @@ along with GCC; see the file COPYING3. If not see %{shared: %{mdll: %eshared and mdll are not compatible}} \ %{shared: --shared} %{mdll:--dll} \ %{static:-Bstatic} %{!static:-Bdynamic} \ - %{shared|mdll: -e _DllMainCRTStartup@12 --enable-auto-image-base} \ + %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ %(shared_libgcc_undefs)" /* Include in the mingw32 libraries with libgcc */ diff --git a/gcc/configure b/gcc/configure index 0515812873d..17effdae994 100755 --- a/gcc/configure +++ b/gcc/configure @@ -895,6 +895,7 @@ enable_initfini_array enable_sjlj_exceptions with_system_libunwind enable_secureplt +enable_leading_mingw64_underscores enable_cld enable_win32_registry enable_static @@ -1592,6 +1593,8 @@ Optional Features: --enable-sjlj-exceptions arrange to use setjmp/longjmp exception handling --enable-secureplt enable -msecure-plt by default for PowerPC + --enable-leading-mingw64-underscores + Enable leading underscores on 64 bit mingw targets --enable-cld enable -mcld by default for 32bit x86 --disable-win32-registry disable lookup of installation paths in the @@ -10685,6 +10688,17 @@ if test "${enable_secureplt+set}" = set; then : fi +# Check whether --enable-leading-mingw64-underscores was given. +if test "${enable_leading_mingw64_underscores+set}" = set; then : + enableval=$enable_leading_mingw64_underscores; +fi + +if test x"$enable_leading_mingw64_underscores" = xyes ; then : + +$as_echo "#define USE_MINGW64_LEADING_UNDERSCORES 1" >>confdefs.h + +fi + # Check whether --enable-cld was given. if test "${enable_cld+set}" = set; then : enableval=$enable_cld; @@ -17094,7 +17108,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17097 "configure" +#line 17111 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17200,7 +17214,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17203 "configure" +#line 17217 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 67973b1fec6..cd31f4e6db8 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1568,6 +1568,14 @@ AC_ARG_ENABLE(secureplt, [ --enable-secureplt enable -msecure-plt by default for PowerPC], [], []) +AC_ARG_ENABLE(leading-mingw64-underscores, + AS_HELP_STRING([--enable-leading-mingw64-underscores], + [Enable leading underscores on 64 bit mingw targets]), + [],[]) +AS_IF([ test x"$enable_leading_mingw64_underscores" = xyes ], + [AC_DEFINE(USE_MINGW64_LEADING_UNDERSCORES, 1, + [Define if we should use leading underscore on 64 bit mingw targets])]) + AC_ARG_ENABLE(cld, [ --enable-cld enable -mcld by default for 32bit x86], [], [enable_cld=no]) diff --git a/gcc/tlink.c b/gcc/tlink.c index 1894c6c709a..7b589832b06 100644 --- a/gcc/tlink.c +++ b/gcc/tlink.c @@ -32,6 +32,10 @@ along with GCC; see the file COPYING3. If not see #include "collect2.h" #include "libiberty.h" +/* TARGET_64BIT may be defined to use driver specific functionality. */ +#undef TARGET_64BIT +#define TARGET_64BIT TARGET_64BIT_DEFAULT + #define MAX_ITERATIONS 17 /* Defined in the automatically-generated underscore.c. */ -- 2.11.0