modyfing cross toolchain compilation

Nathan Whitehorn nwhitehorn at freebsd.org
Mon Oct 21 13:45:10 UTC 2013


On 10/21/13 01:38, Aleksander wrote:
> hello!
>
> Few days ago, when playing with linux-ppc, I have identified a bug with
> PowerPC toolchain. It turns out that PowerPC e500 core is not compilant
> with generic ppc ISA - it lacks of 'lwsync' instruction. This instruction
> is used in libstdc++.so library, so I need to modify toolchain build
> process by adding -me500v2 option, when building  libraries. Can you tell
> me how to do it, so I can test this potential soluton?
>

Which core is this? sync (and lwsync) are supposed to be supported on
all PowerPC processors, since they are part of Book II and is *supposed*
to be transparently interpreted as "sync" if not supported since the L
field of the encoding was reserved previous to the introduction of
lwsync. So I think your CPU is broken. It seems like GCC does have some
hacks for this and may do the right thing via adding some #defines if
you set CPUTYPE=8450 in make.conf, but it doesn't look like the relevant
glue in config/rs6000 is hooked up for that at present. Without those,
since the instruction is supposed to be valid, it will happily compile
and assemble it.

So an immediate solution is to just change the instruction in libstdc++
to "sync". Longer term, probably the Book-E kernel should trap lwsync
illegal instruction faults and interpret them as "sync" (or do nothing,
actually, since a trap is as good as a sync) on such broken cores. I
doubt this is the last piece of code is userland or ports that assumes
that Book-II instructions are valid. This keeps binary compat with
compliant cores. We should also fix up GCC so it sets TARGET_E500 if the
right CPUTYPE is set so that natively compiled executables don't hit the
trap.
-Nathan


More information about the freebsd-hackers mailing list