OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Sep 07, 2010 3:16 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 12:06 am 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
Transferring this from the Wiki discussion page...

GCC 4.5.0 introduces a new dependency, the MPC library, which isn't covered by the tutorial yet. But that isn't my problem.

It seems that the tutorial only works when you use /usr/local as the prefix.

During the configure step for GCC, you state --with-gmp=..., --with-mpfr=... and --with-mpc=..., which allows the build process to find the headers and linker libraries. Unfortunately the search path for the libraries does not get coded into the resulting executables:

Code:
/usr/src/build-gcc/gcc $ ldd cc1
   linux-gate.so.1 =>  (0xb804e000)
   libmpc.so.2 => not found
   libmpfr.so.1 => /usr/lib/libmpfr.so.1 (0xb7fed000)
   libgmp.so.10 => not found
   libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7fe8000)
   libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e85000)
   libgmp.so.3 => /usr/lib/libgmp.so.3 (0xb7e3e000)
   /lib/ld-linux.so.2 (0xb804f000)


Not only does cc1 not find the libmpc.so.2 despite being told it resides in /usr/cross/lib during the configure, it also links the system-provided gmp / mpfr libraries in /usr/lib despite being told to use those in /usr/cross/lib.

I really despise this kind of autoconfig stupidity.

I don't like mixing manually-installed libraries with the code under control of my system package manager, and anyway by using $PREFIX our tutorial gives the impression of being independent of the actual location binaries are installed to - which obviously it is not.

And editing /etc/ld.so.conf isn't an option for people who are working as non-root on shared systems.

I'd really like to file this as a bug in GCC / Autoconfig, but I know what the answer would be.

How do we handle this in the tutorial? Hardcode /usr/local and scrap $PREFIX, recommend editing /etc/ld.so.conf (which would be tricky since distros differ in this regard), or something else? (Please nobody recommend setting LD_LIBRARY_PATH, that's evil.)


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 12:14 am 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
Personally, I'd suggest scrapping the "installing from source" part for GMP, MPFR and MPC (which aren't cross-compile specific anyway), and instead recommend installing the appropriate packages (e.g. libmpc-devel) through the respective system package manager. That way, cross-binutils and cross-GCC can be installed anywhere you like, and you don't even have to state --with-gmp etc. during config.


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 12:24 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 869
Location: Hobart, Australia
I totally agree with you. It seems the best solution for everybody (including, even, the people using cygwin). It's mentioned deep in the bowels of the wiki, but the only requisite package you need for Debian is 'libmpfr-dev'. It'll install everything else as a dependency.

_________________
My Blog


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 12:28 am 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
Hmmm... I just tried my own suggestion, and it doesn't work.

GCC requires mpc 0.8.0+, and e.g. my Linux Mint installs v 0.5.2...

Damn. I wouldn't want to start explaining people how to use unstable / testing repositories for their respective distros...


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 12:36 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 869
Location: Hobart, Australia
Isn't being able to use your current operating system a prerequisite for starting off in OSDev?

_________________
My Blog


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 1:24 am 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
Yep. I should retire from the field - the reason for my libmpc being outdated is that I'm still using Mint v7.0 when v9.0 is bound for release this month. :P

So ignore my last post. Using the system package manager is the way to go.


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 2:26 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 4909
Location: Staphorst, The Netherlands
I'd still file the bug for the sake of it. If they do tell us "that's a feature, not a bug" we have a legit excuse to call them names.

Maybe I should try how well llvm suits as a drop-in replacement for gcc.

_________________
"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrash
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 2:54 am 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
Combuster wrote:
I'd still file the bug for the sake of it.


Have fun. I got bitten by this in several projects already. It's a commen occurence in Autoconfig projects, dragging in system libraries even when being told to use different ones. It's a ***** when you want to compile for a production system using a specific version of e.g. Boost, but the Autoconfig keeps dragging in your *system* Boost, which is a completely different version...


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 9:01 am 
Online
Member
Member

Joined: Wed Oct 18, 2006 10:43 pm
Posts: 415
Location: Kansas City, KS, USA
Solar wrote:
Personally, I'd suggest scrapping the "installing from source" part for GMP, MPFR and MPC (which aren't cross-compile specific anyway), and instead recommend installing the appropriate packages (e.g. libmpc-devel) through the respective system package manager. That way, cross-binutils and cross-GCC can be installed anywhere you like, and you don't even have to state --with-gmp etc. during config.


I'll second that. If anyone really wants to install those from source, all they have to do is unpack the GMP source to gmp/ inside the GCC source tree. Also unpack MPFR to mpfr/, and MPC to mpc/. Then GCC will compile and use the ones in the source tree instead. Supposedly anyway, I haven't tested it, but the docs say it should work.

Personally I just use my package manager to install those libraries and allow the cross compiler to link against them.


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 11:30 pm 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
Putting the gmp / mpfr / mpc directories into the GCC source tree indeed works. However, the build insists on configuring libstdc++-v3, which bails out with "error: Link tests are not allowed after GCC_NO_EXECUTABLES"...

That's not only GCC 4.5.0, GCC 4.4.4 does the same.

Strange. Suddenly it's me who can't build a cross-compiler while everybody else says things are fine. #-o


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Thu May 06, 2010 11:39 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2434
Location: Rockhampton, Australia (I come from a land down under!)
libstdc++-v3 will only be compiled if you didn't use only "make all-gcc && make install-gcc", which the tutorial says to do.

Unless of course 4.5.0 has libstdc++-v3 included in the all-gcc target now, which would be silly.

_________________
Pedigree | My Pedigree dev blog
Working on: Graphics framework


Top
 Profile  
 
 Post subject: Re: GCC 4.5.0 and the cross-compiler tutorial
PostPosted: Fri May 07, 2010 12:28 am 
Offline
Member
Member

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 5445
Location: Germany
/facepalm

all-gcc...

#-o


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group