public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* new port : libgcc ? newlib ?
@ 2009-03-13  9:46 Florent DEFAY
  2009-03-13 14:21 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Florent DEFAY @ 2009-03-13  9:46 UTC (permalink / raw)
  To: gcc-help

Hi,

I am working on a new port of GCC. I am now dealing with multiply, divide, mod.
The target machine does not support these operations. Then I think I
have to consider LIBGCC.
But here I get in trouble.

First, there are 2 libgcc : libgcc1 and libgcc2. What is the difference ?

When reading GCC Internals, I found information about libgcc2 and I
tried to insert the following line in the t-target :

LIB2FUNCS_EXTRA=mulhi3.S

where mulhi3.S contains the assembler code for the function __mulhi3.

When building GCC, no rule to compile mulhi3.S ... I think my t-target
is not complete but I do not find anything more.

Then I tried this (just like msp430) :

LIB1ASMSRC = target/mulhi3.S
LIB1ASMFUNCS = __mulhi3

GCC build succeeds (with errors, see below). But then, when linking a
program using multiply :
undefined reference to `__mulhi3'

I tried to add -lgcc in the Makefile when linking but :
target-ld: cannot find -lgcc

Moreover, when building GCC, it finishes with this error :
*** Configuration target-unknown-none not supported
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory `/home/me/gcc/build_target'
make: *** [all] Error 2

I searched about this error. I found a reply. It says "sym-link newlib
into GCC sources".
I do not understand why is it newlib about? My target has no system. I
just would like to disable all of this.

I also get an error at 'make install' time :
make[2]: Entering directory `/home/me/gcc/build_target/target/libstdc++-v3'
make[2]: *** No rule to make target `install'.  Stop.
make[2]: Leaving directory `/home/me/gcc/build_target/target/libstdc++-v3'
make[1]: *** [install-target-libstdc++-v3] Error 2
make[1]: Leaving directory `/home/me/gcc/build_target'
make: *** [install] Error 2

This is the same, I am not intrested in libstdc++, how to disable that?

So, please, could you help me about how to implement simplest libgcc.

Regards.

Florent

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: new port : libgcc ? newlib ?
  2009-03-13  9:46 new port : libgcc ? newlib ? Florent DEFAY
@ 2009-03-13 14:21 ` Ian Lance Taylor
  2009-03-13 15:09   ` Florent DEFAY
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2009-03-13 14:21 UTC (permalink / raw)
  To: Florent DEFAY; +Cc: gcc-help

Florent DEFAY <spira.inhabitant@gmail.com> writes:

> First, there are 2 libgcc : libgcc1 and libgcc2. What is the difference ?

libgcc1 exists primarily conceptually.  It is the basic set of
operations which can not be reasonably implemented using other
operations.  In the good old days libgcc1 was built using the other
compiler on your system.  Since these days there is generally no other
compiler, most targets provide assembler code to perform the operations.
For example, see config/arm/lib1funcs.asm.

libgcc2, conversely, is the set of operations which can be implemented
reasonably.  For example, if you have a 32-bit add instruction, it's
easy to use it to implement 64-bit addition.  This code appears in
gcc/libgcc2.c.  On many processors it is possible to optimize using
instructions which are not avaliable in C, such as add-with-carry; those
optimizations are written in gcc/longlong.h.


> When reading GCC Internals, I found information about libgcc2 and I
> tried to insert the following line in the t-target :
>
> LIB2FUNCS_EXTRA=mulhi3.S
>
> where mulhi3.S contains the assembler code for the function __mulhi3.

mulhi3 would be in libgcc1, not libgcc2.  You would normally set
LIB1ASMSRC and LIB1ASMFUNCS.


> When building GCC, no rule to compile mulhi3.S

Well, no.  You have to write it yourself.


> Then I tried this (just like msp430) :
>
> LIB1ASMSRC = target/mulhi3.S
> LIB1ASMFUNCS = __mulhi3

Looks right, assuming you've written mulhi3.S.


> Moreover, when building GCC, it finishes with this error :
> *** Configuration target-unknown-none not supported
> make[1]: *** [configure-target-libgcc] Error 1
> make[1]: Leaving directory `/home/me/gcc/build_target'
> make: *** [all] Error 2

This is why libgcc wasn't built.  You need to patch gcc/config.gcc to
support your target.  Actually I don't know how you would have gotten
this far without doing that, so there may besomething else you need to
do.


> I searched about this error. I found a reply. It says "sym-link newlib
> into GCC sources".

That's if you want a C library.  You haven't gotten to that point.  It
won't help with this problem.


> This is the same, I am not intrested in libstdc++, how to disable that?

Run configure with --enable-languages=c.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: new port : libgcc ? newlib ?
  2009-03-13 14:21 ` Ian Lance Taylor
