X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: dj AT delorie DOT com X-Recipient: djgpp AT delorie DOT com Message-ID: Content-Type: multipart/alternative; boundary="_56ac5af7-ebda-4e62-bd57-c196aa22e7c0_" X-Originating-IP: [131.107.0.103] From: Jay To: DJ Delorie CC: Subject: RE: libstdc++ writev/2.04/patches upstream? Date: Tue, 8 Jul 2008 01:28:18 +0000 Importance: Low In-Reply-To: <200807072346.m67NklaB006801@envy.delorie.com> References: <200807070405 DOT m67451dZ010910 AT delorie DOT com> <200807071920 DOT m67JKA4v032518 AT envy DOT delorie DOT com> <200807072141 DOT m67Lf1A6003751 AT envy DOT delorie DOT com> <200807072346 DOT m67NklaB006801 AT envy DOT delorie DOT com> MIME-Version: 1.0 X-OriginalArrivalTime: 08 Jul 2008 01:28:18.0809 (UTC) FILETIME=[E6DF9690:01C8E099] Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --_56ac5af7-ebda-4e62-bd57-c196aa22e7c0_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > > Jay=20 > > You have to "cheat" in any case=2C like starting with a compiler and = > > linker from somewhere. > > DJ > Um=2C no. I do cross co= mpilers starting with only a native compiler and > the original sources= . Note that writing cross development tools is my > day job - I do this= all the time. =20 Having a native compiler and linker I label "cheating". You have to start somewhere -- from some binaries=2C that are runnable some= where=2C not just source. (Yes=2C I realize even starting with a native compiler/linker and a working= bootable computer is being spoiled.) > And many of the tests are "run this" tests=3B=20 I admit I have not taken any inventory of compile vs. link vs. run. Um=2C given a preexisting djcrx=2C a sys-root=2C changing the writev test t= obe "auto" is reasonable=2C right? I have to try it out of course=2C with v= 203and v204. And=2C if you (or others) very much prefer the existing assump= tion=2CI could make it first test if it can link anything (just main(){})= =2C and if not=2C use thecurrent default=2C and only if it is able to link = anything=2C then use theresult of linking to writev as a test. Or really=2C it could be like (psuedo code!) # # DJGPP 2.04 has writev=2C 2.03 does not. # Default to 2.04 and probe= for 2.03. # has_write=3Dtrue # default in case libc.a not present sysro= ot =3D prefix/target/sys-root # default sys-root if use_sysroot !=3D "" = && use_sysroot !=3D yes sysroot =3D use_sysroot # use specified sys-ro= ot if exist sys-root/lib/libc.a # make sure it is minimally valid = if nm-for-target libc.a | grep fopen if nm-for-target libc.a | g= rep writev has_writev=3Dtrue else has_writev=3Dfal= se =20 If you have ld=2C you probably have nm. No need to compile=2C except=2C well=2C maybe the compileris better at find= ing libc.a. =20 so maybe: has_writev=3Dtrue # assume v2.04 default in case libc.a not present # Ca= n we compile and link anything? if cc << int main() { }<< # Can we NOT = link to writev? if ! cc << int main() { void* p =3D &writev=3B } = << has_writev=3Dfalse else rm a.exe rm a.out else echo WARNING: unable to do autoconf= iguration via linking for cross build=2C using defaults. end =20 Really=2C this is pseudo code.I'll get the m4/auto*/sh right. Also=2C maybe uname differentiates=2C though that's crude.Presumably 2.04 e= xisted=2C in an intermediate state=2C beforewritev was added. I believe there are other similar things being hardcoded here.I'll look int= o it. - Jay= --_56ac5af7-ebda-4e62-bd57-c196aa22e7c0_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable  =3B >=3B >=3B Jay
 =3B >=3B >=3B You have to "cheat" in any case=2C like starting wit= h a compiler and =3B =3B
 =3B >=3B >=3B linker from som= ewhere. =3B
 =3B >=3B =3B =3B =3B =3B
