public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* [v850] cross compiler - file v850.md
@ 2008-04-10 17:36 p0ulp3
  2008-04-11 12:14 ` Brian Dessent
  0 siblings, 1 reply; 6+ messages in thread
From: p0ulp3 @ 2008-04-10 17:36 UTC (permalink / raw)
  To: gcc-help

Hi everybody,

I am using gcc v 4.3.0 in order to build a cross compiler via cygwin
for v850 target. I have used these commands for the installation :

# installation of binutils, with the sources in /tmp/src/
mkdir -p /tmp/build/binutils
cd /tmp/build/binutils

/tmp/src/binutils-2.10.1/configure --target=v850-elf --prefix=/tools
--exec-prefix=/tools/gnu -v 2>&1 | tee configure.out

make -w all install 2>&1 | tee make.out

# installation of newlib, with the sources in /tmp/src
mkdir -p /tmp/build/newlib
cd /tmp/build/newlib

/tmp/src/newlib-1.16.0/configure  --target=v850-elf --prefix=/tools
--exec-prefix=/tools/gnu -v 2>&1 | tee configure.out

make -w all install 2>&1 | tee make.out

# next, installation of gcc, with the sources in /tmp/src/
PATH=/tools/gnu/bin:$PATH ; export PATH

mkdir -p /tmp/build/gcc
cd /tmp/build/gcc

/tmp/src/gcc-4.3.0/configure --target=v850-elf --prefix=/tools
--exec-prefix=/tools/gnu --with-gnu-as --with-gnu-ld --with-newlib -v
2>&1 | tee configure.out

make -w all-gcc install-gcc LANGUAGES="c c++" 2>&1 | tee make.out

All those commands are executed without problem, and I have finally
gcc for the v850 platform, so then I try to compile a program really
simple but during the linking stage, gcc generates some errors because
it doesn't find some symbols like this one :

main.c:(.text+0x24e): undefined reference to `__callt_save_interrupt'

After a search, I have realized that those symbols are defined in the
file v850.md but this file and the complete directory is not present
on my installation. Actually I can see the directory here :

$ ls /tmp/src/gcc-4.3.0/gcc/config/v850/
lib1funcs.asm  t-v850   v850-c.c       v850.c  v850.md
predicates.md  t-v850e  v850-protos.h  v850.h  v850.opt

The interesting point is that during the compilation of gcc, the file appears  :
[...]
Using `/tmp/src/gcc-4.3.0/gcc/config/v850/v850.c' for machine-specific logic.
Using `/tmp/src/gcc-4.3.0/gcc/config/v850/v850.md' as machine description file.
Using the following target machine macro files:
        /tmp/src/gcc-4.3.0/gcc/config/dbxelf.h
        /tmp/src/gcc-4.3.0/gcc/config/elfos.h
        /tmp/src/gcc-4.3.0/gcc/config/svr4.h
        /tmp/src/gcc-4.3.0/gcc/config/v850/v850.h
[...]
build/genconstants.exe /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md \
	  > tmp-constants.h
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-constants.h
insn-constants.h
[...]
build/genconditions.exe /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md >
tmp-condmd.c
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-condmd.c build/gencondmd.c
[...]
build/genpreds.exe -h /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md > tmp-preds.h
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-preds.h tm-preds.h
[...]
build/genpreds.exe -c /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md > tmp-constrs.h
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-constrs.h tm-constrs.h
[...]
build/genflags.exe /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md \
	  insn-conditions.md > tmp-flags.h
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-flags.h insn-flags.h
[...]
build/genconfig.exe /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md \
	  insn-conditions.md > tmp-config.h
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-config.h insn-config.h
[...]
build/genattrtab.exe /tmp/src/gcc-4.3.0/gcc/config/v850/v850.md \
	  insn-conditions.md > tmp-attrtab.c
/bin/sh /tmp/src/gcc-4.3.0/gcc/../move-if-change tmp-attrtab.c insn-attrtab.c

and those files are used to build libbackend.a

