Re: New backend

Segher Boessenkool <[email protected]> Wed, 31 Dec 2025 05:31:08 -0600
Newsgroups gmane.comp.gcc.help
Message-ID <aVUJfMpH4zF9o3fd@gate>
Hi!

On Wed, Dec 31, 2025 at 11:02:41AM +0100, BERTRAND Joël wrote:
> Segher Boessenkool a écrit :
> > On Tue, Dec 30, 2025 at 01:52:09PM +0100, BERTRAND Joël via Gcc-help wrote:
> >> 	As it's the first time I'm trying to add a backend, I suppose I have
> >> done a mistake. Help will be welcome.
> > 
> > You get the errors
> > 
> >> genautomata: unit `m6809' is not used
> >> genautomata: unit `m6309' is not used
> > 
> > and that is indeed true: you have define_unit's, but nothing actually
> > uses those units, so nthe builld system thinks that perhaps you typoed
> > things.  Either actually use the units, or remove the define_unit's
> > (well, you probably don't really want the delete it, but you can comment
> > it out for now?)
> 
> 	Thanks for your answer. I have continued to learn gcc internal but it's
> very cryptic.
> 
> 	As I obtain errors or segmentation fault, I have tried in a first time
> to port gcc/config/m6809 from gcc 4.3 to 15.2.

Wow, 4.3 is 18 years old now :-)

> Of course, build process
> returns a lot of errors. I have fixed a lot of errors but some poisoned
> defineds resist.
> 
> 	RETURN_POPS_ARGS

This was converted to a target hook, so, a function instead of a C
preprocessor macro, in 2003 or so.

> 	FUNCTION_ARG_ADVANCE
> 	FUNCTION_ARG
> 	TRAMPOLINE_TEMPLATE
> 	INITIALIZE_TRAMPOLINE
> 	LEGITIMATE_CONSTANT_P
> 	LEGITIMIZE_ADDRESS
> 	GO_IF_MODE_DEPENDENT_ADDRESS
> 	FIXUNS_TRUNC_LIKE_FIX_TRUNC
> 	FLOAT_TYPE_SIZE
> 	TRULY_NOOP_TRUNCATION
> 	NOTICE_UPDATE_CC
> 
> 	I can send a tarball (63 KB) but is there somewhere a document to port
> a backend from gcc 4.3 to recent gcc ?

I would do this in smaller steps, so, first, port from 4.3 to 4.7 or so
(that's 4 years of new stuff and changes), and then 6.1, and then 10.1
maybe, 14.1, and then trunk (I'd not try to make any specific release
work, just trunk).

That way, not overwhelmingly much changes per step, but every step still
brings you quite a bit of progress.

Many thing that in the bad old days used to be a macro now are a target
hook.  Usually the names stayed (almost) the same, but no longer in
SHOUTING_CAPS.

So just dive in, fix all problems one by one.  23 years of improvements
is no tiny amount.

You could read the release notes for intermediate versions; it often
tells you a bit about what changed.  Or googling lets you find all kinds
of things in the public archives for the GCC MLs (gcc@ and gcc-patches@,
mostly), that can give you some inspiration where needed.

And of course, feel free to ask more targeted questions here, or on IRC
(#gcc on oftc.net), etc.

Good luck, and have fun!


Segher