Bug 6944 - building toolchain for sh4 fails
Summary: building toolchain for sh4 fails
Status: RESOLVED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: PC Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-03 00:07 UTC by George
Modified: 2015-06-03 01:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
config file for sh4 toolchain build (32.45 KB, application/octet-stream)
2014-03-03 00:07 UTC, George
Details
Fix the toolchain build for the SuperH architecture. (1.89 KB, patch)
2014-03-04 13:00 UTC, George
Details

Note You need to log in before you can comment on or make changes to this bug.
Description George 2014-03-03 00:07:00 UTC
Hello support,

I'm trying to build a toolchain for Renesas SH4.

The process fails at the end with the following log:

make[3]: Leaving directory `/home/g/toolchain/output/build/host-gcc-final-4.7.3/build/gcc'
make[2]: Leaving directory `/home/g/toolchain/output/build/host-gcc-final-4.7.3/build'
make[1]: Leaving directory `/home/g/toolchain/output/build/host-gcc-final-4.7.3/build'
if [ ! -e /home/g/toolchain/output/host/usr/bin/sh4-buildroot-linux-gnu-cc ]; then ln -snf sh4-buildroot-linux-gnu-gcc /home/g/toolchain/output/host/usr/bin/sh4-buildroot-linux-gnu-cc; fi
if [ ! -e /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/bin/cc ]; then ln -snf gcc /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/bin/cc; fi
(cd /home/g/toolchain/output/host/usr/bin; for i in sh4-buildroot-linux-gnu-*; do ln -snf $i sh4-linux${i##sh4-buildroot-linux-gnu}; done)
cp -dpf /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libgcc_s* /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/sysroot/lib/
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libgcc_s*’: No such file or directory
make: [/home/g/toolchain/output/build/host-gcc-final-4.7.3/.stamp_host_installed] Error 1 (ignored)
cp -dpf /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libgcc_s* /home/g/toolchain/output/target/lib/
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libgcc_s*’: No such file or directory
make: [/home/g/toolchain/output/build/host-gcc-final-4.7.3/.stamp_host_installed] Error 1 (ignored)
mkdir -p /home/g/toolchain/output/target/usr/lib
for i in  libstdc++ libmudflapth ; do cp -dpf /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/${i}.so* /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/sysroot/usr/lib/ ; cp -dpf /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/${i}.a /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/sysroot/usr/lib/ ; cp -dpf /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/${i}.so* /home/g/toolchain/output/target/usr/lib/ ; done
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libstdc++.so*’: No such file or directory
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libstdc++.a’: No such file or directory
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libstdc++.so*’: No such file or directory
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libmudflapth.so*’: No such file or directory
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libmudflapth.a’: No such file or directory
cp: cannot stat ‘/home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*/libmudflapth.so*’: No such file or directory
make: *** [/home/g/toolchain/output/build/host-gcc-final-4.7.3/.stamp_host_installed] Error 1
g@g-ThinkPad-X220:~/toolchain/buildroot$ 




I'm using the SHA 5970e883419a55f25ea900d776287ae6ea34b62e from the buildroot git repo.

The build tries to copy everything that's under /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*

Under that, I have only one folder named !m4



ls -la /home/g/toolchain/output/host/usr/sh4-buildroot-linux-gnu/lib*
total 12
drwxr-xr-x 3 g g 4096 Mar  2 14:16 .
drwxr-xr-x 6 g g 4096 Mar  2 14:23 ..
drwxr-xr-x 2 g g 4096 Mar  2 18:56 !m4


I guess the ! sign confuses the copy command.

I started the build with this command:  make O=../output toolchain

Attached is my config file.

Am I doing something wrong?



Cheers
George
Comment 1 George 2014-03-03 00:07:58 UTC
Created attachment 5264 [details]
config file for sh4 toolchain build
Comment 2 Thomas Petazzoni 2014-03-03 07:52:07 UTC
Aah, glad to see we have a SuperH user!

This problem is well-known (at least to me). The issue is that gcc for SH4 insists on being multilib, to all the libraries are not directly in the sysroot but in some directory named "!m4" if I remember correctly. This confuses the Buildroot toolchain logic, which assumes the toolchain is not multilib.

Moreover, the other problem we have with SH4 is that to be able a kernel, you really need to have the m4-nofpu multilib variant, in addition to the m4 one. This is why configs/qemu_sh4_r2d_defconfig has this special configuration option:

BR2_EXTRA_GCC_CONFIG_OPTIONS="--with-multilib-list=m4,m4-nofpu"

At this point, I must say I am not sure how this problem should be fixed exactly.

Do you have some good knowledge of the SuperH architecture variants? That would be very helpful: we lack some contributors using SuperH and having some minimal knowledge of the architecture.
Comment 3 George 2014-03-04 13:00:59 UTC
Created attachment 5270 [details]
Fix the toolchain build for the SuperH architecture.
Comment 4 George 2014-03-04 13:02:09 UTC
Hi,

I've attached a small patch that fixes the toolchain build for the SuperH architecture.

Could you take a look at it and if it's ok, add it into the git repo?


Cheers
George

(In reply to comment #3)
> Created attachment 5270 [details]
> Fix the toolchain build for the SuperH architecture.
Comment 5 Thomas Petazzoni 2014-03-04 19:57:20 UTC
Thanks for the patch!

However, I am not sure it will work correctly in all cases. It works in your case because only one multilib variant gets built, and installed in the !m4 directory. But if you have BR2_EXTRA_GCC_CONFIG_OPTIONS="--with-multilib-list=m4,m4-nofpu", then two multilib variants will be built, and you will have two directories, not one.

Could you check this case?

It's also a bit annoying that on SuperH, specifying a custom gcc option is needed to even be able to build a kernel. Do you know if there's something that can be done about it?
Comment 6 Thomas De Schampheleire 2014-04-24 20:03:09 UTC
Hi George,

Did you already find some time to look into this further?

Thanks a lot,
ThomasDS
Comment 7 George 2014-04-26 21:55:13 UTC
Hi Thomas,

with my little patch, I was able to have a toolchain capable of building the whole rootfs for my board.

I did not use the BR2_EXTRA_GCC_CONFIG_OPTIONS, and to be honest, I don't understand why I'd need those.

I don't know what else to say. It works in my case, but I don't know if there are other cases that might not work.


Cheers
George

(In reply to comment #6)
> Hi George,
> 
> Did you already find some time to look into this further?
> 
> Thanks a lot,
> ThomasDS
Comment 8 Thomas Petazzoni 2014-04-29 05:21:57 UTC
Did you try building an SH4 Linux kernel with the generated toolchain?
Comment 9 George 2014-05-02 17:22:26 UTC
Yes, I was able to build using the default defconfig for ecovec24.
I had to modify the ./arch/sh/Makefile in that kernel by removing the -m4-nofpu for sh4.


cflags-$(CONFIG_CPU_SH4)        := $(call cc-option,-m4,) \
    $(call cc-option,-mno-implicit-fp)
Comment 10 Thomas Petazzoni 2014-05-17 08:57:43 UTC
(In reply to comment #9)
> Yes, I was able to build using the default defconfig for ecovec24.
> I had to modify the ./arch/sh/Makefile in that kernel by removing the -m4-nofpu
> for sh4.
> 
> 
> cflags-$(CONFIG_CPU_SH4)        := $(call cc-option,-m4,) \
>     $(call cc-option,-mno-implicit-fp)

Hum, right, but we don't want people to be forced to modify the kernel Makefiles in order to be able to build a SH4 kernel with a Buildroot toolchain. That isn't really nice, right?
Comment 11 mail 2014-09-09 17:01:53 UTC
Hi,

I don't think removing m4-nofpu is the right thing to create a good kernel.
As gcc does not include support for -mno-implicit-fp, there is no way around using
a multilib gcc to compile a kernel without floating point instructions.

See here for an interesting thread:
http://sourceforge.net/p/linuxsh/mailman/linuxsh-dev/thread/3B732B78.28B8BF39@pocketpenguins.com/

It seems Codesourcery has some gcc patches included to support -mno-implicit-fp.
But the gcc people have rejected it. 

best regards
 Waldemar