New IT forum
26 June 2022, 04:28:24 pm *
Welcome, %1$s. Please login or register.

: MiraBox now in stock.
 
Pages: [1]

Author Topic: How to build a native C compiler?  (Read 7557 times)

David James

  • Newbie
  • *
  • Posts: 7
How to build a native C compiler?
« on: 07 September 2010, 08:46:04 pm »

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:

[email protected]:~$ 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-essentials (which identifies itself as
[email protected]:~# 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

Confusticated

  • New IT customer
  • Hero Member
  • *
  • Posts: 663
Re: How to build a native C compiler?
« Reply #1 on: 07 August 2011, 08:21:44 pm »

I don't have a sheevaplug, never compiled gcc on a plug........
Applications often require specific patches to compile on ARM, depending on where the source for gcc came from, you may need to patch it.
Check out OpenWRT, they not only support building kernels & root filesestems, but also the 'build tools' to make them like gcc.
First lets try and nail down the problem.

Quote
/usr/src/gcc/b3/gcc/xgcc

This binary is being executed from within the source tree (which is unusual).
If it has not been statically linked it may be having issues locating dependant libraries.
Lets determine if this is or is not an issue.

You will need to obtain 'ldd' from somewhere, if it is not already installed.

Code: [Select]
ldd /usr/src/gcc/b3/gcc/xgcc
Will examine xgcc and list dynamic libraries it is dependant on and the path to them if they can be found.
Post your findings and we will take it from there.

EDIT:
If ldd isn't easily available similar information can be obtained with
Code: [Select]
/lib/ld-2.7.so --list /usr/src/gcc/b3/gcc/xgccnote your dynamic linker version number (/lib/ld-?.?.so) may be different.
« Last Edit: 07 August 2011, 10:57:36 pm by Confusticated »
Logged
Advocatus Diaboli - My agenda is not to give you the answer, but to guide your thoughts so you derive it for yourself!
Pages: [1]
 
 

Powered by MySQL Powered by PHP SMF 2.0.10 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!