@ 2009-03-13 15:09   ` Florent DEFAY
  2009-03-13 15:32     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Florent DEFAY @ 2009-03-13 15:09 UTC (permalink / raw)
  To: Ian Lance Taylor, gcc-help

Thank you for your reply. I can precise some things:

>> Then I tried this (just like msp430) :
>>
>> LIB1ASMSRC = target/mulhi3.S
>> LIB1ASMFUNCS = __mulhi3
>
> Looks right, assuming you've written mulhi3.S.

I have.
Will the function __mulhi3 be placed in libgcc.a? Then, to compile a
program which use multiplications, should I link with -lgcc option?

>> Moreover, when building GCC, it finishes with this error :
>> *** Configuration target-unknown-none not supported
>> make[1]: *** [configure-target-libgcc] Error 1
>> make[1]: Leaving directory `/home/me/gcc/build_target'
>> make: *** [all] Error 2
>
> This is why libgcc wasn't built.  You need to patch gcc/config.gcc to
> support your target.  Actually I don't know how you would have gotten
> this far without doing that, so there may besomething else you need to
> do.

Indeed, I already patched gcc/config.gcc.
More recently, I found libgcc/config.host and patched it, which solved
the error above.

>> This is the same, I am not intrested in libstdc++, how to disable that?
>
> Run configure with --enable-languages=c.

Well, that's what I already do. I tried something else:
I removed the directory libsdtc++v6 (and other similar lib
directories) in GCC sources
and then no more error about that.

Now, the problem is that the port is not complete and, as a
consequence, when compiling libgcc2.c this happens :
/home/me/gcc/build_target/./gcc/xgcc
-B/home/me/gcc/build_target/./gcc/ -B/home/me/target/target/bin/
-B/home/me/target/target/lib/ -isystem /home/me/target/target/include
-isystem /home/me/target/target/sys-include -O2 -g -g -O2 -O2  -O2 -g
-g -O2   -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition  -isystem ./include   -g  -DIN_LIBGCC2
-D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc  -I. -I. -I../.././gcc
-I../../../gcc-4.3.3/libgcc -I../../../gcc-4.3.3/libgcc/.
-I../../../gcc-4.3.3/libgcc/../gcc
-I../../../gcc-4.3.3/libgcc/../include   -o _muldi3.o -MT _muldi3.o
-MD -MP -MF _muldi3.dep -DL_muldi3 -c
../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c \

../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c: In function ‘__mulsi3’:
../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c:560: internal compiler
error: Segmentation fault

I would like (temporarily) not to compile libgcc2. But, in the same
time, enable compiling of my multhi3. Is that possible? It would be a
libgcc without libgcc2.

Thank you.
Regards.

Florent

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: new port : libgcc ? newlib ?
  2009-03-13 15:09   ` Florent DEFAY
@ 2009-03-13 15:32     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2009-03-13 15:32 UTC (permalink / raw)
  To: Florent DEFAY; +Cc: gcc-help

Florent DEFAY <spira.inhabitant@gmail.com> writes:

> Thank you for your reply. I can precise some things:
>
>>> Then I tried this (just like msp430) :
>>>
>>> LIB1ASMSRC = target/mulhi3.S
>>> LIB1ASMFUNCS = __mulhi3
>>
>> Looks right, assuming you've written mulhi3.S.
>
> I have.
> Will the function __mulhi3 be placed in libgcc.a?

Yes.

> Then, to compile a
> program which use multiplications, should I link with -lgcc option?

The gcc driver will automatically link with -lgcc, unless you use
something like the -nodefaultlibs option.


> Now, the problem is that the port is not complete and, as a
> consequence, when compiling libgcc2.c this happens :
> /home/me/gcc/build_target/./gcc/xgcc
> -B/home/me/gcc/build_target/./gcc/ -B/home/me/target/target/bin/
> -B/home/me/target/target/lib/ -isystem /home/me/target/target/include
> -isystem /home/me/target/target/sys-include -O2 -g -g -O2 -O2  -O2 -g
> -g -O2   -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -W -Wall
> -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
> -Wold-style-definition  -isystem ./include   -g  -DIN_LIBGCC2
> -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc  -I. -I. -I../.././gcc
> -I../../../gcc-4.3.3/libgcc -I../../../gcc-4.3.3/libgcc/.
> -I../../../gcc-4.3.3/libgcc/../gcc
> -I../../../gcc-4.3.3/libgcc/../include   -o _muldi3.o -MT _muldi3.o
> -MD -MP -MF _muldi3.dep -DL_muldi3 -c
> ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c \
>
> ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c: In function ‘__mulsi3’:
> ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c:560: internal compiler
> error: Segmentation fault
>
> I would like (temporarily) not to compile libgcc2. But, in the same
> time, enable compiling of my multhi3. Is that possible? It would be a
> libgcc without libgcc2.

There is no simply way to do this.  You can control it to some extent by
setting LIB2FUNCS_EXCLUDE in your t-* file.  See, e.g.,
config/spu/t-spu-elf.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-13 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-13  9:46 new port : libgcc ? newlib ? Florent DEFAY
2009-03-13 14:21 ` Ian Lance Taylor
2009-03-13 15:09   ` Florent DEFAY
2009-03-13 15:32     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).