[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
hello world for ada compilation (again ...)
- Date: Wed, 13 Oct 1999 16:23:52 -0500
- From: joel.sherrill at OARcorp.com (Joel Sherrill)
- Subject: hello world for ada compilation (again ...)
Kris Hermans wrote:
>
> Hello,
>
> I installed the crosscompiler for gnat/rtems and even succeeded in
> compiling the kernel.
> My system is debian linux, GNAT/RTEMS with target = pc386.
I attached Makefile.pc386. It worked at one point. :)
What you are trying to do is make gnatmake link applications the
same way the make-exe rule does in make/custom/pc386.cfg.
> Sadly, in the sample app (hello_world_ada), there is no makefile included
> for my set-up. While trying to figure out one for myself, I have a few
> questions:
>
> * in the file MakeFile.erc32 there is the line:
> CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems -mcypress I guess this
> defines some flags to pass to the binder and the linker. However, I don't
> get the actual meaning of it (what is bsp_specs, qrtems, mcypress and how
> do I have to modify it for a pc386 ?)
TO help clarify things...
Everything from the -B ... -qrtems just enables the BSP specific "specs"
file and tells it to use the rules for linking with RTEMS. bsp_specs
is an extension to the internal gcc rules for building things.
-mcypress is VERY sparc specific -mcpu=i486 would be a comparable
example from the i386 world.
>
> However, make complains:
>
> make -f Makefile.pc386.old
> /home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/bin/i386-rtems-gcc -O4 -g -Wall
> -ansi -fasm -B/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/
> -specs bsp_specs -qrtems -mcypress -c init.c
> cc1: Invalid option `cypress'
> make: *** [init.o] Error 1
Exactly this specifies a sparc specific option.
> * So, I leave out the invalid option (without knowing what it means ...).
> I get:
>
> make -f Makefile.pc386.old
> /home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/bin/i386-rtems-gcc -O4 -g -Wall
> -ansi -fasm -B/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/
> -specs bsp_specs -qrtems -c init.c
> /home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/bin/i386-rtems-gnatmake -v -O
> -gnata -gnatE -gnato hello -g \
> -bargs -r \
> -cargs -B/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/
> -specs bsp_specs -qrtems \
> -largs -B/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/
> -specs bsp_specs -qrtems init.o
>
> GNATMAKE 3.11p (981118) Copyright 1995-1998 Free Software Foundation,
> Inc.
> "hello.ali" being checked ...
> -> "hello.ali" missing.
> i386-rtems-gcc -c -O -gnata -gnatE -gnato -g
> -B/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/ -specs
> bsp_specs -qrtems hello.adb
> hello.adb:7:11: warning: file name does not match unit name, should be
> "main.adb"
> i386-rtems-gnatbind -aO./ -r -I- -x hello.ali
> i386-rtems-gnatlink -g
> -B/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/ -specs
> bsp_specs -qrtems init.o hello.ali
> i386-rtems-gcc: file path prefix
> `/home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/rtems/pc386/lib/' never used
> /home/pcuser8/RTEMS/gnat-3.11p/i386-rtems/bin/i386-rtems-size hello
> text data bss dec hex filename
> 154464 6076 42188 202728 317e8 hello
>
> What is the meaning of this all ? Did I succeed ? Why isn 't there a file
> with a .exe extension (I have just plain "hello", can I use this for
> creating a bootable disk with grub ?).
It looks like you got a hello executable. Unfortunately, the rule
is not putting the end result in hello.exe as expected.
DO a "file" on hello. It appears to be an executable. If it is the
same format as the C sample executables, then you should be OK that
much.
Be warned, the makefile I sent you forces some addresses on the link.
I don't know if your modifications produced the same result.
> Sorry for all the (perhaps silly) qustions, but I really want to be sure
> that my compile set-up is ok, before proceeding with actually executing
> the apps.
These aren't silly. It is difficult to explain how to make gnatmake
produce executable for RTEMS.
> Thanks for the answers,
>
> Kris (a RTEMS newbie, but I guess you figured this out already ;-))
You are doing fine.
Building gnat is not for the faint of heart. Using gnatmake to produce
applications requires careful comparison of what make-exe is doing and
what you can gnatmake is doing.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
-------------- next part --------------
#
# Makefile for hello world example
#
MAIN=hello
# Tool paths
target=i386-rtems
tooldir=/home/joel/gnat-3.10p/${target}/
rtemsdir=${tooldir}/rtems/pc386
# Tool names
GCC=${tooldir}/bin/${target}-gcc
GNATMAKE=${tooldir}/bin/${target}-gnatmake
SIZE=${tooldir}/bin/${target}-size
OBJCOPY=${tooldir}/bin/${target}-objcopy
NM=${tooldir}/bin/${target}-nm
HEADERADDR=0x00097E00
START16FILE=$(rtemsdir)/lib/start16.bin
START16ADDR=0x00097C00
RELOCADDR=0x00100000
CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems \
-Wl,-Ttext,$(RELOCADDR) -Wl,--oformat,elf32-i386
all: init.o $(MAIN)
$(MAIN): $(MAIN).exe
ln $(MAIN).exe $(MAIN)
$(MAIN).exe: init.o
$(GNATMAKE) -v -O -gnata -gnatE -gnato $(MAIN) -g -o $(MAIN).obj \
-bargs -r \
-cargs $(CARGS) \
-largs $(CARGS) init.o
$(SIZE) $(MAIN).obj
$(NM) -g -n $(MAIN).obj >$(MAIN).num
$(OBJCOPY) -O a.out-i386 \
--remove-section=.rodata \
--remove-section=.comment \
--remove-section=.note \
--strip-unneeded $(MAIN).obj $@
$(OBJCOPY) -O binary $(MAIN).obj $(MAIN).bin
$(rtemsdir)/build-tools/bin2boot -v $(MAIN).bt $(HEADERADDR) \
$(START16FILE) $(START16ADDR) 0 $(MAIN).bin $(RELOCADDR) 0
init.o: init.c
$(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) \
-DGNAT_MAIN_STACKSPACE=16 -c init.c
clean:
rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN)