configure: Automatically add more flags required on symbian

Message ID 1310717447-57706-1-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö July 15, 2011, 8:10 a.m.
---
 configure |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Comments

Mans Rullgard July 15, 2011, 9:31 a.m. | #1
Martin Storsjö <martin@martin.st> writes:

> ---
>  configure |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 9ce77d1..d3a5912 100755
> --- a/configure
> +++ b/configure
> @@ -2502,6 +2502,14 @@ case $target_os in
>          speed_cflags='-O2'
>          enable dos_paths
>          add_cflags --include=$sysinclude/gcce/gcce.h
> +        add_cflags -fvisibility=default -T script -mapcs -nostdinc -msoft-float

-T is a linker option.  What is it doing in cflags?

Does Symbian really require soft-float?

Is Symbian ARM-only?  If not, -mapcs can't be used unconditionally.
Also, what breaks without it?

> +        add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS

Those are OK.

> +        add_ldflags -Wl,--target1-abs,--no-undefined,-nostdlib
> +        add_ldflags -Wl,-Ttext,0x80000,-Tdata,0x1000000 -Wl,-shared

Are those load addresses required?  The -shared seems strange too.
Please explain.

> +        add_ldflags -Wl,--entry=_E32Startup -Wl,-u,_E32Startup

If that's the way it's done...  I'd still like to know why the toolchain
doesn't do this by itself though.

> +        add_ldflags -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso -l:drtaeabi.dso
> +        add_ldflags -l:scppnwdl.dso -lsupc++ -lgcc -l:libc.dso -l:libm.dso
> +        add_ldflags -l:euser.dso -l:libcrt0.lib

These should be in extralibs, not ldflags.
Martin Storsjö July 15, 2011, 11:37 a.m. | #2
On Fri, 15 Jul 2011, Måns Rullgård wrote:

> Martin Storsjö <martin@martin.st> writes:
> 
> > ---
> >  configure |    8 ++++++++
> >  1 files changed, 8 insertions(+), 0 deletions(-)
> >
> > diff --git a/configure b/configure
> > index 9ce77d1..d3a5912 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2502,6 +2502,14 @@ case $target_os in
> >          speed_cflags='-O2'
> >          enable dos_paths
> >          add_cflags --include=$sysinclude/gcce/gcce.h
> > +        add_cflags -fvisibility=default -T script -mapcs -nostdinc -msoft-float
> 
> -T is a linker option.  What is it doing in cflags?

Being misplaced, misinterpreted and not needed - removed.

> Does Symbian really require soft-float?

AFAIK, it's the norm yes. Most devices lack an FPU. OTOH, perhaps this 
could be left out from configure and specified via --extra-cflags if 
wanted?

> Is Symbian ARM-only?  If not, -mapcs can't be used unconditionally.
> Also, what breaks without it?

It's kinda ARM-only - there's a windows simulator environment which uses a 
stone age codewarrior compiler though.

But it seems to work fine without it, so removed for now.

> > +        add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
> 
> Those are OK.
> 
> > +        add_ldflags -Wl,--target1-abs,--no-undefined,-nostdlib
> > +        add_ldflags -Wl,-Ttext,0x80000,-Tdata,0x1000000 -Wl,-shared
> 
> Are those load addresses required?  The -shared seems strange too.
> Please explain.

Yes, they're required.

Symbian is weird in many ways. The toolchains uses ELF, while the devices 
themselves don't run ELF at all - the compiled ELF binaries are run 
through a post-linker that transforms them into symbian binaries, and that 
step requires the load addresses to be specified. (IIRC, the addresses 
themselves don't matter that much, but the default layout if these are 
left out don't work with the postlinker.) -shared is also part of this, 
for generating binaries that work with the postlinker.

> > +        add_ldflags -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
> 
> If that's the way it's done...  I'd still like to know why the toolchain
> doesn't do this by itself though.

For normal symbian stuff (if there is such a thing), all of this is hidden 
deep within multiple layers of perl/python/make/batch scripts - they 
probably found it more flexible to have this specified in the build system 
instead of in the actual toolchain.

> > +        add_ldflags -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso -l:drtaeabi.dso
> > +        add_ldflags -l:scppnwdl.dso -lsupc++ -lgcc -l:libc.dso -l:libm.dso
> > +        add_ldflags -l:euser.dso -l:libcrt0.lib
> 
> These should be in extralibs, not ldflags.

Fixed.

// Martin
Mans Rullgard July 15, 2011, 11:47 a.m. | #3
Martin Storsjö <martin@martin.st> writes:

> On Fri, 15 Jul 2011, Måns Rullgård wrote:
>
>> Martin Storsjö <martin@martin.st> writes:
>> 
>> > ---
>> >  configure |    8 ++++++++
>> >  1 files changed, 8 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/configure b/configure
>> > index 9ce77d1..d3a5912 100755
>> > --- a/configure
>> > +++ b/configure
>> > @@ -2502,6 +2502,14 @@ case $target_os in
>> >          speed_cflags='-O2'
>> >          enable dos_paths
>> >          add_cflags --include=$sysinclude/gcce/gcce.h
>> > +        add_cflags -fvisibility=default -T script -mapcs -nostdinc -msoft-float
>> 
>> Does Symbian really require soft-float?
>
> AFAIK, it's the norm yes. Most devices lack an FPU. OTOH, perhaps this 
> could be left out from configure and specified via --extra-cflags if 
> wanted?

There are Symbian phones with ARM11 CPUs, and these usually have VFP.
It's of course possible that the OS still disallows use of it.  It seems
to be stupid enough to do such a thing.

If VFP is allowed on some phones, specifying soft-float here is a bad
idea since there is no way for the user to override it.

>> > +        add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
>> 
>> Those are OK.
>> 
>> > +        add_ldflags -Wl,--target1-abs,--no-undefined,-nostdlib
>> > +        add_ldflags -Wl,-Ttext,0x80000,-Tdata,0x1000000 -Wl,-shared
>> 
>> Are those load addresses required?  The -shared seems strange too.
>> Please explain.
>
> Yes, they're required.
>
> Symbian is weird in many ways. The toolchains uses ELF, while the devices 
> themselves don't run ELF at all - the compiled ELF binaries are run 
> through a post-linker that transforms them into symbian binaries, and that 
> step requires the load addresses to be specified. (IIRC, the addresses 
> themselves don't matter that much, but the default layout if these are 
> left out don't work with the postlinker.) -shared is also part of this, 
> for generating binaries that work with the postlinker.

Very well then.  Just one thing, doesn't -shared without the -Wl work?

>> > +        add_ldflags -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
>> 
>> If that's the way it's done...  I'd still like to know why the toolchain
>> doesn't do this by itself though.
>
> For normal symbian stuff (if there is such a thing), all of this is hidden 
> deep within multiple layers of perl/python/make/batch scripts - they 
> probably found it more flexible to have this specified in the build system 
> instead of in the actual toolchain.

OK then.

>> > +        add_ldflags -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso -l:drtaeabi.dso
>> > +        add_ldflags -l:scppnwdl.dso -lsupc++ -lgcc -l:libc.dso -l:libm.dso
>> > +        add_ldflags -l:euser.dso -l:libcrt0.lib
>> 
>> These should be in extralibs, not ldflags.
>
> Fixed.

One more thing: what's with the -nostd* flags?  Is the toolchain so
fucked up this is required?
Martin Storsjö July 15, 2011, 12:42 p.m. | #4
On Fri, 15 Jul 2011, Måns Rullgård wrote:

> Martin Storsjö <martin@martin.st> writes:
> 
> > On Fri, 15 Jul 2011, Måns Rullgård wrote:
> >
> >> Martin Storsjö <martin@martin.st> writes:
> >> 
> >> > ---
> >> >  configure |    8 ++++++++
> >> >  1 files changed, 8 insertions(+), 0 deletions(-)
> >> >
> >> > diff --git a/configure b/configure
> >> > index 9ce77d1..d3a5912 100755
> >> > --- a/configure
> >> > +++ b/configure
> >> > @@ -2502,6 +2502,14 @@ case $target_os in
> >> >          speed_cflags='-O2'
> >> >          enable dos_paths
> >> >          add_cflags --include=$sysinclude/gcce/gcce.h
> >> > +        add_cflags -fvisibility=default -T script -mapcs -nostdinc -msoft-float
> >> 
> >> Does Symbian really require soft-float?
> >
> > AFAIK, it's the norm yes. Most devices lack an FPU. OTOH, perhaps this 
> > could be left out from configure and specified via --extra-cflags if 
> > wanted?
> 
> There are Symbian phones with ARM11 CPUs, and these usually have VFP.
> It's of course possible that the OS still disallows use of it.  It seems
> to be stupid enough to do such a thing.
> 
> If VFP is allowed on some phones, specifying soft-float here is a bad
> idea since there is no way for the user to override it.

Ok, good point.

> >> > +        add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
> >> 
> >> Those are OK.
> >> 
> >> > +        add_ldflags -Wl,--target1-abs,--no-undefined,-nostdlib
> >> > +        add_ldflags -Wl,-Ttext,0x80000,-Tdata,0x1000000 -Wl,-shared
> >> 
> >> Are those load addresses required?  The -shared seems strange too.
> >> Please explain.
> >
> > Yes, they're required.
> >
> > Symbian is weird in many ways. The toolchains uses ELF, while the devices 
> > themselves don't run ELF at all - the compiled ELF binaries are run 
> > through a post-linker that transforms them into symbian binaries, and that 
> > step requires the load addresses to be specified. (IIRC, the addresses 
> > themselves don't matter that much, but the default layout if these are 
> > left out don't work with the postlinker.) -shared is also part of this, 
> > for generating binaries that work with the postlinker.
> 
> Very well then.  Just one thing, doesn't -shared without the -Wl work?

Indeed it does, changed.

> >> > +        add_ldflags -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
> >> 
> >> If that's the way it's done...  I'd still like to know why the toolchain
> >> doesn't do this by itself though.
> >
> > For normal symbian stuff (if there is such a thing), all of this is hidden 
> > deep within multiple layers of perl/python/make/batch scripts - they 
> > probably found it more flexible to have this specified in the build system 
> > instead of in the actual toolchain.
> 
> OK then.
> 
> >> > +        add_ldflags -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso -l:drtaeabi.dso
> >> > +        add_ldflags -l:scppnwdl.dso -lsupc++ -lgcc -l:libc.dso -l:libm.dso
> >> > +        add_ldflags -l:euser.dso -l:libcrt0.lib
> >> 
> >> These should be in extralibs, not ldflags.
> >
> > Fixed.
> 
> One more thing: what's with the -nostd* flags?  Is the toolchain so
> fucked up this is required?

No, apparently those are cargo cult, too. Removed.

Also, since add_extralibs prepends stuff instead of appends, I changed the 
three add_extralibs calls into one spanning three lines, and changed 
add_ldflags similarly for consistency.

// Martin

Patch

diff --git a/configure b/configure
index 9ce77d1..d3a5912 100755
--- a/configure
+++ b/configure
@@ -2502,6 +2502,14 @@  case $target_os in
         speed_cflags='-O2'
         enable dos_paths
         add_cflags --include=$sysinclude/gcce/gcce.h
+        add_cflags -fvisibility=default -T script -mapcs -nostdinc -msoft-float
+        add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
+        add_ldflags -Wl,--target1-abs,--no-undefined,-nostdlib
+        add_ldflags -Wl,-Ttext,0x80000,-Tdata,0x1000000 -Wl,-shared
+        add_ldflags -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
+        add_ldflags -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso -l:drtaeabi.dso
+        add_ldflags -l:scppnwdl.dso -lsupc++ -lgcc -l:libc.dso -l:libm.dso
+        add_ldflags -l:euser.dso -l:libcrt0.lib
         ;;
     none)
         ;;