From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 6D1C63858C74 for ; Thu, 29 Sep 2022 16:48:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D1C63858C74 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-ej1-x630.google.com with SMTP id lc7so4076151ejb.0 for ; Thu, 29 Sep 2022 09:48:17 -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; bh=LGt0G77LBmjUbzEP3Ko0f91wCdvCwEMjF9i9utT6l3U=; b=TjtK0YKxej/DBPUAI7FvPARU6aT/1FQ6pckI5xMUn3NKtyk02L46wEr1vEsic7zxtX XgCKto6Fsrxr1tY+MzHiTc+WPXtOTTJcXmtBBeXlMPkevebnOSaelXllcoYapJGSGAQ6 oNixcd/X33vXWmjhClLQByY/g1ij5HEJyRt7+imDliwMDXXdPh8ZsJPlQcnelh/nWPzF A1idMzvs9TCFYru+fejRiq/X2xSnsbWbWg8tLmXSwHK7PFqSA+F2FCV+o9C5EKY26pA0 +h5mzSivCYJnvfneqQBdPFrzggKz7zg8q7mL4uXnUp1sYVjMpHKLqt8PgNXrjkQ7YlDW j+2Q== 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; bh=LGt0G77LBmjUbzEP3Ko0f91wCdvCwEMjF9i9utT6l3U=; b=Cydu/TpWZJb5L3H8tVGwWPvM81bYVk2570zFY4h9BfaqFVWQEg9cuxmtROb3brYGLi zR/3UF553hmmPhB3vQteneTUp/VvEi/uXYF4aRXBdvjDvNQIhD/LtCt7rOWLM0PsSmFL 6O86Y90tLQL6BxRT7uozxcdv5FAbwGgnBUz9NLs3rcRkx+SxmuaD9mKfa57bsbRci4HT VXemsD4xcYvh62q3vTN/esEFzC/heqFcNkIVMiz9Ugc4BEQvPYSWzEwf/R2ng1johexw lTH3i8zkFDKweSzaKIiJVmGZ9DEJgC4geUjJBVVQgwtd4GimNlriwzisXHN7tF8EzLTC GqOw== X-Gm-Message-State: ACrzQf2/blHSAQBHmQMuOtTM7kN03mfaYHDKL6uMfHG2hjSV70A8wyWN CY5ZU2RVXAdCPA9dZuFYWg+AmTT1YH8LWg== X-Google-Smtp-Source: AMsMyM4m64ctz45AZwCITW9luPxFD49aDq0W+iArbwLkVQnxEIM24iAyc/RN+T3GTx5hFlZTPqdwyw== X-Received: by 2002:a17:906:ef8c:b0:77c:8d9a:9aed with SMTP id ze12-20020a170906ef8c00b0077c8d9a9aedmr3537495ejb.704.1664470095688; Thu, 29 Sep 2022 09:48:15 -0700 (PDT) Received: from smtpclient.apple ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id 2-20020a170906308200b0073d70df6e56sm4231333ejv.138.2022.09.29.09.48.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2022 09:48:14 -0700 (PDT) From: Olivier Hainque Content-Type: multipart/mixed; boundary="Apple-Mail=_F46080D9-8292-4DEE-A0BF-F66296E977C2" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: [patch] Define a GCC_DRIVER_HOST_INITIALIZATION for VxWorks Message-Id: <73648BDD-B1E7-4EDD-8BFA-06C97F4702B5@adacore.com> Date: Thu, 29 Sep 2022 18:48:13 +0200 Cc: Olivier Hainque , Marc Poulhies To: gcc-patches X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Spam-Status: No, score=-4.2 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=_F46080D9-8292-4DEE-A0BF-F66296E977C2 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hello, This change prepares the ground prior to the reintroduction of shared libs support for VxWorks. On this platform, the use of shared libraries involves unusual steps compared to standard native systems and enforcing static links by default improves user experience. This change arranges for the driver to insert a '-static' option by default for this purpose. g++ makes choices depending on such options from its lang_specific_driver, so our default needs to be conveyed before that and specs aren't handled early enough. We then proceed by defining a GCC_DRIVER_HOST_INITIALIZATION macro for VxWorks, to insert a -static option in case the user hasn't provided any explicit indication on the command line of the kind of link desired. While a HOST macro doesn't seem appropriate to control a target OS driven behavior, this matches other uses and won't conflict as VxWorks is not supported on any of the other configurations using this macro, and we expect at least warnings if a not a plain failure if a build with conflicting definitions is attempted. We have been using this in gcc-11 based production compilers for a while. I have performed a couple of build+test cycles on gcc-12 for powerpc64-vxworks7r2 and powerpc-vxworks6.9, and did a sanity checking build of all-gcc for arm-wrs-vxworks7r2. Cheers, Olivier 2022-09-29 Marc Poulhies Olivier Hainque gcc/ * config/vxwkorks/vxwkorks-driver.cc: New. * config.gcc (*vxwkorks*): Add vxworks-driver.o in extra_gcc_objs. * config/t-vxworks: Add vxworks-driver.o. * config/vxworks.h (GCC_DRIVER_HOST_INITIALIZATION): New. --Apple-Mail=_F46080D9-8292-4DEE-A0BF-F66296E977C2 Content-Disposition: attachment; filename=0016-Define-GCC_DRIVER_HOST_INITIALIZATION-for-VxWorks-ta.patch Content-Type: application/octet-stream; x-unix-mode=0640; name="0016-Define-GCC_DRIVER_HOST_INITIALIZATION-for-VxWorks-ta.patch" Content-Transfer-Encoding: quoted-printable =46rom=2039ef29459c8f17471b769fb36adf413dd974447a=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Marc=3D20Poulhi=3DC3=3DA8s?=3D=20= =0ADate:=20Tue,=204=20Jan=202022=2014:56:27=20= +0000=0ASubject:=20[PATCH=2016/18]=20Define=20= GCC_DRIVER_HOST_INITIALIZATION=20for=20VxWorks=0A=20targets=0A=0AThis=20= change=20prepares=20the=20ground=20prior=20to=20the=20reintroduction=20= of=0Ashared=20libs=20support=20for=20VxWorks.=0A=0AOn=20this=20platform,=20= the=20use=20of=20shared=20libraries=20involves=20unusual=0Asteps=20= compared=20to=20standard=20native=20systems=20and=20enforcing=20static=0A= links=20by=20default=20improves=20user=20experience.=0A=0AThis=20change=20= arranges=20for=20the=20driver=20to=20insert=20a=20'-static'=20option=20= by=0Adefault=20for=20this=20purpose.=0A=0Ag++=20makes=20choices=20= depending=20on=20such=20options=20from=20its=0Alang_specific_driver,=20= so=20our=20default=20needs=20to=20be=20conveyed=20before=0Athat=20and=20= specs=20aren't=20handled=20early=20enough.=0A=0AWe=20then=20proceed=20by=20= defining=20a=20GCC_DRIVER_HOST_INITIALIZATION=20macro=0Afor=20VxWorks,=20= to=20insert=20a=20-static=20option=20in=20case=20the=20user=20hasn't=20= provided=0Aany=20explicit=20indication=20on=20the=20command=20line=20of=20= the=20kind=20of=20link=20desired.=0A=0AWhile=20a=20HOST=20macro=20= doesn't=20seem=20appropriate=20to=20control=20a=20target=20OS=0Adriven=20= behavior,=20this=20matches=20other=20uses=20and=20won't=20conflict=20as=20= VxWorks=0Ais=20not=20supported=20on=20any=20of=20the=20other=20= configurations=20using=20this=20macro,=0Aand=20we=20expect=20at=20least=20= warnings=20if=20a=20not=20a=20plain=20failure=20if=20a=20build=0Awith=20= conflicting=20definitions=20is=20attempted.=0A=0AWe=20have=20been=20= using=20this=20in=20gcc-11=20based=20production=20compilers=20for=0Aa=20= while.=20I=20have=20performed=20a=20couple=20of=20build+test=20cycles=20= on=20gcc-12=0Afor=20powerpc64-vxworks7r2=20and=20powerpc-vxworks6.9,=20= and=20did=20a=20sanity=0Achecking=20build=20of=20all-gcc=20for=20= arm-wrs-vxworks7r2.=0A=0A2022-09-29=20=20Marc=20Poulhies=20=20= =0A=20=20=20=20=20=20=20=20=20=20=20=20Olivier=20= Hainque=20=20=0A=0Agcc/=0A=09*=20= config/vxwkorks/vxwkorks-driver.cc:=20New.=0A=09*=20config.gcc=20= (*vxwkorks*):=20Add=20vxworks-driver.o=20in=20extra_gcc_objs.=0A=09*=20= config/t-vxworks:=20Add=20vxworks-driver.o.=0A=09*=20config/vxworks.h=20= (GCC_DRIVER_HOST_INITIALIZATION):=20New.=0A---=0A=20gcc/config.gcc=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20|=20=202=20+=0A=20= gcc/config/t-vxworks=20=20=20=20=20=20=20=20=20|=20=204=20++=0A=20= gcc/config/vxworks-driver.cc=20|=2093=20= ++++++++++++++++++++++++++++++++++++=0A=20gcc/config/vxworks.h=20=20=20=20= =20=20=20=20=20|=2010=20++++=0A=204=20files=20changed,=20109=20= insertions(+)=0A=20create=20mode=20100644=20gcc/config/vxworks-driver.cc=0A= =0Adiff=20--git=20a/gcc/config.gcc=20b/gcc/config.gcc=0Aindex=20= 999969d06df..5984dbf6419=20100644=0A---=20a/gcc/config.gcc=0A+++=20= b/gcc/config.gcc=0A@@=20-1021,6=20+1021,8=20@@=20case=20${target}=20in=0A= =20=20=20extra_headers=3D"${extra_headers}=20= ../vxworks/vxworks-predef.h"=0A=20=20=20target_has_targetcm=3D"yes"=0A=20= =0A+=20=20extra_gcc_objs=3D"vxworks-driver.o"=0A+=0A=20=20=20#=20This=20= private=20header=20exposes=20a=20consistent=20interface=20for=20checks=20= on=0A=20=20=20#=20the=20VxWorks=20version=20our=20runtime=20header=20= files=20need=20to=20perform,=20based=20on=0A=20=20=20#=20what=20the=20= system=20headers=20adverstise:=0Adiff=20--git=20a/gcc/config/t-vxworks=20= b/gcc/config/t-vxworks=0Aindex=2040c6cc4185b..dc97a4e0f30=20100644=0A---=20= a/gcc/config/t-vxworks=0A+++=20b/gcc/config/t-vxworks=0A@@=20-16,6=20= +16,10=20@@=0A=20#=20along=20with=20GCC;=20see=20the=20file=20COPYING3.=20= =20If=20not=20see=0A=20#=20.=0A=20=0A= +vxworks-driver.o:=20$(srcdir)/config/vxworks-driver.cc=0A+=09$(COMPILE)=20= $<=0A+=09$(POSTCOMPILE)=0A+=0A=20vxworks.o:=20= $(srcdir)/config/vxworks.cc=0A=20=09$(COMPILE)=20$<=0A=20=09= $(POSTCOMPILE)=0Adiff=20--git=20a/gcc/config/vxworks-driver.cc=20= b/gcc/config/vxworks-driver.cc=0Anew=20file=20mode=20100644=0Aindex=20= 00000000000..da5f015f1de=0A---=20/dev/null=0A+++=20= b/gcc/config/vxworks-driver.cc=0A@@=20-0,0=20+1,93=20@@=0A+/*=20= Copyright=20(C)=202022=20Free=20Software=20Foundation,=20Inc.=0A+=0A= +This=20file=20is=20part=20of=20GCC.=0A+=0A+GCC=20is=20free=20software;=20= you=20can=20redistribute=20it=20and/or=20modify=0A+it=20under=20the=20= terms=20of=20the=20GNU=20General=20Public=20License=20as=20published=20= by=0A+the=20Free=20Software=20Foundation;=20either=20version=203,=20or=20= (at=20your=20option)=0A+any=20later=20version.=0A+=0A+GCC=20is=20= distributed=20in=20the=20hope=20that=20it=20will=20be=20useful,=0A+but=20= WITHOUT=20ANY=20WARRANTY;=20without=20even=20the=20implied=20warranty=20= of=0A+MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20PARTICULAR=20PURPOSE.=20= =20See=20the=0A+GNU=20General=20Public=20License=20for=20more=20details.=0A= +=0A+You=20should=20have=20received=20a=20copy=20of=20the=20GNU=20= General=20Public=20License=0A+along=20with=20GCC;=20see=20the=20file=20= COPYING3.=20=20If=20not=20see=0A+.=20=20*/=0A= +=0A+#include=20"config.h"=0A+#include=20"system.h"=0A+#include=20= "coretypes.h"=0A+#include=20"tm.h"=0A+#include=20"opts.h"=0A+=0A+/*=20= Perform=20early=20driver=20flags=20initializations=20that=20can't=20be=20= achieved=0A+=20=20=20with=20specs.=20=20In=20particular,=20we=20need=20= to=20explicitly=20request=20a=20static=0A+=20=20=20link=20for=20rtps=20= by=20default=20before=20lang_specific_driver=20gets=20control.=20=20*/=0A= +=0A+void=20vxworks_driver_init=20(unsigned=20int=20= *in_decoded_options_count,=0A+=09=09=09=20=20struct=20cl_decoded_option=20= **in_decoded_options)=0A+{=0A+=20=20unsigned=20int=20i;=0A+=20=20struct=20= cl_decoded_option=20*decoded_options=20=3D=20*in_decoded_options;=0A+=0A= +=20=20/*=20Arrange=20to=20add=20-static=20if=20we=20are=20going=20to=20= link=20a=20rtp=20and=20there=20is=20no=0A+=20=20=20=20=20trace=20of=20= any=20explicit=20request=20for=20a=20specific=20kind=20of=20link.=20=20= */=0A+=20=20bool=20wont_link=20=3D=20false;=0A+=20=20bool=20mrtp=20=3D=20= false;=0A+=20=20bool=20link_kind_indication=20=3D=20false;=0A+=0A+=20=20= /*=20The=20new=20argument=20list=20will=20be=20contained=20in=20this.=20=20= */=0A+=20=20struct=20cl_decoded_option=20*new_decoded_options;=0A+=20=20= unsigned=20int=20num_options=20=3D=20*in_decoded_options_count;=0A+=0A+=20= =20for=20(i=20=3D=201;=20i=20<=20num_options;=20i++)=0A+=20=20=20=20{=0A= +=20=20=20=20=20=20if=20(decoded_options[i].errors=20&=20= CL_ERR_MISSING_ARG)=0A+=09continue;=0A+=0A+=20=20=20=20=20=20switch=20= (decoded_options[i].opt_index)=0A+=09{=0A+=09case=20OPT_static:=0A+=09= case=20OPT_shared:=0A+=09case=20OPT_Bdynamic:=0A+=09case=20OPT_Bstatic:=0A= +=09case=20OPT_non_static:=0A+=09=20=20link_kind_indication=20=3D=20= true;=0A+=09=20=20break;=0A+=0A+=09case=20OPT_c:=0A+=09case=20OPT_r:=0A+=09= case=20OPT_S:=0A+=09case=20OPT_E:=0A+=09case=20OPT_M:=0A+=09case=20= OPT_MM:=0A+=09case=20OPT_fsyntax_only:=0A+=09=20=20wont_link=20=3D=20= true;=0A+=09=20=20break;=0A+=0A+=09case=20OPT_mrtp:=0A+=09=20=20mrtp=20=3D= =20true;=0A+=09=20=20break;=0A+=0A+=09default:=0A+=09=20=20break;=0A+=20=20= =20=20=20=20}=0A+=20=20=20=20}=0A+=0A+=20=20if=20(!wont_link=20&&=20mrtp=20= &&=20!link_kind_indication)=0A+=20=20=20=20{=0A+=20=20=20=20=20=20= num_options++;=0A+=20=20=20=20=20=20new_decoded_options=20=3D=20= XNEWVEC(struct=20cl_decoded_option,=20num_options);=0A+=0A+=20=20=20=20=20= =20for=20(i=20=3D=200;=20i=20<=20num_options=20-=201;=20i++)=0A+=09= new_decoded_options[i]=20=3D=20decoded_options[i];=0A+=0A+=20=20=20=20=20= =20generate_option(OPT_static,=20NULL,=201,=20CL_DRIVER,=0A+=09=09=20=20=20= =20=20=20&new_decoded_options[num_options=20-=201]);=0A+=0A+=20=20=20=20=20= =20*in_decoded_options=20=3D=20new_decoded_options;=0A+=20=20=20=20=20=20= *in_decoded_options_count=20=3D=20num_options;=0A+=20=20=20=20}=0A+}=0A= diff=20--git=20a/gcc/config/vxworks.h=20b/gcc/config/vxworks.h=0Aindex=20= 13c616829c4..e7e5ffe9999=20100644=0A---=20a/gcc/config/vxworks.h=0A+++=20= b/gcc/config/vxworks.h=0A@@=20-28,6=20+28,16=20@@=20along=20with=20GCC;=20= see=20the=20file=20COPYING3.=20=20If=20not=20see=0A=20#undef=20= TARGET_VXWORKS=0A=20#define=20TARGET_VXWORKS=201=0A=20=0A+/*=20???=20= Even=20though=20assigned=20to=20a=20HOST=20driver=20hook,=20this=20= function=0A+=20=20=20operates=20for=20all=20vxworks=20targets=20= regardless=20of=20the=20current=20host.=0A+=20=20=20We=20will=20get=20= warnings=20at=20build=20time=20if=20the=20macro=20happens=20to=20be=0A+=20= =20=20redefined=20one=20way=20or=20another=20for=20a=20host.=20=20*/=0A= +struct=20cl_decoded_option;=0A+extern=20void=20vxworks_driver_init=20= (unsigned=20int=20*,=20struct=20cl_decoded_option=20**);=0A+=0A+#define=20= GCC_DRIVER_HOST_INITIALIZATION=20\=0A+=20=20=20=20=20=20=20=20= vxworks_driver_init=20(&decoded_options_count,=20&decoded_options)=0A+=0A= =20/*=20In=20kernel=20mode,=20VxWorks=20provides=20all=20the=20libraries=20= itself,=20as=20well=20as=0A=20=20=20=20the=20functionality=20of=20= startup=20files,=20etc.=20=20In=20RTP=20mode,=20it=20behaves=20more=0A=20= =20=20=20like=20a=20traditional=20Unix,=20with=20more=20external=20= files.=20=20Most=20of=20our=20specs=0A--=20=0A2.25.1=0A=0A= --Apple-Mail=_F46080D9-8292-4DEE-A0BF-F66296E977C2--