From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id AEBDC3858D37 for ; Mon, 10 Oct 2022 08:28:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AEBDC3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32d.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so5954978wmb.0 for ; Mon, 10 Oct 2022 01:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=to:cc:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=TJybsMfIMAxKnEjotGKkqHMW7XYMOPtG/15BXKp4aYg=; b=k5sOeXWa/ZOko69N19Kx0SLPvug4KM3sT9I2eDK19Apf6pO6lfBqdYatP7gQkYZ0VA zGk9rlFg2PUheNY0WjdgoiHXfbJElVZKUY7iHh7ueEJYh/lnwNL0LQjKmRbwvOH2KL6t rckdKw7REeYPtKovwxQf7TcegN3xSXV48N3oTdkG1TS2hRHxOkGLYkzE/L0fDsK+iwDe sf+Fmj+KwNO9aKF33OObcpL6v8fKFNVGUaLjw0P0EVYj93QqUVWixbO+rtEINXsbzHRT XNt32OrFyoKGMNBYuYIUChdtL0vv7MeSljc33QS16ritODgpXIKi+iUvcdvtHUUMrSX4 G8DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=TJybsMfIMAxKnEjotGKkqHMW7XYMOPtG/15BXKp4aYg=; b=Z6oCMZQ2zVWWU9LaDlC+eL1SZmSZW1wWqofqp+VGPQpY0s6FNsTPaGqW3kMgLIYw6J KNuoZLNsW/64iG7FK4iW4jBz3CCUWbi/z1N6L+if81ZAj/Zv5UzmC3qgR/88zdTs7yaP oQnWsh3cU5klCtoG4Sj7Jmz37mhQiO4A11Op9OcBTHRtVfswDGKkfwui3j0AFXzJBYuw YPU84RY5kRADg+T7c7Osw3W3UGuyECiVD1kOZRYAG4I/FpY3fQOqpiTF/vzeNkp0V3yA /pPh7hqbjbF2EkZXtZwhOqMTkaeKUkXuoit4wskYAHXKJY+uYWQqJsoUvbs++rZsm6KL +GDA== X-Gm-Message-State: ACrzQf08kuB4JFOuFChXDg/0cheG/PddpXc6gagDiLs/vGLMgIAT8CPP tgCdcBRRAFqIszQY/hDqh0XKTpSm1gbZ5Q== X-Google-Smtp-Source: AMsMyM5600oofnU1/BGGLGyFPU20SQEdYw9Znm5AC42Em4F6+UEGUQ6IDIkVvzrWerzaoN/Nu8izFg== X-Received: by 2002:a05:600c:4e90:b0:3b4:cb93:7d11 with SMTP id f16-20020a05600c4e9000b003b4cb937d11mr11777513wmq.43.1665390497385; Mon, 10 Oct 2022 01:28:17 -0700 (PDT) Received: from smtpclient.apple ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id c190-20020a1c35c7000000b003b492338f45sm9907864wma.39.2022.10.10.01.28.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2022 01:28:14 -0700 (PDT) From: Olivier Hainque Content-Type: multipart/mixed; boundary="Apple-Mail=_477C108C-A227-484D-AED7-9AFB0C9CA18C" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: [patch] Tighten VXWORKS_LIBGCC_SPEC wrt libgcc_eh Message-Id: <2D131115-9D29-4050-AE74-E1799882F91D@adacore.com> Date: Mon, 10 Oct 2022 10:28:14 +0200 Cc: Olivier Hainque To: gcc-patches X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --Apple-Mail=_477C108C-A227-484D-AED7-9AFB0C9CA18C Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hello, VxWorks has a custom definition of LIBGCC_SPEC to accommodate the variety of "modules" a user can build (dkm, sharedlib (-shared), static rtp, or rtp depending on shared libs (-non-static)) This change reworks that spec to better support configurations with shared libraries enabled (patch coming) and document the variations. The change also prepares for a possible dual-eh (dwarf+sjlj) setup, which we (AdaCore) work on proposing. The impact on this patch is really minimal and there's no functional impact at all in the interim. The bulk of the change consists in the introduction of a couple of local macros that instantiate the link options needed to include libgcc_eh in the closure, with values depending on the configuration characteristics. A few comments are added to explain the general idea and each of the variations. Part of the changes consist in adding -lgcc after -lgcc_eh to accommodate configurations where libgcc_eh legitimately resort to libgcc functions on some targets, for example cas synchronisation routines on aarch64. We have been using this for a while in house for gcc-11 based toolchains targetting a range of vxworks7r2 configurations (arm, aarch64, ppc, ppc64, x86, x86_64, with shared libraries enabled for all the 64bit variants), as well as for vxworks6.9 on powerpc. I have verified that gcc-12 based toolchain for arm, ppc and ppc64 behave as expected and performed a sanity check build for powerpc64-vxworks7r2 on mainline. Will commit shortly. Cheers, Olivier 2022-10-09 Olivier Hainque * config/vxworks (VX_LGCC_EH_SO0, VX_LGCC_EH_SO1): New internal macros. (VXWORKS_LIBGCC_SPEC): Use them and document. --Apple-Mail=_477C108C-A227-484D-AED7-9AFB0C9CA18C Content-Disposition: attachment; filename=0001-Tigthen-the-addition-of-lgcc_eh-to-vxworks_libgcc_sp.patch Content-Type: application/octet-stream; x-unix-mode=0640; name="0001-Tigthen-the-addition-of-lgcc_eh-to-vxworks_libgcc_sp.patch" Content-Transfer-Encoding: quoted-printable =46rom=20dce5f64ff7b387ca966a19345939a8b7d0515c91=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Olivier=20Hainque=20=0A= Date:=20Fri,=2018=20Feb=202022=2022:44:53=20+0000=0ASubject:=20[PATCH=20= 1/2]=20Tigthen=20the=20addition=20of=20-lgcc_eh=20to=20= vxworks_libgcc_spec=0A=0AThis=20change=20refines=20VXWORKS_LIBGCC_SPEC=20= wrt=20the=20inclusion=0Aof=20-lgcc_eh.=0A=0AUnless=20the=20compiler=20= features=20support=20for=20dual=20sjlj=20and=0Atable=20based=20eh,=20= libgcc_eh.a=20is=20available=20only=20with=20multilib=0Avariants=20for=20= which=20we=20build=20a=20shared=20lib=20(mrtp=20on=20VxWorks).=0A=0A= Rework=20logic=20to=20handle=20absence=20of=20libgcc_s=0Afor=20-mrtp=20= -mcmodel=3Dlarge,=20using=20a=20conditional=20expr=20kind=20of=0Aspec.=0A= =0AThe=20gthread=20support=20in=20libgcc_eh=20might=20resort=20to=20= libgcc=0Afunctions=20on=20some=20targets,=20e.g.=20cas=20synchronisation=20= routines=0Aon=20aarch64.=20Arrange=20to=20append=20-lgcc=20also=20after=20= -lgcc_eh=0Ain=20VXWORKS_LIBGCC_SPEC.=0A---=0A=20gcc/config/vxworks.h=20|=20= 48=20++++++++++++++++++++++++++++++++++++++++----=0A=201=20file=20= changed,=2044=20insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20= a/gcc/config/vxworks.h=20b/gcc/config/vxworks.h=0Aindex=20= 075a45109e8..e7e5ffe9999=20100644=0A---=20a/gcc/config/vxworks.h=0A+++=20= b/gcc/config/vxworks.h=0A@@=20-224,14=20+224,54=20@@=20extern=20void=20= vxworks_driver_init=20(unsigned=20int=20*,=20struct=20cl_decoded_option=20= **);=0A=20#undef=20VXWORKS_LINK_SPEC=0A=20#define=20VXWORKS_LINK_SPEC=20= VXWORKS_BASE_LINK_SPEC=20"=20"=20VXWORKS_EXTRA_LINK_SPEC=0A=20=0A+/*=20= Control=20how=20to=20include=20libgcc=20in=20the=20link=20closure,=20= handling=20both=20"shared"=0A+=20=20=20and=20"non-static"=20in=20= addition=20to=20"static-libgcc"=20when=20shared=20lib=20support=20is=0A+=20= =20=20enabled.=20=20*/=0A+=0A=20#undef=20VXWORKS_LIBGCC_SPEC=0A+=0A+/*=20= libgcc_eh=20control;=20libgcc_eh.a=20is=20available=20either=20together=20= with=20libgcc_s=0A+=20=20=20(mrtp=20and=20mcmodel!=3Dlarge=20when=20= configured=20with=20--enable-shared)=20or=20when=20the=0A+=20=20=20= compiler=20is=20specially=20setup=20to=20support=20dual=20= sjlj/table-based=20eh.=20=20*/=0A+=0A+/*=20VX_LGCC_EH_SO1:=20The=20= "-lgcc_eh"=20part=20we=20need=20in=20situations=20where=20we=20know=20a=0A= +=20=20=20shared=20libgcc=20is=20available=20(ENABLE_SHARED_LIBGCC=20+=20= mrtp=20multilib).=20=20*/=0A+=0A+#define=20VX_LGCC_EH_SO1=20"=20-lgcc_eh=20= -lgcc"=0A+/*=20Extra=20-lgcc=20to=20handle=20functions=20from=20= libgcc_eh=20that=20refer=20to=20symbols=0A+=20=20=20exposed=20by=20= libgcc=20and=20not=20guaranteed=20to=20be=20dragged=20in=20before=20= -lgcc_eh=0A+=20=20=20appears.=20=20*/=0A+=0A+/*=20VX_LGCC_EH_SO0:=20The=20= "-lgcc_eh"=20part=20we=20need=20in=20situations=20where=20we=20know=20a=0A= +=20=20=20shared=20libgcc=20is=20not=20available=20= (!ENABLE_SHARED_LIBGCC=20or=20!mrtp=20multlib).=20=20*/=0A+=0A+#if=20= !defined(CONFIG_DUAL_EXCEPTIONS)=0A+=0A+/*=20No=20shared=20lib=20&&=20= !DUAL_EH=20->=20no=20libgcc_eh=20available=20at=20all.=20=20*/=0A= +#define=20VX_LGCC_EH_SO0=0A+=0A+#else=20/*=20CONFIG_DUAL_EXCEPTIONS=20=20= */=0A+=0A+/*=20No=20shared=20lib=20but=20DUAL_EH=20->=20libgcc_eh=20= around=20and=20spec=20handled=20by=20the=20driver=0A+=20=20=20depending=20= on=20ENABLE_SHARED_LIBGCC.=20=20If=20defined,=20the=20driver=20expects=20= a=20regular=0A+=20=20=20sequence.=20=20Otherwise,=20the=20driver=20is=20= expected=20to=20turn=20-lgcc=20into=20-lgcc_eh=20on=0A+=20=20=20its=20= own=20and=20just=20add=20an=20instance=20to=20address=20possible=20cross=20= refs.=20=20*/=0A+=0A+#if=20defined(ENABLE_SHARED_LIBGCC)=0A+#define=20= VX_LGCC_EH_SO0=20"=20-lgcc_eh=20-lgcc"=0A+#else=0A+#define=20= VX_LGCC_EH_SO0=20"=20-lgcc"=0A+#endif=0A+=0A+#endif=20/*=20= CONFIG_DUAL_EXCEPTIONS=20=20*/=0A+=0A=20#if=20= defined(ENABLE_SHARED_LIBGCC)=0A=20#define=20VXWORKS_LIBGCC_SPEC=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20\=0A-"%{!mrtp:-lgcc=20= -lgcc_eh}=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20\=0A-=20%{mrtp:%{!static-libgcc:%{shared|non-static:-lgcc_s;:-lgcc=20= -lgcc_eh}}=20=20\=0A-=20=20=20=20=20=20=20=20=20%{static-libgcc:-lgcc=20= -lgcc_eh}}"=0A+=20=20"%{!mrtp|mcmodel=3Dlarge:-lgcc"=20VX_LGCC_EH_SO0=20= ";"=09=09=09\=0A+=20=20"=20= :%{!static-libgcc:%{shared|non-static:-lgcc_s;:-lgcc"=20VX_LGCC_EH_SO1=20= "}}=20\=0A+=20=20=20=20=20%{static-libgcc:-lgcc"=20VX_LGCC_EH_SO1=20"}}"=0A= =20#else=0A-#define=20VXWORKS_LIBGCC_SPEC=20"-lgcc"=0A+#define=20= VXWORKS_LIBGCC_SPEC=20"-lgcc"=20VX_LGCC_EH_SO0=0A=20#endif=0A=20=0A=20/*=20= Setup=20the=20crtstuff=20begin/end=20we=20might=20need=20for=20dwarf=20= EH=20registration=0A--=20=0A2.25.1=0A=0A= --Apple-Mail=_477C108C-A227-484D-AED7-9AFB0C9CA18C Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_477C108C-A227-484D-AED7-9AFB0C9CA18C--