But after a look on google
(http://www.nabble.com/Library-libbackend.a-td16017546.html) this
library seems useless after the build, so do you know where the
symbols in the v850.md file are stored, is it a library I am missing ?

Thanks for your help
p0ulp3

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

* Re: [v850] cross compiler - file v850.md
  2008-04-10 17:36 [v850] cross compiler - file v850.md p0ulp3
@ 2008-04-11 12:14 ` Brian Dessent
  2008-04-11 15:02   ` p0ulp3
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Dessent @ 2008-04-11 12:14 UTC (permalink / raw)
  To: p0ulp3; +Cc: gcc-help

p0ulp3 wrote:

> /tmp/src/gcc-4.3.0/configure --target=v850-elf --prefix=/tools
> --exec-prefix=/tools/gnu --with-gnu-as --with-gnu-ld --with-newlib -v
> 2>&1 | tee configure.out
> 
> make -w all-gcc install-gcc LANGUAGES="c c++" 2>&1 | tee make.out

You should really do --enable-languages=c,c++ when configuring and skip
overloading LANGUAGES at make time.  I think that's a gcc 3.x-ism that
is obsolete with the toplevel bootstrap changes in 4.x (just like "make
bootstrap" is now obsolete and is replaced by
--{enable,disable}-bootstrap.)

> main.c:(.text+0x24e): undefined reference to `__callt_save_interrupt'

I suspect that this function is part of libgcc.  When you use the
"all-gcc" or "install-gcc" targets you tell the build system to build
only the bare compiler itself, not any of its supporting target
libraries.  So it's no surprise then that you can't link with the
result, because libgcc is an essential support library that gcc uses for
all kinds of internal functions.

This "make all-gcc" target is not supposed to make a fully working
compiler, it's only to be used in situations where you don't yet have
target libc headers and thus can't link libgcc.  You're supposed to use
the resulting bare gcc to then configure/build/install your libc and
headers, and then use those to rebuild gcc correctly and in full,
without the all-gcc hack.

> After a search, I have realized that those symbols are defined in the
> file v850.md but this file and the complete directory is not present
> on my installation. Actually I can see the directory here :

.md files are never installed, they are source code for the compiler,
similar to all the other .c files.  You're chasing after the wrong thing
here.  You need to build libgcc, i.e. "make" not "make all-gcc".

Brian

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

* Re: [v850] cross compiler - file v850.md
  2008-04-11 12:14 ` Brian Dessent
@ 2008-04-11 15:02   ` p0ulp3
  2008-04-11 23:54     ` Jim Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: p0ulp3 @ 2008-04-11 15:02 UTC (permalink / raw)
  To: gcc-help, brian

I have tried to rebuild a clean version of gcc with "make" but I am
still experiencing the same problem. By the way, one of the files
created during the installation tries to include files that don't
exist :
/tools/gnu/v850-elf/include/stdlib.h :
[...]
#include "ghs_null.h"		/* defines NULL and size_t */
#include "ghs_wchar.h"		/* defines wchar_t */
[...]

and those files are not known by google or my whole computer, even the
source of gcc, so I think that there is maybe a bug there.

I am currently using the include dir : /tools/gnu/v850-elf/include/
and I have replace the include with :
#include "null.h"
#include "wchar.h"


I have also tried this based on your remark :

$ strings /tools/gnu/lib/gcc/v850-elf/4.3.0/v850e/libgcc.a  | grep
callt | head -n100
[...]
__callt_save_interrupt
__callt_return_interrupt
__callt_save_all_interrupt
__callt_restore_all_interrupt
[...]

So you were right, the libgcc.a contains the symbols I am looking for
but they seem to be not used by ld. Actually by using the --verbose
option in the makefile, I have seen that the libgcc.a used must be
this one :

/tools/gnu/lib/gcc/v850-elf/4.3.0/libgcc.a
and both libs were installed in the same time (based on their creation time)
So I have checked this lib :
$ strings /tools/gnu/lib/gcc/v850-elf/4.3.0/libgcc.a  | grep callt
[...]
_callt_save_interrupt.o/
_callt_save_all_interrupt.o/
[...]

these are the only calls to callt_save_interrupt.o, so it's logical
that the linker doesn't find the symbols. I have then tried to rename
this lib libgcc.a.old to prevent the linker to use it, and I have
added the path for the good one in the makefile but I have an curious
error.

This is the makefile I am using :

#####
CC=/tools/gnu/bin/v850-elf-gcc.exe
CFLAGS=-mv850e -I/tools/gnu/v850-elf/include/
LDFLAGS=--verbose -Wl, -L/tools/gnu/lib/gcc/v850-elf/4.3.0/v850e/
EXEC=test
SRC= $(wildcard src/*.c)
OBJ= $(SRC:.c=.o)

all: $(EXEC)

$(EXEC): $(OBJ)
	$(CC) -o $@ $(LDFLAGS) $^

%.o: %.c
	$(CC) -o $@ -c $(CFLAGS) $<

clean:
	rm -rf src/*.o
	rm -rf *.i
	rm -rf *.s
#####

and the output when I try to include the good library :

#####
$ make -w clean && make 2>&1 | tee make.out
make: Entering directory `/home/poulpe/test_sylvain'
rm -rf src/*.o
rm -rf *.i
rm -rf *.s
make: Leaving directory `/home/poulpe/test_sylvain'
/tools/gnu/bin/v850-elf-gcc.exe -o src/Display.o -c -mv850e -I/tools/gnu/v850-el
f/include/ src/Display.c
/tools/gnu/bin/v850-elf-gcc.exe -o src/main.o -c -mv850e -I/tools/gnu/v850-elf/i
nclude/ src/main.c
src/main.c: In function 'main':
src/main.c:39: warning: return type of 'main' is not 'int'
/tools/gnu/bin/v850-elf-gcc.exe -o test --verbose -Wl, -L/tools/gnu/lib/gcc/v850
-elf/4.3.0/v850e/  src/Display.o src/main.o
Using built-in specs.
Target: v850-elf
Configured with: /tmp/src/gcc-4.3.0/configure --target=v850-elf --prefix=/tools
--exec-prefix=/tools/gnu --with-gnu-as --with-gnu-ld --with-newlib --enable-lang
uages=c,c++ -v
Thread model: single
gcc version 4.3.0 (GCC)
COMPILER_PATH=/tools/gnu/libexec/gcc/v850-elf/4.3.0/:/tools/gnu/libexec/gcc/v850
-elf/4.3.0/:/tools/gnu/libexec/gcc/v850-elf/:/tools/gnu/lib/gcc/v850-elf/4.3.0/:
/tools/gnu/lib/gcc/v850-elf/:/tools/gnu/lib/gcc/v850-elf/4.3.0/../../../../../gn
u/v850-elf/bin/
LIBRARY_PATH=/tools/gnu/lib/gcc/v850-elf/4.3.0/:/tools/gnu/lib/gcc/v850-elf/4.3.
0/../../../../../gnu/v850-elf/lib/
COLLECT_GCC_OPTIONS='-o' 'test' '-v' '-L/tools/gnu/lib/gcc/v850-elf/4.3.0/v850e/
'
 /tools/gnu/libexec/gcc/v850-elf/4.3.0/collect2.exe -o test /tools/gnu/lib/gcc/v
850-elf/4.3.0/../../../../../gnu/v850-elf/lib/crt0.o -L/tools/gnu/lib/gcc/v850-e
lf/4.3.0/v850e/ -L/tools/gnu/lib/gcc/v850-elf/4.3.0 -L/tools/gnu/lib/gcc/v850-el
f/4.3.0/../../../../../gnu/v850-elf/lib  src/Display.o src/main.o -lgcc -lc -lgc
c
/tools/gnu/lib/gcc/v850-elf/4.3.0/../../../../../gnu/v850-elf/bin/ld: : No such
file: No such file or directory
collect2: ld returned 1 exit status
make: *** [test] Error 1
#####

And the output with the bad library (no -Wl option in makefile and
libgcc.a.old renamed to libgcc.a)

#####
$ make -w clean && make 2>&1 | tee make.out
make: Entering directory `/home/sboivineau/test_sylvain'
rm -rf src/*.o
rm -rf *.i
rm -rf *.s
make: Leaving directory `/home/sboivineau/test_sylvain'
/tools/gnu/bin/v850-elf-gcc.exe -o src/Display.o -c -mv850e -I/tools/gnu/v850-el
f/include/ src/Display.c
/tools/gnu/bin/v850-elf-gcc.exe -o src/main.o -c -mv850e -I/tools/gnu/v850-elf/i
nclude/ src/main.c
src/main.c: In function 'main':
src/main.c:39: warning: return type of 'main' is not 'int'
/tools/gnu/bin/v850-elf-gcc.exe -o test --verbose  src/Display.o src/main.o
Using built-in specs.
Target: v850-elf
Configured with: /tmp/src/gcc-4.3.0/configure --target=v850-elf --prefix=/tools
--exec-prefix=/tools/gnu --with-gnu-as --with-gnu-ld --with-newlib --enable-lang
uages=c,c++ -v
Thread model: single
gcc version 4.3.0 (GCC)
COMPILER_PATH=/tools/gnu/libexec/gcc/v850-elf/4.3.0/:/tools/gnu/libexec/gcc/v850
-elf/4.3.0/:/tools/gnu/libexec/gcc/v850-elf/:/tools/gnu/lib/gcc/v850-elf/4.3.0/:
/tools/gnu/lib/gcc/v850-elf/:/tools/gnu/lib/gcc/v850-elf/4.3.0/../../../../../gn
u/v850-elf/bin/
LIBRARY_PATH=/tools/gnu/lib/gcc/v850-elf/4.3.0/:/tools/gnu/lib/gcc/v850-elf/4.3.
0/../../../../../gnu/v850-elf/lib/
COLLECT_GCC_OPTIONS='-o' 'test' '-v'
 /tools/gnu/libexec/gcc/v850-elf/4.3.0/collect2.exe -o test /tools/gnu/lib/gcc/v
850-elf/4.3.0/../../../../../gnu/v850-elf/lib/crt0.o -L/tools/gnu/lib/gcc/v850-e
lf/4.3.0 -L/tools/gnu/lib/gcc/v850-elf/4.3.0/../../../../../gnu/v850-elf/lib src
/Display.o src/main.o -lgcc -lc -lgcc
src/main.o: In function `_main':
main.c:(.text+0x10): undefined reference to `___DI'
main.c:(.text+0x2c): undefined reference to `___EI'
src/main.o: In function `_INTP4':
main.c:(.text+0x24e): undefined reference to `__callt_save_interrupt'
main.c:(.text+0x24e): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_save_interrupt'
main.c:(.text+0x250): undefined reference to `__callt_save_all_interrupt'
main.c:(.text+0x250): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_save_all_interrupt'
main.c:(.text+0x344): undefined reference to `__callt_restore_all_interrupt'
main.c:(.text+0x344): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_restore_all_interrupt'
main.c:(.text+0x346): undefined reference to `__callt_return_interrupt'
main.c:(.text+0x346): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_return_interrupt'
src/main.o: In function `_INTP5':
main.c:(.text+0x360): undefined reference to `__callt_save_interrupt'
main.c:(.text+0x360): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_save_interrupt'
main.c:(.text+0x362): undefined reference to `__callt_save_all_interrupt'
main.c:(.text+0x362): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_save_all_interrupt'
main.c:(.text+0x368): undefined reference to `___EI'
src/main.o: In function `_INTP9':
main.c:(.text+0x412): undefined reference to `__callt_save_interrupt'
main.c:(.text+0x412): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_save_interrupt'
main.c:(.text+0x414): undefined reference to `__callt_save_all_interrupt'
main.c:(.text+0x414): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_save_all_interrupt'
main.c:(.text+0x482): undefined reference to `__callt_restore_all_interrupt'
main.c:(.text+0x482): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_restore_all_interrupt'
main.c:(.text+0x484): undefined reference to `__callt_return_interrupt'
main.c:(.text+0x484): relocation truncated to fit: R_V850_CALLT_6_7_OFFSET again
st undefined symbol `__callt_return_interrupt'
collect2: ld returned 1 exit status
make: *** [test] Error 1
#####

Thanks for your help




2008/4/10, Brian Dessent <brian@dessent.net>:
> p0ulp3 wrote:
>
>  > /tmp/src/gcc-4.3.0/configure --target=v850-elf --prefix=/tools
>  > --exec-prefix=/tools/gnu --with-gnu-as --with-gnu-ld --with-newlib -v
>  > 2>&1 | tee configure.out
>  >
>  > make -w all-gcc install-gcc LANGUAGES="c c++" 2>&1 | tee make.out
>
>
> You should really do --enable-languages=c,c++ when configuring and skip
>  overloading LANGUAGES at make time.  I think that's a gcc 3.x-ism that
>  is obsolete with the toplevel bootstrap changes in 4.x (just like "make
>  bootstrap" is now obsolete and is replaced by
>  --{enable,disable}-bootstrap.)
>
>
>  > main.c:(.text+0x24e): undefined reference to `__callt_save_interrupt'
>
>
> I suspect that this function is part of libgcc.  When you use the
>  "all-gcc" or "install-gcc" targets you tell the build system to build
>  only the bare compiler itself, not any of its supporting target
>  libraries.  So it's no surprise then that you can't link with the
>  result, because libgcc is an essential support library that gcc uses for
>  all kinds of internal functions.
>
>  This "make all-gcc" target is not supposed to make a fully working
>  compiler, it's only to be used in situations where you don't yet have
>  target libc headers and thus can't link libgcc.  You're supposed to use
>  the resulting bare gcc to then configure/build/install your libc and
>  headers, and then use those to rebuild gcc correctly and in full,
>  without the all-gcc hack.
>
>
>  > After a search, I have realized that those symbols are defined in the
>  > file v850.md but this file and the complete directory is not present
>  > on my installation. Actually I can see the directory here :
>
>
> .md files are never installed, they are source code for the compiler,
>  similar to all the other .c files.  You're chasing after the wrong thing
>  here.  You need to build libgcc, i.e. "make" not "make all-gcc".
>
>
>  Brian
>

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

* Re: [v850] cross compiler - file v850.md
  2008-04-11 15:02   ` p0ulp3
@ 2008-04-11 23:54     ` Jim Wilson
  2008-04-14 16:04       ` p0ulp3
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Wilson @ 2008-04-11 23:54 UTC (permalink / raw)
  To: p0ulp3; +Cc: gcc-help, brian

p0ulp3 wrote:
> #include "ghs_null.h"		/* defines NULL and size_t */
> #include "ghs_wchar.h"		/* defines wchar_t */
> [...]

GHS is Green Hills Software.  It looks like you have accidentally mixed 
up the GHS and GCC toolchains somehow.

> CFLAGS=-mv850e -I/tools/gnu/v850-elf/include/
> LDFLAGS=--verbose -Wl, -L/tools/gnu/lib/gcc/v850-elf/4.3.0/v850e/

You must use the some options when linking as when compiling.  Add 
-mv850e to LDFLAGS and your problem will go away, as that tells gcc to 
use the v850e version of libgcc.  And drop the explicit -L option, that 
isn't necessary or useful.

Jim

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

* Re: [v850] cross compiler - file v850.md
  2008-04-11 23:54     ` Jim Wilson
@ 2008-04-14 16:04       ` p0ulp3
  2008-04-14 18:06         ` Jim Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: p0ulp3 @ 2008-04-14 16:04 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc-help, brian

Hi,

>  You must use the some options when linking as when compiling.  Add -mv850e
> to LDFLAGS and your problem will go away, as that tells gcc to use the v850e
> version of libgcc.  And drop the explicit -L option, that isn't necessary or
> useful.
>
>  Jim

You solved a part of the problem, the flag -mv850e was missing for the
linker, and now the symbols callt_... are resolved, but the symbols
___DI() and ___EI() are still unresolved :

$ make clean && make 2>&1 | tee make.out
rm -rf src/*.o
rm -rf *.i
rm -rf *.s
/tools/gnu/bin/v850-elf-gcc.exe -o src/Display.o -c -mv850e -I/tools/gnu/v850-el
f/include/ src/Display.c
/tools/gnu/bin/v850-elf-gcc.exe -o src/main.o -c -mv850e -I/tools/gnu/v850-elf/i
nclude/ src/main.c
src/main.c: In function 'main':
src/main.c:39: warning: return type of 'main' is not 'int'
/tools/gnu/bin/v850-elf-gcc.exe -o test -mv850e src/Display.o src/main.o
src/main.o: In function `_main':
main.c:(.text+0x10): undefined reference to `___DI'
main.c:(.text+0x30): undefined reference to `___EI'
src/main.o: In function `_INTP5':
main.c:(.text+0x370): undefined reference to `___EI'
collect2: ld returned 1 exit status
make: *** [test] Error 1

So I have replaced each call of __DI() and __EI() by asm("di") and
asm("ei") and the program is linked now but if anyone has an idea to
solve this problem, let me know.

Thanks again for your help
p0ulp3

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

* Re: [v850] cross compiler - file v850.md
  2008-04-14 16:04       ` p0ulp3
@ 2008-04-14 18:06         ` Jim Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Jim Wilson @ 2008-04-14 18:06 UTC (permalink / raw)
  To: p0ulp3; +Cc: gcc-help, brian

p0ulp3 wrote:
> So I have replaced each call of __DI() and __EI() by asm("di") and
> asm("ei") and the program is linked now but if anyone has an idea to
> solve this problem, let me know.

Why are you expecting calls to __DI() to generate a "di" instruction? 
Maybe that is a GHS specific feature that GCC doesn't implement?  If so, 
  then add a macro that is defined only when __GNUC__ is defined that 
expands __DI() to asm("di") for gcc.

Jim

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

end of thread, other threads:[~2008-04-14 16:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-10 17:36 [v850] cross compiler - file v850.md p0ulp3
2008-04-11 12:14 ` Brian Dessent
2008-04-11 15:02   ` p0ulp3
2008-04-11 23:54     ` Jim Wilson
2008-04-14 16:04       ` p0ulp3
2008-04-14 18:06         ` Jim Wilson

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).