Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 140205 - GCC-4 for SH-4 needs some multilib support
Summary: GCC-4 for SH-4 needs some multilib support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GCC Porting (show other bugs)
Hardware: sh Other
: High minor (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 145850 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-13 02:34 UTC by Manuel Lauss
Modified: 2006-09-17 12:28 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Crude hack to add multilib support to SuperH-GCC4 compilers (portage-gcc4-superh-multilib.patch,1.13 KB, patch)
2006-09-08 00:14 UTC, Manuel Lauss
Details | Diff
gcc4-sh-multilib.patch (gcc4-sh-multilib.patch,542 bytes, patch)
2006-09-13 23:29 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Lauss 2006-07-13 02:34:54 UTC
Hello!

GCC-4 for SH-4/SH-4a needs multilib support to be able to compile a kernel.
The default sh4-linux cross compiler produced by crossdev only supports the
'-m4' architecture flag; to build a kernel, '-m4-nofpu' must additionally be
supported (same for sh-4a). GCC-3 supports all by default.

It need not be anything fancy, simply passing '--enable-multilib --with-multilib-list=m4,m4-nofpu,m4-single,m4a,m4a-nofpu,m4a-single' to the configure script is enough.

Thanks!
Comment 1 SpanKY gentoo-dev 2006-07-13 20:13:03 UTC
i thought the gcc-4 peeps were doing retarded stuff with SH ... so if you wanted a nofpu compiler, you had to build for like a sh4_nofpu-linux-gnu target
Comment 2 Manuel Lauss 2006-07-14 00:13:44 UTC
well, if you crossdev with '-t sh' then you get a compiler which
supports all those architectures, but then glibc does not build :)

All I want is a GCC-4 which can build kernels (never mind that gcc-4
currently creates unbootable kernels), and possibly a gcc-4 that runs
on SH-4 (to build qt4-embedded and ultimately opie) and for that at
a minumum m4 and m4-nofpu support is required. 
Comment 3 SpanKY gentoo-dev 2006-07-14 19:17:59 UTC
i was gonna say, i'm pretty sure it's been a while since gcc-4 produced bootable kernels on sh :)

i use 3.4.6 still with most stuff
Comment 4 SpanKY gentoo-dev 2006-07-15 13:22:31 UTC
i dont like the notion of hard coding target values into the eclass ... anyway we could pull a list of those targets dynamically at buildtime ?
Comment 5 Manuel Lauss 2006-07-16 02:19:42 UTC
How about an envvar MULTILIB_LIST, which gets evaluated by the ebuild/whatever.
Crossdev can set it in response to the '-t ' parameter. For '-t sh4' it should
set it to "m4,m4-nofpu,.." and for '-t sh4a' to "m4a,m4a-nofpu,..."
If someone wants to emerge gcc-4 for CHOST=CTARGET=sh4, then he/she can set additional archs in MULTILIB_LIST prior to emerge.

(there was once a multilib USE flag, no?)
Comment 6 SpanKY gentoo-dev 2006-07-16 14:46:18 UTC
there still is a multilib USE flag ... but what i meant was to have the toolchain.eclass do something like:
if use sh && use multilib ; then
  myconf="${myconf} --enable-multilib"
  myconf="${myconf} --with-multilib=$(grep out all valid targets)"
fi
Comment 7 Manuel Lauss 2006-07-24 23:28:29 UTC
I have no other idea than the one I wrote down in comment #5.
Maybe print a big warning in the gcc ebuild if tc-arch==sh that
the "standard" ebuild only produces a compiler suitable for userspace
and if you want to build a kernel (or for a special version of SH chips like the
sh4-dsp, sh3e, etc),
you have to specify the supported target archs in an environment variable
(maybe with a link to http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/SH-Options.html#SH-Options
)
Comment 8 SpanKY gentoo-dev 2006-07-30 23:05:15 UTC
maybe something like:

if [[ ${CTARGET} == sh* ]] && use multilib ; then
  local sh_multilib=$(sed \
  -n '/^[[:space:]]*\*) sh_multilibs=/{s:.*=\([^[:space:]]*\).*;;:\1:;p}' \
  config.gcc)

  myconf="${myconf} --enable-multilib"
  myconf="${myconf} --with-multilib=${sh_multilib}"
fi

that gives me:
m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single

but still the nofpu target is missing ... what a pain ... it may be easier to write out a list in toolchain.eclass :/
Comment 9 Manuel Lauss 2006-07-30 23:53:50 UTC
Hm, would it be easier to convince the gcc folks to automatically build
a multilib enabled gcc (like gcc-3)?
Comment 10 SpanKY gentoo-dev 2006-09-02 01:21:04 UTC
*** Bug 145850 has been marked as a duplicate of this bug. ***
Comment 11 Manuel Lauss 2006-09-08 00:14:23 UTC
Created attachment 96366 [details, diff]
Crude hack to add multilib support to SuperH-GCC4 compilers

Here's a crude hack I use to create multilib-enabled GCC-4
for SuperH targets. It seems to DTRT wrt. e.g. sh4_nofpu-* and
gcc-3.
Comment 12 SpanKY gentoo-dev 2006-09-08 00:34:00 UTC
i chatted with some sh guys and i think it might be better to just change the config.gcc file to always do multilib with gcc-4.x the way gcc-3.x did it ... it adds very little buildtime/runtime overhead for this

after all, a raw sh4 target cant even build a kernel ;x
Comment 13 SpanKY gentoo-dev 2006-09-13 23:29:24 UTC
Created attachment 96935 [details, diff]
gcc4-sh-multilib.patch

try this please
Comment 14 Manuel Lauss 2006-09-14 23:50:50 UTC
Thank you!
Works just like GCC-3 now.
(and compiled kernels still don't boot ;) )
Comment 15 SpanKY gentoo-dev 2006-09-16 20:58:51 UTC
only thing i can think of before i add this ...

with this patch, the default multilib for sh[1234] is all the sh[1234] targets ... would it be better to have the default multilib be all the sh targets for the specified cpu ?

so default sh1 would be all the sh1 variants ... default sh2 would be all the sh2 variants, etc...

what do you think ?
Comment 16 Manuel Lauss 2006-09-17 06:34:55 UTC
I say don't bother. What would be gained by that? libgcc size isn't that big a deal (at least for me). I hope someone else can comment on that too.
Comment 17 SpanKY gentoo-dev 2006-09-17 12:28:42 UTC
i was on the fence one way or the other

ive committed the proposed patch here and it'll be in 4.1.1-r2 ... thanks for testing