Ada Tricore-gcc (trying and failing to build)

Hi folks!

I have to target Tricore for some of my work. As far as I know, only Greenhills has an Ada compiler that supports it. But I’ve been curious why GCC couldn’t target it as well.

There is a tricore-gcc repo to build from source: GitHub - EEESlab/tricore-gcc-toolchain-11.3.0 and I thought I’d grab that and try and enable Ada for it.

Stage1 builds, but Stage2 fails:

Adding multilib support to Makefile in /tmp/tricore-gcc/tricore-gcc/libada
with_multisubdir=tc18/short-double
done
configure: creating ./config.status
make[2]: Entering directory '/tmp/tricore-gcc/BUILD/gcc-stage2/tricore-elf/libada'
make -C ../.././gcc/ada "MAKEOVERRIDES=" "LDFLAGS=" "LN_S=ln -s" "SHELL=/bin/bash" "GNATLIBFLAGS=-W -Wall -gnatpg -nostdinc " "GNATLIBCFLAGS=-g -O2 " "GNATLIBCFLAGS_FOR_C=-W -Wall -g -O2 -g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit -fexceptions -DIN_RTS -DHAVE_GETIPINFO  " "PICFLAG_FOR_TARGET=-fPIC" "THREAD_KIND=native" "TRACE=no" "MULTISUBDIR=" "libsubdir=/tmp/tricore-gcc/INSTALL/lib/gcc/tricore-elf/11.3.1" "toolexeclibdir=/tmp/tricore-gcc/INSTALL/lib/gcc/tricore-elf/11.3.1/adalib" "objext=.o" "prefix=/tmp/tricore-gcc/INSTALL" "exeext=.exeext.should.not.be.used " 'CC=the.host.compiler.should.not.be.needed' "GCC_FOR_TARGET=/tmp/tricore-gcc/BUILD/gcc-stage2/./gcc/xgcc -B/tmp/tricore-gcc/BUILD/gcc-stage2/./gcc/ -B/tmp/tricore-gcc/INSTALL/tricore-elf/bin/ -B/tmp/tricore-gcc/INSTALL/tricore-elf/lib/ -isystem /tmp/tricore-gcc/INSTALL/tricore-elf/include -isystem /tmp/tricore-gcc/INSTALL/tricore-elf/sys-include   " "CFLAGS=-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit" ./bldtools/oscons/xoscons
make[3]: Entering directory '/tmp/tricore-gcc/BUILD/gcc-stage2/gcc/ada'
mawk -v FORMAT=Makefile -f /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/gendevices.awk /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/gendevices.awk /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/devices.def > tmp-tricore-mlib
/bin/bash /tmp/tricore-gcc/tricore-gcc/gcc/../move-if-change \
	tmp-tricore-mlib /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/t-multilib
Adding multilib support to libsupc++/Makefile in /tmp/tricore-gcc/tricore-gcc/libstdc++-v3
with_multisubdir=tc131
s-tricore-mlib
/bin/bash: s-tricore-mlib: command not found
make[3]: *** [/tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/t-tricore:63: s-tricore-mlib] Error 127
make[3]: Leaving directory '/tmp/tricore-gcc/BUILD/gcc-stage2/gcc/ada'
make[2]: *** [Makefile:116: osconstool] Error 2
make[2]: Leaving directory '/tmp/tricore-gcc/BUILD/gcc-stage2/tricore-elf/libada'
make[1]: *** [Makefile:15199: all-target-libada] Error 2
make[1]: *** Waiting for unfinished jobs....

The build works and completes fine without Ada as a selected language. So I’m not sure what else is configured in this script that might be incompatible.
Does this error seem familiar to anyone? Is it something obvious to avoid when building an Ada toolchain? Or is it just that fundamentally the Ada support isn’t compatible with this architecture?

Cheers!
Chip

Does gcc support it?

I’m unaware of any tricore toolchain vendor that supports Ada other than Greenhills. But, to be honest, I also have no idea what’s involved in making one language work and not the others.
I guess it isn’t just a simple matter then. :smiley: Oh well.

You would need to go into the gcc internals docs to extend GCC to support it (I hope you like lisp as c macros?) then extend GNAT (start at the gcc-interface dir) to extend that.

Does stage 1 build Ada OK? (and, are you working towards a cross-compiler? because I thought that all such only ran stage 1 anyway)

GCC’s manual doesn’t show tricore as supported, but a quick (<1s) search showed me this.

That’s the repo I’m using. They have a meta repo with a build script. I just added Ada to the enabled languages in that and crossed my fingers basically.

Stage 1 “apparently” builds, but I don’t have gnatmake, and gcc -c hello.ada tells me that an Ada compiler isn’t available. In ‘bin’ I have a tricore-elf-gnatbind but no other gnat tools that I can tell.

Ah I see. I have just checked the Makefile.rtl and it does not have the required sections to match the tricore architecture.

You’d need to look at that and add what you need to get basic zfp profile going and then add more to whatever profile is required.

Lines like this:

s-vxwork.ads<libgnarl/s-vxwork__ppc.ads \

are essentially “renames,” but ht escript will create links to the LHS from the RHS of the < symbol.

1 Like

This is the script I use for building a cross-to-arm-eabi compiler; the part that took me a long time to get right (thanks, Arnaud!) was line 38,

make -w -C gcc cross-gnattools ada.all.cross

The normal recommendation is that you use a native compiler at the same release as the one you’re trying to build, but if you’ve got gnatbind things must be looking good!

1 Like

He still needs a tricore section in that makefile.rtl even for tricore-elf, iirc.

Yep, just to confirm that stage1 was missing the Ada build, using make all-gnattools ended up in the same error:

make[2]: Entering directory '/tmp/tricore-gcc/BUILD/gcc-stage1/gcc/ada'
mawk -v FORMAT=Makefile -f /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/gendevices.awk /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/gen
devices.awk /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/devices.def > tmp-tricore-mlib                                                   /bin/bash /tmp/tricore-gcc/tricore-gcc/gcc/../move-if-change \
        tmp-tricore-mlib /tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/t-multilib
s-tricore-mlib
/bin/bash: s-tricore-mlib: command not found
make[2]: *** [/tmp/tricore-gcc/tricore-gcc/gcc/config/tricore/t-tricore:63: s-tricore-mlib] Error 127
make[2]: Leaving directory '/tmp/tricore-gcc/BUILD/gcc-stage1/gcc/ada'
make[1]: *** [Makefile:116: osconstool] Error 2
make[1]: Leaving directory '/tmp/tricore-gcc/BUILD/gcc-stage1/tricore-elf/libada'
make: *** [Makefile:15199: all-target-libada] Error 2

So when looking over the Makefile.rtl file, I didn’t exactly see a good template to start from. @Lucretia your example with vxworks lines is perfectly clear, but the section in the file for *-elf only has a single line.

I’ll have to learn a bit more about which lines I need to adapt I think. The *-elf section was my first thought for a bare-metal target.

I’ve had a look, but it’s all changed since I last looked, about 10-20 years ago. There used to be files with mlib in the name, tgt means target specific and there were files with that name too, iirc, so I don’t know it they’re generated, most likely. But IIRC, there was a rule that used to have something like tgt-mlib in it and you had to set that up for your target.

Probably best to do a find in the build fir for ‘mlib’ and ‘tgt’ and then ls -l them to see where they’re linked to if they exist and try to find the makefile location that way, you might also have to look in the generated makefiles to find them.

1 Like