sh4 Linux cross-toolchain (by Code Sourcery)
1) Pre-build sh-linux-gcc toolchain :
Download Sourcery G++ Lite 4.4-45 for SuperH GNU/Linux from :
http://www.codesourcery.com/sgpp/lite/superh/portal/release1041
choose : IA32 GNU/Linux Installer
2) Install toolchain to Linux host :
$ /bin/sh renesas-4.4-45-sh-linux-gnu.bin
Will lounch graphical installer which will install toolchain to :
~/CodeSourcery/
3) Compile hello.c :
$ ~/CodeSourcery/Sourcery_G++_Lite/bin/sh-linux-gnu-gcc -o hello hello.c
This will already search libraries to pre-destined paths :
drasko@Marx:~/sh4_projects$ ~/CodeSourcery/Sourcery_G++_Lite/bin/sh-linux-gnu-gcc -v -o hello hello.c
Using built-in specs.
Target: sh-linux-gnu
Configured with: /scratch/ams/4.4-sh-linux-gnu-lite/src/gcc-4.4/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=sh-linux-gnu --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-cpu=sh4a --with-multilib-list=sh4al,!mb/m4al --with-endian=little,big --enable-extra-sgxxlite-multilibs --enable-incomplete-targets --with-gnu-as --with-gnu-ld --with-specs='%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --disable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 4.4-45' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/sh-linux-gnu/libc --with-build-sysroot=/scratch/ams/4.4-sh-linux-gnu-lite/install/sh-linux-gnu/libc --with-gmp=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --with-mpfr=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --with-ppl=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/ams/4.4-sh-linux-gnu-lite/install/sh-linux-gnu/bin --with-build-time-tools=/scratch/ams/4.4-sh-linux-gnu-lite/install/sh-linux-gnu/bin
Thread model: posix
gcc version 4.4.1 (Sourcery G++ Lite 4.4-45)
COLLECT_GCC_OPTIONS='-v' '-o' 'hello'
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/sh-linux-gnu/4.4.1/cc1 -quiet -v -iprefix /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/ -isysroot /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc hello.c -quiet -dumpbase hello.c -auxbase hello -version -o /tmp/ccTmWWcy.s
ignoring nonexistent directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/local/include"
ignoring duplicate directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/../../lib/gcc/sh-linux-gnu/4.4.1/include"
ignoring duplicate directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/../../lib/gcc/sh-linux-gnu/4.4.1/include-fixed"
ignoring duplicate directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/../../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/include
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/include-fixed
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/include
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/include
End of search list.
GNU C (Sourcery G++ Lite 4.4-45) version 4.4.1 (sh-linux-gnu)
compiled by GNU C version 4.3.2, GMP version 4.3.1, MPFR version 2.4.1-p5.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6d45046fc0139f32061c226770713dae
COLLECT_GCC_OPTIONS='-v' '-o' 'hello'
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/bin/as -v -little -o /tmp/ccGtcr9X.o /tmp/ccTmWWcy.s
GNU assembler version 2.19.51 (sh-linux-gnu) using BFD version (Sourcery G++ Lite 4.4-45) 2.19.51.20090709
COMPILER_PATH=/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/sh-linux-gnu/4.4.1/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/bin/
LIBRARY_PATH=/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/lib/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/lib/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello'
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/sh-linux-gnu/4.4.1/collect2 --sysroot=/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc --eh-frame-hdr -m shlelf_linux -dynamic-linker /lib/ld-linux.so.2 -o hello /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/crt1.o /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/crti.o /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/crtbegin.o -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1 -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/lib -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/lib -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib /tmp/ccGtcr9X.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/crtend.o /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/crtn.o
drasko@Marx:~/sh4_projects$
4) Lounch quemu test :
drasko@Marx:~/sh4_projects$ qemu-sh4 -L ~/CodeSourcery/Sourcery_G++_Lite/sh-linux-gnu/libc/ ./hello
Hello from SH4
drasko@Marx:~/sh4_projects$
Download Sourcery G++ Lite 4.4-45 for SuperH GNU/Linux from :
http://www.codesourcery.com/sgpp/lite/superh/portal/release1041
choose : IA32 GNU/Linux Installer
2) Install toolchain to Linux host :
$ /bin/sh renesas-4.4-45-sh-linux-gnu.bin
Will lounch graphical installer which will install toolchain to :
~/CodeSourcery/
3) Compile hello.c :
$ ~/CodeSourcery/Sourcery_G++_Lite/bin/sh-linux-gnu-gcc -o hello hello.c
This will already search libraries to pre-destined paths :
drasko@Marx:~/sh4_projects$ ~/CodeSourcery/Sourcery_G++_Lite/bin/sh-linux-gnu-gcc -v -o hello hello.c
Using built-in specs.
Target: sh-linux-gnu
Configured with: /scratch/ams/4.4-sh-linux-gnu-lite/src/gcc-4.4/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=sh-linux-gnu --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-cpu=sh4a --with-multilib-list=sh4al,!mb/m4al --with-endian=little,big --enable-extra-sgxxlite-multilibs --enable-incomplete-targets --with-gnu-as --with-gnu-ld --with-specs='%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --disable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 4.4-45' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/sh-linux-gnu/libc --with-build-sysroot=/scratch/ams/4.4-sh-linux-gnu-lite/install/sh-linux-gnu/libc --with-gmp=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --with-mpfr=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --with-ppl=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/ams/4.4-sh-linux-gnu-lite/obj/host-libs-4.4-45-sh-linux-gnu-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/ams/4.4-sh-linux-gnu-lite/install/sh-linux-gnu/bin --with-build-time-tools=/scratch/ams/4.4-sh-linux-gnu-lite/install/sh-linux-gnu/bin
Thread model: posix
gcc version 4.4.1 (Sourcery G++ Lite 4.4-45)
COLLECT_GCC_OPTIONS='-v' '-o' 'hello'
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/sh-linux-gnu/4.4.1/cc1 -quiet -v -iprefix /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/ -isysroot /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc hello.c -quiet -dumpbase hello.c -auxbase hello -version -o /tmp/ccTmWWcy.s
ignoring nonexistent directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/local/include"
ignoring duplicate directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/../../lib/gcc/sh-linux-gnu/4.4.1/include"
ignoring duplicate directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/../../lib/gcc/sh-linux-gnu/4.4.1/include-fixed"
ignoring duplicate directory "/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/../../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/include
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/include-fixed
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/include
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/include
End of search list.
GNU C (Sourcery G++ Lite 4.4-45) version 4.4.1 (sh-linux-gnu)
compiled by GNU C version 4.3.2, GMP version 4.3.1, MPFR version 2.4.1-p5.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6d45046fc0139f32061c226770713dae
COLLECT_GCC_OPTIONS='-v' '-o' 'hello'
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/bin/as -v -little -o /tmp/ccGtcr9X.o /tmp/ccTmWWcy.s
GNU assembler version 2.19.51 (sh-linux-gnu) using BFD version (Sourcery G++ Lite 4.4-45) 2.19.51.20090709
COMPILER_PATH=/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/sh-linux-gnu/4.4.1/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/bin/
LIBRARY_PATH=/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/lib/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/lib/:/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello'
/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../libexec/gcc/sh-linux-gnu/4.4.1/collect2 --sysroot=/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc --eh-frame-hdr -m shlelf_linux -dynamic-linker /lib/ld-linux.so.2 -o hello /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/crt1.o /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/crti.o /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/crtbegin.o -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1 -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/../../../../sh-linux-gnu/lib -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/lib -L/home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib /tmp/ccGtcr9X.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/sh-linux-gnu/4.4.1/crtend.o /home/drasko/CodeSourcery/Sourcery_G++_Lite/bin/../sh-linux-gnu/libc/usr/lib/crtn.o
drasko@Marx:~/sh4_projects$
4) Lounch quemu test :
drasko@Marx:~/sh4_projects$ qemu-sh4 -L ~/CodeSourcery/Sourcery_G++_Lite/sh-linux-gnu/libc/ ./hello
Hello from SH4
drasko@Marx:~/sh4_projects$