&nbs= p=3B >=3B =3B =3B =3BDJ
 =3B >=3B Um=2C no. I do cr= oss compilers starting with only a native compiler and =3B =3B
=  =3B >=3B the original sources. Note that writing cross development t= ools is my =3B =3B
 =3B >=3B day job - I do this all the = time. =3B =3B

Having a native compiler and linker I label "cheating".
You have to start somewhere -- from some binaries=2C that are runnable some= where=2C not just source.
(Yes=2C I realize even starting with a native compiler/linker and a working= bootable computer is being spoiled.)

 =3B>=3B And many of the tests are "run this" tests=3B

I admit I have not taken any inventory of compile vs. link vs. run.

Um=2C given a preexisting djcrx=2C a sys-root=2C changing the writev te= st to
be "auto" is reasonable=2C right? I have to try it out of course= =2C with v203
and v204. And=2C if you (or others) very much prefer the e= xisting assumption=2C
I could make it first test if it can link anything= (just main(){})=2C and if not=2C use the
current default=2C and only if= it is able to link anything=2C then use the
result of linking to writev= as a test.

Or really=2C it could be like (psuedo code!)

 =3B #
 =3B # DJGPP 2.04 has writev=2C 2.03 does not.
&nb= sp=3B # Default to 2.04 and probe for 2.03.
 =3B #
 =3B has_w= rite=3Dtrue # default in case libc.a not present
 =3B sysroot =3D pr= efix/target/sys-root # default sys-root
 =3B =3B =3B if use_= sysroot !=3D "" &=3B&=3B use_sysroot !=3D yes
 =3B =3B&nbs= p=3B =3B =3B sysroot =3D use_sysroot # use specified sys-root
&n= bsp=3B =3B =3B if exist sys-root/lib/libc.a
 =3B =3B&nbs= p=3B =3B =3B # make sure it is minimally valid
 =3B =3B&= nbsp=3B =3B =3B if nm-for-target libc.a | grep fopen
 =3B&nb= sp=3B =3B =3B =3B =3B =3B if nm-for-target libc.a | gre= p writev
 =3B =3B =3B =3B =3B =3B =3B = =3B =3B has_writev=3Dtrue
 =3B =3B =3B =3B =3B&n= bsp=3B =3B else
 =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B has_writev=3Dfalse
 =3B
If you have ld=2C you probably have nm.

No need to compile=2C except=2C well=2C maybe the compiler
is better at = finding libc.a.
 =3B
so maybe:
 =3B has_writev=3Dtrue # assume v2.04 default in case libc.a not presen= t
 =3B # Can we compile and link anything?
 =3B if cc <=3B&= lt=3B
 =3Bint main() { }
<=3B<=3B
 =3B =3B =3B= # Can we NOT link to writev?
 =3B =3B =3B if ! cc <=3B<= =3B =3B
 =3B =3B =3B =3B =3B int main() { void* = p =3D &=3Bwritev=3B }
 =3B =3B =3B <=3B<=3B
 = =3B =3B =3B =3B =3B has_writev=3Dfalse
 =3B =3B&= nbsp=3B else
 =3B =3B =3B =3B =3B rm a.exe =3B
 =3B = =3B =3B =3B =3B rm a.out =3B
 =3B else
 =3B&n= bsp=3B =3B echo WARNING: unable to do autoconfiguration via linking for= cross build=2C using defaults.
 =3B end
 =3B
Really=2C this is pseudo code.
I'll get the m4/auto*/sh right.

Also=2C maybe uname differentiates=2C though that's crude.
Presumabl= y 2.04 existed=2C in an intermediate state=2C before
writev was added.
I believe there are other similar things being hardcoded here.
I'll = look into it.

 =3B- Jay

= --_56ac5af7-ebda-4e62-bd57-c196aa22e7c0_--