• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: How to build a native C compiler on a SheevaPlug?  (Read 1971 times)
DavidJames
Newbie
*

Karma: 0
Posts: 2


View Profile
« on: September 10, 2010, 10:35:31 AM »

I have my SheevaPlug booting Ubuntu 9.04 from an eSATA disk, so I have lots of disk space and I'm not worried about possibly wearing out internal flash or an SD card ...

I'm trying to compile (natively) version 3.4.6 of the GCC C compiler. I know it's old, but I need it so that I can build a version of GPC (the GNU Pascal compiler) which exactly matches the version I am running on i86-based Linux boxes (GPC 20070904 based on GCC-3.4.6).


I've tried using the GPC version that I get with apt-get install GPC.

It identifies itself as:

david@ubuntu:~$ gpc -v
Using built-in specs.
Configured with: ../src/configure -v --enable-languages=c,pascal --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --disable-libmudflap --disable-libssp --enable-checking=release arm-linux-gnueabi
Thread model: posix
gpc version 20070904, based on gcc-4.1.3 20080420 (prerelease) (Ubuntu 2.1-4.1.2-22ubuntu1)

However when I build my application using that compiler I see various quirks. I'd like to get to a compiler that should be exactly the same as the one I'm using on the i86-based Linux boxes to rule out compiler differences as the source of the problems I'm seeing.



I'm failing dismally to build the GCC C compiler ...


After a lot of Googling, I eventually settled on a set of arguments to configure.

The arguments I have used are: --prefix=/usr/local/gcc-3.4.6 --enable-languages=c --with-float=soft --disable-libssp --with-arch=armv5te --enable-shared --with-system-zlib --without-included-gettext --enable-threads=posix --enable-nls --enable-__cxa_atexit --enable-clocale=gnu --disable-libmudflap --disable-libgomp

I'm also adding '-marm -msoft-float -march=armv5te -Wl,marmelf_linux_eabi' to the CFLAGS in the generated Makefile (and to the calls to xgcc) and I'm adding -marmelf_linux_eabi to LD_FLAGS and to any explicit calls to the linker.


I'm using the version of the C compiler that is installed by apt-get build-essential or possibly by apt-get install gcc, I'm not sure which now. It identifies itself as
root@ubuntu:~# gcc -v
Using built-in specs.
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --disable-libssp --disable-sjlj-exceptions --with-arch=armv5t --with-tune=cortex-a8 --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)

The brick wall I've finally hit is:
/usr/src/gcc/b3/gcc/xgcc: /usr/src/gcc/b3/gcc/libgcc_s.so.1: version `GCC_3.5' not found (required by /usr/src/gcc/b3/gcc/xgcc)



Can anyone suggest suitable arguments for configure to build version 3.4.6 of the GCC C compiler, any patches, or changes to the generated Makefile, or anything else I'm missing?
Logged

cjm
Jr. Member
**

Karma: 6
Posts: 69


View Profile
« Reply #1 on: September 10, 2010, 11:58:19 AM »

I don't have finished configure arguments for you but maybe some pointers. I believe it's odd that it would try to find a label indicating gcc 3.5 while you're trying to compile 3.4.6. Maybe some bits of the toolchain are taken from the Ubuntu compiler, some from the one you're trying to compile. How far does the compile process get?

Another thing you may want to try is to find a source package for gcc 3.4.6 in the Ubuntu archives and check the configure arguments in there (.../debian/rules). You'll probably have to change some of the flags, most likely the ARM/ABI-related flags, but it would be a starting point.

BTW, Debian Lenny has a package for 3.4.6 (source and binary):

http://packages.debian.org/lenny/gcc-3.4

Thanks,
--Christian
Logged

DavidJames
Newbie
*

Karma: 0
Posts: 2


View Profile
« Reply #2 on: September 10, 2010, 04:29:53 PM »

Thank you. Those sound like useful suggestions.

I've now switched to Debian squeeze and am seeing if I get any further with that.

I'm new to Debian and Ubuntu (coming from RedHat and Fedora) so apt-get is a bit of a mystery to me ... is it simple to grab the Debian Lenny packages you have pointed to and install them into Debian Squeeze?
Logged

cjm
Jr. Member
**

Karma: 6
Posts: 69


View Profile
« Reply #3 on: September 11, 2010, 10:46:36 AM »

I wouldn't try and install binary Lenny packes in Squeeze because the dependencies may be all screwed up. But compiling a source package with apt-get and dpkg-buildpackage is so simple that it surprises me every time. In your case:

  • add the Lenny sources to /etc/apt/sources.list:
    deb-src http://mirrors.kernel.org/debian/ lenny main contrib non-free
  • run "apt-get update" or "aptitude update" to update the cache with available packages and sources
  • run "apt-cache showsrc gcc-3.4"
  • find the entry with the correct gcc version if there are multiple. In my case, there was only 3.4.6ds1-9 but there might be a slightly newer one as I didn't run "aptitude update" for a few weeks
  • create an empty directory for the build and change into it
  • run "apt-get source gcc-3.4" in the build directory; if you need to pick a specific version, add the version number to the package like so: "apt-get source gcc-3.4=3.4.6ds1"
  • change into the source directory (gcc-3.4-3.4.6ds1 in my case)
  • run "dpkg-buildpackage -rfakeroot" to build the compiler
  • once the build has completed successfully, you'll find binary package files to install with "dpkg -i" in the parent directory (the one above the source directory)

You may have to change configure options (e.g. to select the proper ABI) or hack the dependencies section if there are dependencies to older packages -- things should work with the versions provided by Squeeze because you recompile using those packages. Configure options can be changed in debian/rules and dependencies hacked in debian/control.

If you miss packages for the build, run "apt-get build-dep gcc-3.4" to have them automatically resolved (as far as they can be resolved with Squeeze packages). Again, if Squeeze only offers newer versions of packages needed at build time, I would install those newer packages, manually if necessary, and hack the debian/control file.

Last but not least, if you have to build again and again to get things resolved, you can add the option "-nc" (no clean) to the dpkg-buildpackage command to avoid having to start from scratch all the time.

Hope this helps (and works),
--Christian
Logged

Pages: [1]
Print
Jump to: