MIPS and gcc-4.3.1

View: New views
10 Messages — Rating Filter:   Alert me  

MIPS and gcc-4.3.1

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello again!

I've been trying to build uClibc-20080801 for MIPS with gcc-4.3.1.

The build chokes in libc/stdlib/_atexit.c at line 205:
libc/stdlib/_atexit.c:205: error: expected ';' before '__prev'
libc/stdlib/_atexit.c:205: error: '__prev' undeclared (first use in this function)
libc/stdlib/_atexit.c:205: error: (Each undeclared identifier is reported only once
libc/stdlib/_atexit.c:205: error: for each function it appears in.)
libc/stdlib/_atexit.c:205: error: expected ';' before '__prev'
libc/stdlib/_atexit.c:205: error: expected ';' before '__prev'
libc/stdlib/_atexit.c:205: error: expected ';' before '__prev'
libc/stdlib/_atexit.c:205: error: invalid lvalue in asm output 0

After looking at the code and digging into macros, I ended up in
libc/sysdeps/linux/mips/bits/atomic.h

This file makes use of the 'typeof' keyword. I looked around in other archs,
and all but MIPS and Alpha use '__typeof'. MIPS and Alpha do use 'typeof'.

So I made the attached patch, and the build completes.
Is the patch right?

On the other hand, reading the gcc manual, section 5.6 titled "Referring
to a Type with `typeof'" ("info ./gcc/doc/gcc.info" in the gcc source tree)
reads:

|  If you are writing a header file that must work when included in ISO C
| programs, write `__typeof__' instead of `typeof'.  *Note Alternate
| Keywords::.

So going do section 5.41 "Alternate Keywords", it reads:

| `-ansi' and the various `-std' options disable certain keywords.
[--SNIP--]
| The keywords `asm', `typeof' and `inline' are not available in programs
| compiled with `-ansi' or `-std'
[--SNIP--]
|  The way to solve these problems is to put `__' at the beginning and
| end of each problematical keyword.

So I do not know where this '__typeof' comes from, but we'd be better using
'__typeof__' instead, no?

Did I miss something else?

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°

[attachment removed]
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Bernhard Reutner-Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Aug 05, 2008 at 03:11:29PM +0200, Yann E. MORIN wrote:
>Hello again!

Hi Yann,

>So I do not know where this '__typeof' comes from, but we'd be better using
>'__typeof__' instead, no?

I'd go for __typeof__, yes.
>
>Did I miss something else?

No, that's perfectly fine.
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Bernhard Reutner-Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Aug 05, 2008 at 03:11:29PM +0200, Yann E. MORIN wrote:

>So I do not know where this '__typeof' comes from, but we'd be better using
>'__typeof__' instead, no?

I was just about to apply it blindly (don't remember if you have
write-access), but you seem to be setup to actually test it :)

find ./ \( -name "*.[ch]" -o -name "*.inc" \) -exec \
sed -i -e "/typeof[[:space:]]*(/s/[_]*typeof[_]*/__typeof__/;" {} \;

I didn't look if comments would trigger, those should be omitted from
what gets applied.
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Heyda Bernhard and All!

On Tuesday 05 August 2008 18:18:03 Bernhard Fischer wrote:
> On Tue, Aug 05, 2008 at 03:11:29PM +0200, Yann E. MORIN wrote:
> >So I do not know where this '__typeof' comes from, but we'd be better using
> >'__typeof__' instead, no?
> I was just about to apply it blindly (don't remember if you have
> write-access), but you seem to be setup to actually test it :)

No I don't have write access. I'm not comfortable with having it, anyway.

> find ./ \( -name "*.[ch]" -o -name "*.inc" \) -exec \
> sed -i -e "/typeof[[:space:]]*(/s/[_]*typeof[_]*/__typeof__/;" {} \;

That's not the only problem. We also use 'asm' statements, but we explicitly
instruct the compiler not to recognize them, in Rules.mak, around line 466:

$ svn blame Rules.mak
[--SNIP--
| 22868      aldot # Make sure that we can be built with non-C99 compilers, too.
| 22868      aldot # Use __\1__ instead.
| 22868      aldot CFLAGS += $(call check_gcc,-fno-asm,)

The change is really recent:
$ svn log -r 22868
------------------------------------------------------------------------
r22868 | aldot | 2008-07-17 18:54:31 +0200 (Thu, 17 Jul 2008) | 4 lines

- poison non-standard keywords:
  Make sure that we can be built with non-C99 compilers, too.
  Use __\1__ instead.
------------------------------------------------------------------------

Hmmm. Who's 'aldot', by the way? I can't seem to remember... ;-) Hehe!

We should audit the code for other keywords that ought to be replaced
with __\1__. We should also provide macros for those when we're not
using gcc. x86_64 bombed on me in libc/sysdeps/linux/x86_64/sigaction.c
at line 147:

[--SNIP--]
| #define RESTORE(name, syscall) RESTORE2 (name, syscall)
| # define RESTORE2(name, syscall) \
| asm                                             \
|   (                                             \
|    ".text\n" \
|    "__" #name ":\n"                             \
|    "    movq $" #syscall ", %rax\n"             \
|    "    syscall\n"                              \
|    );
| #ifdef __NR_rt_sigaction
| /* The return code for realtime-signals.  */
| RESTORE (restore_rt, __NR_rt_sigreturn)
| #endif
| #ifdef __NR_sigreturn
| RESTORE (restore, __NR_sigreturn)
| #endif

Which expands to something like (with my .config):
| # 147 "libc/sysdeps/linux/x86_64/sigaction.c"
| asm ( ".text\n" "__" "restore_rt" ":\n" "       movq $" "15" ", %rax\n" "       syscall\n" );

But the command line contains both '-fno-asm' and '-std=gnu99' (-save-temps
is from me!):
| ../gcc-core-static/bin/x86_64-unknown-linux-uclibc-gcc -save-temps
| -c libc/sysdeps/linux/x86_64/sigaction.c
| -o libc/sysdeps/linux/x86_64/sigaction.os
| -include ./include/libc-symbols.h -Wall -pipe -Wstrict-prototypes
| -fno-strict-aliasing -fno-stack-protector -fno-builtin -nostdinc
| -I./include -I. -I./libc/sysdeps/linux/x86_64 -fno-asm -DUCLIBC_INTERNAL
                                        Here ----'
| -std=gnu99 -Os -funit-at-a-time -fno-tree-loop-optimize
    '---- and here
| -fno-tree-dominator-opts -fno-strength-reduce
| -I./libpthread/linuxthreads.old/sysdeps/unix/sysv/linux/x86_64
| -I./libpthread/linuxthreads.old/sysdeps/x86_64
| -I./libpthread/linuxthreads.old/sysdeps/unix/sysv/linux
| -I./libpthread/linuxthreads.old/sysdeps/pthread
| -I./libpthread/linuxthreads.old -I./libpthread
| -I/home/ymorin/x-tools/x86_64-unknown-linux-uclibc/x86_64-unknown-linux-uclibc/sys-root/usr/include/
| -I/home/ymorin/dev/crosstool-NG/ct-ng.trunk/targets/x86_64-unknown-linux-uclibc/build/gcc-core-static/lib/gcc/x86_64-unknown-linux-uclibc/4.3.1//include-fixed
| -I/home/ymorin/dev/crosstool-NG/ct-ng.trunk/targets/x86_64-unknown-linux-uclibc/build/gcc-core-static/lib/gcc/x86_64-unknown-linux-uclibc/4.3.1/include
| -DNDEBUG -fPIC -MT libc/sysdeps/linux/x86_64/sigaction.os -MD -MP
| -MF libc/sysdeps/linux/x86_64/.sigaction.os.dep

From the gcc manual, we need to protect 'asm', 'inline', 'typeof', and
'restrict' (do we use the latest?) and use the alternate forms __\1__.

> I didn't look if comments would trigger, those should be omitted from
> what gets applied.

OK, let me try... Will come back later with a patch.

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°

_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Bernhard Reutner-Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Aug 05, 2008 at 07:48:52PM +0200, Yann E. MORIN wrote:
>Heyda Bernhard and All!

>$ svn blame Rules.mak
>[--SNIP--
>| 22868      aldot # Make sure that we can be built with non-C99 compilers, too.
>| 22868      aldot # Use __\1__ instead.
>| 22868      aldot CFLAGS += $(call check_gcc,-fno-asm,)
>
>The change is really recent:
>$ svn log -r 22868
>------------------------------------------------------------------------
>r22868 | aldot | 2008-07-17 18:54:31 +0200 (Thu, 17 Jul 2008) | 4 lines
>
>- poison non-standard keywords:
>  Make sure that we can be built with non-C99 compilers, too.
>  Use __\1__ instead.
>------------------------------------------------------------------------
>
>Hmmm. Who's 'aldot', by the way? I can't seem to remember... ;-) Hehe!

That'd be /me

>
>We should audit the code for other keywords that ought to be replaced
>with __\1__. We should also provide macros for those when we're not
>using gcc. x86_64 bombed on me in libc/sysdeps/linux/x86_64/sigaction.c
>at line 147:
>
>[--SNIP--]
>| #define RESTORE(name, syscall) RESTORE2 (name, syscall)
>| # define RESTORE2(name, syscall) \
>| asm                                             \

drats. Yes the '(' on a separate line certainly escaped my sed, sorry.

>|   (                                             \
>|    ".text\n" \
>|    "__" #name ":\n"                             \
>|    "    movq $" #syscall ", %rax\n"             \
>|    "    syscall\n"                              \
>|    );
>| #ifdef __NR_rt_sigaction
>| /* The return code for realtime-signals.  */
>| RESTORE (restore_rt, __NR_rt_sigreturn)
>| #endif
>| #ifdef __NR_sigreturn
>| RESTORE (restore, __NR_sigreturn)
>| #endif
>
>Which expands to something like (with my .config):
>| # 147 "libc/sysdeps/linux/x86_64/sigaction.c"
>| asm ( ".text\n" "__" "restore_rt" ":\n" "       movq $" "15" ", %rax\n" "       syscall\n" );

>From the gcc manual, we need to protect 'asm', 'inline', 'typeof', and
>'restrict' (do we use the latest?) and use the alternate forms __\1__.

I think the restrict shouldn't bite (didn't bite me on ia32 and amd64,
at least -- YMMV).
>
>> I didn't look if comments would trigger, those should be omitted from
>> what gets applied.
>
>OK, let me try... Will come back later with a patch.

TIA. The reasoning behind the no-asm is to be C89 compliant, FYI.
Although it is purely cosmetic, from a modern (GCC-)toolchain POV, it
certainly is something that i was bitten by at least while getting me a
comfortable setup on e.g. OSF/1. While this particular OS may be a bad
example since they dropped support for the HW i have access to, it's imo
a good thing to keep an eye on such janitorial tweaks. Sorry if this
caused any temporary grief for you, it was certainly not intended from
my part :)
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all!

On Tuesday 05 August 2008 20:23:41 Bernhard Fischer wrote:
> >Hmmm. Who's 'aldot', by the way? I can't seem to remember... ;-) Hehe!
> That'd be /me

Well, I knew! ;-)

> drats. Yes the '(' on a separate line certainly escaped my sed, sorry.

Am just back from dinner. Will try now...

OK. Here's one that turns all 'asm' and '__asm' into '__asm__'. Not many
of them, there was.

Note that we also must ensure that '__asm__' get redefined to 'asm' when
we're not using gcc, a-la:
| #if ! defined __GNUC__
| # define __asm__ asm
| #endif

No code for that in the patch, I'll leave that to someone else... :-/

> TIA. The reasoning behind the no-asm is to be C89 compliant, FYI.
> Although it is purely cosmetic, from a modern (GCC-)toolchain POV, it
> certainly is something that i was bitten by at least while getting me a
> comfortable setup on e.g. OSF/1. While this particular OS may be a bad
> example since they dropped support for the HW i have access to, it's imo
> a good thing to keep an eye on such janitorial tweaks.

On the other hand, do we really want to support such /oddities/? As far
as I know, uClibc builds only for Linux, right? And only with gcc?

> Sorry if this
> caused any temporary grief for you, it was certainly not intended from
> my part :)

Better sooner than later. :-)

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°

[attachment removed]
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tuesday 05 August 2008 23:56:19 Yann E. MORIN wrote:
> OK. Here's one that turns all 'asm' and '__asm' into '__asm__'. Not many
> of them, there was.

Woops... wrong patch... Here the correct one...

Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°

[attachment removed]
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Bernhard Reutner-Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Aug 06, 2008 at 12:03:58AM +0200, Yann E. MORIN wrote:
>On Tuesday 05 August 2008 23:56:19 Yann E. MORIN wrote:
>> OK. Here's one that turns all 'asm' and '__asm' into '__asm__'. Not many
>> of them, there was.
>
>Woops... wrong patch... Here the correct one...

Applied as r23060. Thanks!
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Bernhard!
Hello All!

On Tuesday 05 August 2008 15:44:12 Bernhard Fischer wrote:
> I'd go for __typeof__, yes.

Here is a patch that changes all occurences of 'typeof' and '__typeof' to
'__typeof__'.

Untested so far (build in progress...).

Regards,
Yann E. MORIN.


--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°

[attachment removed]
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: MIPS and gcc-4.3.1

by Yann E. MORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello All!

On Tuesday 05 August 2008 19:48:52 Yann E. MORIN wrote:
> From the gcc manual, we need to protect 'asm', 'inline', 'typeof', and
> 'restrict' (do we use the latest?) and use the alternate forms __\1__.

Here is a third patch that replaces all 'inline' and '__inline' with
'__inline__'.

Untested so far (will build later). Just for review.

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°

[attachment removed]
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc
LightInTheBox - Buy quality products at wholesale price!