From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 132583858014 for ; Thu, 6 Jan 2022 08:27:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 132583858014 Received: by mail-wm1-x330.google.com with SMTP id c66so1213930wma.5 for ; Thu, 06 Jan 2022 00:27:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:subject:message-id:date:cc:to; bh=kQ/roInLEbDeUDCGQllGdCsYGEkZR2/fDgCdR1/EBqI=; b=oBKlcTgCh/jaQwouRMvT1P8jJkebbhcxg0HYGJfcMHWttTzTdsM7Xv4yvyCRjXe7gH L9SzmIczc0ikh1V5lbVkWrqVqVzC8bpKqqNl4TtBAzgVIw+QsGOAYPRyr8JRoRhgyfkb 7m3xoVqO59BigF5DXJYWxCOKmVOQwisWNGIPwDgcX+Qk+RxJrkIaFIS16ekj4wG7fVoc iVg8jZSBgsj3w3aKe5fyNTRZQz+leg+tuputPf+cK3lheaP1Q6jD0L0Xy4g/TxBhdcBR N0Zl041IeyUJiGdV2UbVT8vAvkmMhPJSbT9f/DyJBswFH95Iwrm9Epc3KQUYeTMohpbR wg4g== X-Gm-Message-State: AOAM5306AYFlSOGbIauP6/apdhNZ2F6RMLt9cdeihqDzP0x/F+KBf77X 8Nkl3OguojP/y0/QQ/Um2tMdeChJMWgdMQ== X-Google-Smtp-Source: ABdhPJxq9GCP7Y8iAIQ4lsXKAZEaIK621w2hIJTsXzCpcjQ4j0/+UGnnP60pCSHB3Q7y4drIsshk0g== X-Received: by 2002:a05:600c:2159:: with SMTP id v25mr5935217wml.131.1641457618972; Thu, 06 Jan 2022 00:26:58 -0800 (PST) Received: from imac.home (2a01cb0002912700a0edb343af58cf97.ipv6.abo.wanadoo.fr. [2a01:cb00:291:2700:a0ed:b343:af58:cf97]) by smtp.gmail.com with ESMTPSA id u14sm1358005wrf.39.2022.01.06.00.26.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jan 2022 00:26:58 -0800 (PST) From: Olivier Hainque Content-Type: multipart/mixed; boundary="Apple-Mail=_2FA53479-6370-4A93-97E0-5EBB0A7F1D72" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: [PATCH] Improve sequence logic in cxx_init_decl_processing Message-Id: <5A7D4F1E-B0ED-48F0-B94B-6A355C46730E@adacore.com> Date: Thu, 6 Jan 2022 09:26:58 +0100 Cc: Olivier Hainque , Rasmus Villemoes , jason@redhat.com To: gcc-patches X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jan 2022 08:27:03 -0000 --Apple-Mail=_2FA53479-6370-4A93-97E0-5EBB0A7F1D72 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hello, commit aa2c978400f3b3ca6e9f2d18598a379589e77ba0, introduced per https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545552.html makes references to __cxa_pure_virtual weak and this is causing issues on some VxWorks configurations, where weak symbols are only supported for one of the two major operating modes, and not on all versions. While trying to circumvent that, I noticed that the current code in cxx_init_decl_processing does something like: if (flag_weak) /* If no definition is available, resolve references to NULL. */ declare_weak (abort_fndecl); ... if (! supports_one_only ()) flag_weak = 0; The code possibly resetting flag_weak should presumlably execute before the test checking the flag, or we'd need a comment explaining why this surprising order is on purpose. The attached patch just moves the reset above the test. It bootstraps/regtests fine on x86_64-linux and allows better control on vxWorks. I'm not yet clear on some of the ramifications there (tigthening the definitions of SUPPORTS_ONE_ONLY and TARGET_SUPPORTS_WEAK yields lots of dg test failures) but that's another story. Ok to commit? Thanks in advance! 2021-12-30 Olivier Hainque gcc/ * cp/decl.c (cxx_init_decl_processing): Move code possibly altering flag_weak before code testing it. Olivier --Apple-Mail=_2FA53479-6370-4A93-97E0-5EBB0A7F1D72 Content-Disposition: attachment; filename=0001-Improve-sequence-logic-in-cxx_init_decl_processing.patch Content-Type: application/octet-stream; x-unix-mode=0640; name="0001-Improve-sequence-logic-in-cxx_init_decl_processing.patch" Content-Transfer-Encoding: quoted-printable =46rom=20bac3f8fad76fa4f406e0c96906cfdd4b6609744c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Olivier=20Hainque=20=0A= Date:=20Thu,=2030=20Dec=202021=2020:47:31=20+0000=0ASubject:=20[PATCH]=20= Improve=20sequence=20logic=20in=20cxx_init_decl_processing=0A=0AChecking=20= for=20one_only/weak=20support=20is=20better=20done=0Abefore=20deciding=20= to=20turn=20references=20to=20__cxa_pure_virtual=20weak.=0A=0AThis=20= helps=20at=20least=20on=20VxWorks=20where=20one_only=20/=20weak=20= support=0Avaries=20between=20kernel=20and=20rtp=20modes=20as=20well=20as=20= across=20VxWorks=0Aversions.=0A=0A2021-12-30=20=20Olivier=20Hainque=20=20= =0A=0Agcc/=0A=09*=20cp/decl.c=20= (cxx_init_decl_processing):=20Move=20code=20possibly=0A=09altering=20= flag_weak=20before=20code=20testing=20it.=0A---=0A=20gcc/cp/decl.c=20|=20= 6=20+++---=0A=201=20file=20changed,=203=20insertions(+),=203=20= deletions(-)=0A=0Adiff=20--git=20a/gcc/cp/decl.c=20b/gcc/cp/decl.c=0A= index=200b71c00f5ab..993c7105784=20100644=0A---=20a/gcc/cp/decl.c=0A+++=20= b/gcc/cp/decl.c=0A@@=20-4718,6=20+4718,9=20@@=20cxx_init_decl_processing=20= (void)=0A=20=20=20=20=20nullptr_node=20=3D=20build_int_cst=20= (nullptr_type_node,=200);=0A=20=20=20}=0A=20=0A+=20=20if=20(!=20= supports_one_only=20())=0A+=20=20=20=20flag_weak=20=3D=200;=0A+=0A=20=20=20= abort_fndecl=0A=20=20=20=20=20=3D=20build_library_fn_ptr=20= ("__cxa_pure_virtual",=20void_ftype,=0A=20=09=09=09=20=20=20=20= ECF_NORETURN=20|=20ECF_NOTHROW=20|=20ECF_COLD);=0A@@=20-4733,9=20+4736,6=20= @@=20cxx_init_decl_processing=20(void)=0A=20=20=20if=20(flag_exceptions)=0A= =20=20=20=20=20init_exception_processing=20();=0A=20=0A-=20=20if=20(!=20= supports_one_only=20())=0A-=20=20=20=20flag_weak=20=3D=200;=0A-=0A=20=20=20= if=20(modules_p=20())=0A=20=20=20=20=20init_modules=20(parse_in);=0A=20=0A= --=20=0A2.25.1=0A=0A= --Apple-Mail=_2FA53479-6370-4A93-97E0-5EBB0A7F1D72 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_2FA53479-6370-4A93-97E0-5EBB0A7F1D72--