[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] CPU detection broken
Patrice Mandin wrote:
Since the start, I was wondering if it was possible to simply use a
different crt0.o file. With multilib enabled, libraries come from
m68020-60/m68020/default directories, so is it possible for crt0.o file
to follow this?
Yes, it is possible !
I checked with GCC 4, if a file named crt0.o exists in the multilib
directory, it is used instead of the default one. It is probably the
same with GCC 2.95.
If it would be possible, it would simply be compiled for m68000 for the
3 versions, and given some -m68020/-m68020-60 related define, it would
check if the required CPU is present.
At first, I planned to do the CPU check like that.
It would have required to use multiple crt0.o as discussed above.
For clarity, I put the CPU detection in a separate function called
_checkcpu(). It is included in libc.a, so its implementation can use
ifdefs to check for the various CPU. So currently, the common crt0.o
unconditionally calls _checkcpu(), for every multilib.
You say that crt0.o could be compiled for m68000. Since it is an
assembly source, it doesn't really matter (except for jump pseudo-ops).
But it must be the same for all the functions called before the CPU
check, namely Getcookie() and get_sysvar(), which were written in C. It
would have work for 68000/68020, but not for ColdFire, because when
generating code for 68000 the compiler use instructions not available on
ColdFire. So the only solution is to write manually these functions in
assembly with instructions compatible with 68000 and ColdFire, what I
did. Fortunately, there are no performance or size issues.
However, the fact of having a common crt0.o for all targets is very
annoying, because it can't contain additional functions specific to a
target, as it can't contain ifdefs. In particular, I would like to avoid
calling the empty _checkcpu() for 68000, but it is not currently
possible. It would be OK with multiple crt0.o.
What other people think ?
Using a specific crt0.o for each target would allow to put ifdefs in
crt0.S, it would bring more flexibility. This goal could be reached
quite easily by modifying the Makefiles.
--
Vincent Rivière