From patchwork Thu Aug 14 20:52:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 35417 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1AD48202E4 for ; Thu, 14 Aug 2014 20:53:19 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf11433120pdb.1 for ; Thu, 14 Aug 2014 13:53:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:message-id:date:from:user-agent:mime-version:to :subject:x-original-sender:x-original-authentication-results :content-type; bh=oBxWYOaksZlu6rL9HEiEIu8WOamdncjT77VAlNtgEyw=; b=d1mi4ebNbISBmBmNw9AiMKuOVcNumrnpTrXiA6mSrTDgzy7o3wxQ1o5wr0Ik5ILJ49 WQb48Nb/IOFkJG6UvywyIDnLV7F0cSuTNQOWPR+/lqmN4f8I9Ad+C1Fgb+sUeUjmI2F5 8BH0EmHwyLwF51vIe2xNMQh6D8S1G65ZUxwvIR8T1uSBIbYPK6j+o1TPLl+YJPscJg6K w0CfjBpC2pTvslyOeehbNmC5zZJHa6Jy/CcDpoobqM64buMMCv/X5rgC+o8HfXPlFoCO 4UOeyw6aOaKoULC9hx+NtZfWUl7s/TyYy9eZHQ4SllwhIRNWrYM3Ro/FEyKlbf6sWfwE Sxnw== X-Gm-Message-State: ALoCoQlTsC6afg6vJeWAwFPzDUOgHj0TZgsPLfXT4EpBS39tJc5lRXIpLAtpVGUqzSza/ZldHqME X-Received: by 10.66.66.196 with SMTP id h4mr6956085pat.22.1408049598397; Thu, 14 Aug 2014 13:53:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.202 with SMTP id c68ls1250375qgf.99.gmail; Thu, 14 Aug 2014 13:53:18 -0700 (PDT) X-Received: by 10.140.84.231 with SMTP id l94mr8601016qgd.84.1408049598280; Thu, 14 Aug 2014 13:53:18 -0700 (PDT) Received: from mail-vc0-x234.google.com (mail-vc0-x234.google.com [2607:f8b0:400c:c03::234]) by mx.google.com with ESMTPS id m3si8984161qac.53.2014.08.14.13.53.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Aug 2014 13:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::234 as permitted sender) client-ip=2607:f8b0:400c:c03::234; Received: by mail-vc0-f180.google.com with SMTP id ij19so2103709vcb.11 for ; Thu, 14 Aug 2014 13:53:18 -0700 (PDT) X-Received: by 10.221.5.137 with SMTP id og9mr6780173vcb.18.1408049597997; Thu, 14 Aug 2014 13:53:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp63946vcb; Thu, 14 Aug 2014 13:53:17 -0700 (PDT) X-Received: by 10.68.69.3 with SMTP id a3mr6903021pbu.94.1408049596830; Thu, 14 Aug 2014 13:53:16 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t7si5311898pdr.201.2014.08.14.13.53.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Aug 2014 13:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-375316-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 21375 invoked by alias); 14 Aug 2014 20:53:05 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 21361 invoked by uid 89); 14 Aug 2014 20:53:04 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Aug 2014 20:53:03 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7EKr2Mc014751 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 14 Aug 2014 16:53:02 -0400 Received: from [10.10.116.31] ([10.10.116.31]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7EKr0TG017234 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 14 Aug 2014 16:53:01 -0400 Message-ID: <53ED21AB.3050905@redhat.com> Date: Thu, 14 Aug 2014 15:52:59 -0500 From: Yaakov Selkowitz User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Gcc Patch List Subject: [PATCH] cygwin: __cxa_atexit support X-Original-Sender: yselkowi@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::234 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 This patch implements __cxa_atexit support for Cygwin targets. This requires Cygwin 1.7.32 and binutils master. Net difference in check-c++ results on i686-pc-cygwin: # of unexpected failures -11 # of unexpected successes -3 # of expected failures -61 # of unsupported tests -46 Index: gcc/config/i386/cygwin.h =================================================================== --- gcc/config/i386/cygwin.h (revision 213759) +++ gcc/config/i386/cygwin.h (working copy) @@ -40,7 +40,7 @@ #define STARTFILE_SPEC "\ %{!shared: %{!mdll: crt0%O%s \ %{pg:gcrt0%O%s}}}\ - crtbegin.o%s" + %{shared:crtbeginS.o%s;:crtbegin.o%s}" #undef ENDFILE_SPEC #define ENDFILE_SPEC \ Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 213759) +++ gcc/config.gcc (working copy) @@ -1575,6 +1575,7 @@ if test x$enable_threads = xyes; then thread_file='posix' fi + default_use_cxa_atexit=yes use_gcc_stdint=wrap ;; x86_64-*-cygwin*) @@ -1590,6 +1591,7 @@ if test x$enable_threads = xyes; then thread_file='posix' fi + default_use_cxa_atexit=yes use_gcc_stdint=wrap tm_defines="${tm_defines} TARGET_CYGWIN64=1" ;; Index: libgcc/config/i386/cygming-crtbegin.c =================================================================== --- libgcc/config/i386/cygming-crtbegin.c (revision 213759) +++ libgcc/config/i386/cygming-crtbegin.c (working copy) @@ -111,6 +111,23 @@ = { }; #endif +#ifdef __CYGWIN__ +/* Declare the __dso_handle variable. It should have a unique value + in every shared-object; in a main program its value is zero. The + object should in any case be protected. This means the instance + in one DSO or the main program is not used in another object. The + dynamic linker takes care of this. */ + +#ifdef CRTSTUFFS_O +extern void *__ImageBase; +void *__dso_handle = &__ImageBase; +#else +void *__dso_handle = 0; +#endif + +#endif /* __CYGWIN__ */ + + /* Pull in references from libgcc.a(unwind-dw2-fde.o) in the startfile. These are referenced by a ctor and dtor in crtend.o. */ extern void __gcc_register_frame (void); @@ -161,6 +178,13 @@ register_class_fn (__JCR_LIST__); } #endif + +#if DEFAULT_USE_CXA_ATEXIT + /* If we use the __cxa_atexit method to register C++ dtors + at object construction, also use atexit to register eh frame + info cleanup. */ + atexit(__gcc_deregister_frame); +#endif /* DEFAULT_USE_CXA_ATEXIT */ } void Index: libgcc/config/i386/cygming-crtend.c =================================================================== --- libgcc/config/i386/cygming-crtend.c (revision 213759) +++ libgcc/config/i386/cygming-crtend.c (working copy) @@ -70,12 +70,6 @@ register_frame_ctor (void) { __gcc_register_frame (); -#if DEFAULT_USE_CXA_ATEXIT - /* If we use the __cxa_atexit method to register C++ dtors - at object construction, also use atexit to register eh frame - info cleanup. */ - atexit (__gcc_deregister_frame); -#endif } #if !DEFAULT_USE_CXA_ATEXIT Index: libgcc/config/i386/t-cygming =================================================================== --- libgcc/config/i386/t-cygming (revision 213759) +++ libgcc/config/i386/t-cygming (working copy) @@ -8,6 +8,9 @@ crtbegin.o: $(srcdir)/config/i386/cygming-crtbegin.c $(crt_compile) -fno-omit-frame-pointer -c $< +crtbeginS.o: $(srcdir)/config/i386/cygming-crtbegin.c + $(crt_compile) -fno-omit-frame-pointer -c $< -DCRTSTUFFS_O + # We intentionally use a implementation-reserved init priority of 0, # so allow the warning. crtend.o: $(srcdir)/config/i386/cygming-crtend.c Index: libgcc/config.host =================================================================== --- libgcc/config.host (revision 213759) +++ libgcc/config.host (working copy) @@ -614,7 +614,7 @@ i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae) ;; i[34567]86-*-cygwin*) - extra_parts="crtbegin.o crtend.o crtfastmath.o" + extra_parts="crtbegin.o crtbeginS.o crtend.o crtfastmath.o" # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h if test x$enable_sjlj_exceptions = xyes; then tmake_eh_file="i386/t-sjlj-eh" @@ -630,7 +630,7 @@ tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_dlldir_file} i386/t-slibgcc-cygming i386/t-cygming i386/t-cygwin i386/t-crtfm i386/t-chkstk t-dfprules" ;; x86_64-*-cygwin*) - extra_parts="crtbegin.o crtend.o crtfastmath.o" + extra_parts="crtbegin.o crtbeginS.o crtend.o crtfastmath.o" # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h if test x$enable_sjlj_exceptions = xyes; then tmake_eh_file="i386/t-sjlj-eh"