From patchwork Fri Oct 5 02:18:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 979262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-486999-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JLtZmF2K"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42RD3M0ZWbz9s4V for ; Fri, 5 Oct 2018 12:19:25 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=Awifuj0ereHP3StGktdDGrKTQenwMGz2VnrGIEWMlz4gDg2mP0 UyHyIUOrNkWybJ9YKl/AQjvPO+2Ly/esryzYN0ChpzYA9Bb4WqNHqL+kKstUKa+J Jjcp7ql0VRhyOE+XtnYageW4rt7S7b1IKX7laeMXFLlb8n9FtSPa9o7k8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=F97GLM+CcV1N8zsz21ZCN2H8FIE=; b=JLtZmF2KwSDZh2C2XSMw KPt0fQJnOIVyNTyYGqdUM/PHvpZYDE8Z9xHhP7DqfR3CGEya351dwd591yhOOjFF zveBqzn14jp6XWtYNyQelgzvgNaZazduOUx8r38TNxXB31Fk6gyB8H5BuNLUUscW 0Z5J2kcC6PNHYOQVNrrzcwI= Received: (qmail 62090 invoked by alias); 5 Oct 2018 02:19:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 61991 invoked by uid 89); 5 Oct 2018 02:19:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=ar, free!, Free!, 8114 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 05 Oct 2018 02:19:00 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6286956127; Thu, 4 Oct 2018 22:18:59 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id epdk3GjQdMUE; Thu, 4 Oct 2018 22:18:59 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id A6B41117EC3; Thu, 4 Oct 2018 22:18:53 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTP id w952IbDE247772; Thu, 4 Oct 2018 23:18:39 -0300 From: Alexandre Oliva To: Jonathan Yong <10walls@gmail.com> Cc: gcc-patches@gcc.gnu.org Subject: introduce --enable-mingw-full32 to default to --large-address-aware Date: Thu, 04 Oct 2018 23:18:37 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Add a configure knob for mingw32 and 64 toolchains to default passing --large-address-aware to the linker, when creating 32-bit binaries. -Wl,--disable-large-address-aware can still reverse its effects. I've tested this with cross i686-pc-mingw32-gcc and x86_64-w64-mingw64-gcc (is this the usual triplet name?), observing the flags passed by gcc to the linker when asked to create an executable program or a dynamic library, in 32- or, with the latter compiler, in 64-bit mode. I wonder if it makes any sense to extend/rename the configure flag to apply to cygwin as well, though it should default to enabled for that platform. I also wonder if it makes sense, at this point, for mingw to default to --large-address-aware (I guess not, but it doesn't hurt to ask, does it? :-) Yet another idea that comes to mind is to introduce gcc flags, say -m32full and -m31, to imply -m32 and also pass either --large-address-aware or --disable-large-address-aware, respectively, to the linker. I suppose it might also make sense to approach this issue from the linker, rather than from GCC, enabling its default to be configured. Would that be preferred? I thought tweaking GCC would be better, for the flag would be visible with -v, both the one passed to the linker and the one passed to GCC configure. It wouldn't be quite as visible as a linker configuration knob. Given all this, is this patch below ok to install, or should I make changes. I've included the configure and config.in changes because they're small enough. Below this first patch, I enclose another patch for cygming.h. for gcc/ChangeLog * configure.ac: Introduce --enable-mingw-full32 to define MINGW_DEFAULT_LARGE_ADDR_AWARE. * configure, config.in: Rebuilt. * config/i386/mingw32.h (LINK_SPEC_LARGE_ADDR_AWARE): Define, based on MINGW_DEFAULT_LARGE_ADDR_AWARE. (LINK_SPEC): Insert it. * config/i386/mingw-264.h: Likewise. --- gcc/config.in | 6 ++++++ gcc/config/i386/mingw-w64.h | 9 +++++++++ gcc/config/i386/mingw32.h | 8 ++++++++ gcc/configure | 26 ++++++++++++++++++++------ gcc/configure.ac | 7 +++++++ 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index 2856e72d627df..05aa7e94c296d 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -2040,6 +2040,12 @@ #endif +/* Define if we should link with --large-address-aware by default */ +#ifndef USED_FOR_TARGET +#undef MINGW_DEFAULT_LARGE_ADDR_AWARE +#endif + + /* Value to set mingw's _dowildcard to. */ #ifndef USED_FOR_TARGET #undef MINGW_DOWILDCARD diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h index 484dc7a9e9f27..00b3f042a36ca 100644 --- a/gcc/config/i386/mingw-w64.h +++ b/gcc/config/i386/mingw-w64.h @@ -81,6 +81,14 @@ along with GCC; see the file COPYING3. If not see #define MULTILIB_DEFAULTS { "m32" } #endif +#undef LINK_SPEC_LARGE_ADDR_AWARE +#if MINGW_DEFAULT_LARGE_ADDR_AWARE +# define LINK_SPEC_LARGE_ADDR_AWARE \ + "%{!shared:%{!mdll:%{" SPEC_32 ":--large-address-aware}}}" +#else +# define LINK_SPEC_LARGE_ADDR_AWARE "" +#endif + #undef LINK_SPEC #define LINK_SPEC SUB_LINK_SPEC " %{mwindows:--subsystem windows} \ %{mconsole:--subsystem console} \ @@ -88,4 +96,5 @@ along with GCC; see the file COPYING3. If not see %{shared: --shared} %{mdll:--dll} \ %{static:-Bstatic} %{!static:-Bdynamic} \ %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ + " LINK_SPEC_LARGE_ADDR_AWARE "\ %(shared_libgcc_undefs)" diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index a66010894208b..c9d8a7a31f30e 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -114,12 +114,20 @@ along with GCC; see the file COPYING3. If not see #define SUBTARGET_EXTRA_SPECS \ { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC } +#if MINGW_DEFAULT_LARGE_ADDR_AWARE +# define LINK_SPEC_LARGE_ADDR_AWARE \ + "%{!shared:%{!mdll:--large-address-aware}}" +#else +# define LINK_SPEC_LARGE_ADDR_AWARE "" +#endif + #define LINK_SPEC "%{mwindows:--subsystem windows} \ %{mconsole:--subsystem console} \ %{shared: %{mdll: %eshared and mdll are not compatible}} \ %{shared: --shared} %{mdll:--dll} \ %{static:-Bstatic} %{!static:-Bdynamic} \ %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ + " LINK_SPEC_LARGE_ADDR_AWARE "\ %(shared_libgcc_undefs)" /* Include in the mingw32 libraries with libgcc */ diff --git a/gcc/configure b/gcc/configure index b7a8e3643778b..21fbda80a3ba7 100755 --- a/gcc/configure +++ b/gcc/configure @@ -927,6 +927,7 @@ enable_sjlj_exceptions with_gcc_major_version_only enable_secureplt enable_mingw_wildcard +enable_mingw_full32 enable_leading_mingw64_underscores enable_cld enable_frame_pointer @@ -1644,6 +1645,8 @@ Optional Features: --enable-secureplt enable -msecure-plt by default for PowerPC --enable-mingw-wildcard Set whether to expand wildcard on command-line. Default to platform configuration + --enable-mingw-full32 Link with --large-address-aware, past 2GiB, by + default --enable-leading-mingw64-underscores enable leading underscores on 64 bit mingw targets --enable-cld enable -mcld by default for 32bit x86 @@ -12002,6 +12005,17 @@ _ACEOF fi +# Check whether --enable-mingw-full32 was given. +if test "${enable_mingw_full32+set}" = set; then : + enableval=$enable_mingw_full32; +fi + +if test x"$enable_mingw_full32" = xyes; then : + +$as_echo "#define MINGW_DEFAULT_LARGE_ADDR_AWARE 1" >>confdefs.h + +fi + # Check whether --enable-leading-mingw64-underscores was given. if test "${enable_leading_mingw64_underscores+set}" = set; then : enableval=$enable_leading_mingw64_underscores; @@ -18460,7 +18474,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18463 "configure" +#line 18477 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18566,7 +18580,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18569 "configure" +#line 18583 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19731,20 +19745,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' diff --git a/gcc/configure.ac b/gcc/configure.ac index 65f9c92ec8522..6272bcaef1c2f 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1826,6 +1826,13 @@ AS_IF([test x"$enable_mingw_wildcard" != xplatform ], $(test x"$enable_mingw_wildcard" = xno; echo $?), [Value to set mingw's _dowildcard to.])]) +AC_ARG_ENABLE(mingw-full32, +[AS_HELP_STRING([--enable-mingw-full32], + [Link with --large-address-aware, past 2GiB, by default])]) +AS_IF([test x"$enable_mingw_full32" = xyes], + [AC_DEFINE([MINGW_DEFAULT_LARGE_ADDR_AWARE], 1, + [Define if we should link with --large-address-aware by default])]) + AC_ARG_ENABLE(leading-mingw64-underscores, AS_HELP_STRING([--enable-leading-mingw64-underscores], [enable leading underscores on 64 bit mingw targets]), ---- define HAVE_GAS_ALIGNED_COMM HAVE_GAS_ALIGNED_COMM is referenced in an initializer in cygming.opt, but it's not guaranteed to be defined by configure, so define it to zero in a cygming-specific header if it's not defined. Ok to install? for gcc/ChangeLog * cygming.h (HAVE_GAS_ALIGNED_COMM): Fallback-define. --- gcc/config/i386/cygming.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index cfe563f47af0b..d7c7dd7057bf6 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -488,3 +488,7 @@ do { \ /* Static stack checking is supported by means of probes. */ #define STACK_CHECK_STATIC_BUILTIN 1 + +#ifndef HAVE_GAS_ALIGNED_COMM +# define HAVE_GAS_ALIGNED_COMM 0 +#endif