LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-16-2011, 08:38 PM   #1
entz
Member
 
Registered: Mar 2007
Location: Milky Way , Planet Earth!
Distribution: Opensuse
Posts: 453
Blog Entries: 3

Rep: Reputation: 40
trouble with making a relocatable gcc package


HI,

i'm compiling gcc 4.5.2 and then packaging it using rpm.

many packages automatically assume the path specified by --prefix= to be the final path of course this is wrong because , at first it will go into BUILDROOT then it will be packaged then relocated ....etc (i'm assuming you're familiar with the procedure)

the problem is , when i compile gcc it produces working binaries however the default search path (i.e gcc --print-search-dirs) is messed up (due to the issue described above)

so far i've searched everything and tried all possible things that i could think of but to no avail.

how can i set configure to install the software into $RPM_BUILD_ROOT/usr will forcing the autoconf scripts to hardwire a different path (i.e /usr/) ??

NOTE: please don't refer me to LFS or something similar because 1) i'm already familiar with LFS 2) this isn't about building a toolchain (i've built it already) but rather about how to package and relocate it properly without breaking it !

cheers

Last edited by entz; 12-16-2011 at 08:48 PM.
 
Old 12-17-2011, 03:28 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
The usual thing is:
Build with sane options. When you're installing, use a line like

make DESTDIR=/my/package/dir install.If you build a gcc package for one dir, I don't think you will successfully locate it elsewhere without real effort. Better build 2 packages for that. I would also not use gcc through rpm.You only stand to lose your choice of options..
 
1 members found this post helpful.
Old 12-17-2011, 06:45 AM   #3
entz
Member
 
Registered: Mar 2007
Location: Milky Way , Planet Earth!
Distribution: Opensuse
Posts: 453

Original Poster
Blog Entries: 3

Rep: Reputation: 40
Quote:
Originally Posted by business_kid View Post
The usual thing is:
Build with sane options. When you're installing, use a line like

make DESTDIR=/my/package/dir install.If you build a gcc package for one dir, I don't think you will successfully locate it elsewhere without real effort. Better build 2 packages for that. I would also not use gcc through rpm.You only stand to lose your choice of options..
hi , thanks for coming by

i've tried DESTDIR right away after my last post , which successfully placed the gcc files into the desired dir and therefore removed BUILDROOT from the search-paths , however i'm still facing problems .....

what do you mean that i lose my choices with rpm and gcc ? how exactly am i supposed to package it then?
also please elaborate on "building 2 packages" as you mentioned it in your post.

actually i'm intending to build gcc to be used inside a chroot environment in order to do a second build (along with some other tools)

so when i run "gcc --print-search-dirs" (inside the chroot)
i get the following output
Code:
install: ../lib64/gcc/x86_64-niteco-linux/4.5.2/
programs: =../lib64/gcc/x86_64-niteco-linux/4.5.2/:../lib64/gcc/:../lib64/../x86_64-niteco-linux/bin/x86_64-niteco-linux/4.5.2/:../lib64/../x86_64-niteco-linux/bin/
libraries: =../lib64/gcc/x86_64-niteco-linux/4.5.2/:../lib64/gcc/:../lib64/../x86_64-niteco-linux/lib/x86_64-niteco-linux/4.5.2/:../lib64/../x86_64-niteco-linux/lib/../lib64/:../lib64/x86_64-niteco-linux/4.5.2/:../lib64/../lib64/:/usr/lib64/gcc/x86_64-niteco-linux/4.5.2/../../../x86_64-niteco-linux/4.5.2/:/usr/lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../lib64/://lib/x86_64-niteco-linux/4.5.2/://lib/../lib64/://usr/lib/x86_64-niteco-linux/4.5.2/://usr/lib/../lib64/:../lib64/../x86_64-niteco-linux/lib/:../lib64/:/usr/lib64/gcc/x86_64-niteco-linux/4.5.2/../../../://lib/://usr/lib/
why the hell are those paths relative ???
this is insane ! how hard is to fix the "install" path for instance to the same path provided to "prefix" during the build which is "/usr" ??

EDIT:
outside the chroot i get this crap
Code:
# /linux/test/usr/bin/gcc --print-search-dirs
install: /linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/
programs: =/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/:/linux/test/usr/bin/../lib64/gcc/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../x86_64-niteco-linux/bin/x86_64-niteco-linux/4.5.2/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../x86_64-niteco-linux/bin/
libraries: =/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/:/linux/test/usr/bin/../lib64/gcc/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../x86_64-niteco-linux/lib/x86_64-niteco-linux/4.5.2/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../x86_64-niteco-linux/lib/../lib64/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../x86_64-niteco-linux/4.5.2/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../lib64/:/usr/lib64/gcc/../x86_64-niteco-linux/4.5.2/:/usr/lib64/gcc/../../lib64/://lib/x86_64-niteco-linux/4.5.2/://lib/../lib64/://usr/lib/x86_64-niteco-linux/4.5.2/://usr/lib/../lib64/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../../x86_64-niteco-linux/lib/:/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/../../../:/usr/lib64/gcc/../://lib/://usr/lib/
cheers

Last edited by entz; 12-17-2011 at 06:47 AM.
 
Old 12-17-2011, 02:01 PM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
You have an absolute path there you know.

/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/ =
/linux/test/usr/lib64/gcc/x86_64-niteco-linux/4.5.2/

The trouble with gcc is that it spreads directories like confetti at a wedding for reasons I never understood. I imagine the ones in chroot should be similar(/usr/bin/back-out-of-bin/lib64<blah>), but not all bits might be in the same place in chroot?

When I was doing LFS, they had a separate install of gcc-2.95.3 on /opt. You must feed it
./configure --prefix=/opt/gcc-2.95.3 --with-bindir=/opt/gcc-2.95.3 etc. and even tell it that the jacks in /opt/gcc-2.95.3 :-P. If you configure for /usr, and install in /opt, you will have a non functional gcc, and some of that stuff is hard coded in. There is no user config file.

If you want a handy package system, check out slackware which uses a few scripts with no real dependency tracking. LFS also have some thing which you put between the make and install on the command line. RPM is headaches. RPM lacks a --middle-finger option which it sorely needs.

Last edited by business_kid; 12-17-2011 at 02:03 PM.
 
1 members found this post helpful.
Old 12-18-2011, 07:59 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
A "one folder gcc" like the /opt/gcc-2.95.3/ mentioned by business_kid,
can to some extend work when moved to another folder.
(And is very easy to tar, bzip2 to a package that can be unpacked anywhere :
gcc452-x86_64.tar.bz2 , where the parent folder is gcc452/ ).
Must be created by the LFS method
http://www.linuxquestions.org/questi...-1-a-842567/#2
( Configured like ../gcc-4.5.2/configure --prefix=/opt/gcc452/ , etc.)

( "--prefix=/usr/" is worst choice. May also overwrite some files
from the system compiler.)

But why not always use the same folder for your chroot environment,
and simply do '../gcc-4.5.2/configure --prefix=/linux/test/ etc.',
or ../gcc-4.5.2/configure --prefix=/linux/test/gcc452/ etc.,
then all issues are avoided.
( The binaries gcc, g++ can be symlinked to your prefered bin/ directory.)

..

Last edited by knudfl; 12-18-2011 at 08:13 AM.
 
Old 12-19-2011, 01:33 PM   #6
entz
Member
 
Registered: Mar 2007
Location: Milky Way , Planet Earth!
Distribution: Opensuse
Posts: 453

Original Poster
Blog Entries: 3

Rep: Reputation: 40
THIS IS GONNA BE A LOOOOOOOOOOOONG POST , bear with me

Quote:
Originally Posted by business_kid View Post
You have an absolute path there you know.

/linux/test/usr/bin/../lib64/gcc/x86_64-niteco-linux/4.5.2/ =
/linux/test/usr/lib64/gcc/x86_64-niteco-linux/4.5.2/
This is ONLY the case on a normal unchrooted shell

Quote:
Originally Posted by business_kid View Post
The trouble with gcc is that it spreads directories like confetti at a wedding for reasons I never understood.
well the confetti install is mostly due the FHS standard as far as i understand it , but to be honest that's not the problem and i don't care where the package throws it's stuff because rpm does an excellent job managing all the spread confetti giving that i can specify the sub root dir with --prefix or similar ...etc

Quote:
Originally Posted by business_kid View Post
I imagine the ones in chroot should be similar(/usr/bin/back-out-of-bin/lib64<blah>), but not all bits might be in the same place in chroot?
No , in the chroot i'm getting (../lib64/gcc<blah>) and it causes problems with finding compiler binaries ...etc

Quote:
Originally Posted by business_kid View Post
you will have a non functional gcc, and some of that stuff is hard coded in. There is no user config file.
yes i dealt with the hardcoded stuff by using
Code:
make DESTDIR=/relocated/dir install
but i'm still dealing with the dynamic (and weird behavior) of generating relative paths that lead to broken libs and exec bins...etc

Quote:
Originally Posted by business_kid View Post
If you want a handy package system, check out slackware which uses a few scripts with no real dependency tracking. LFS also have some thing which you put between the make and install on the command line.
No Thanks , i do really appreciate a full blown package manager as opposed to the slack style ( yes for me dependency tracking is a prerequisite) and btw just wanted to point out that the "thing" you described that can be put between make and install is a utility which "redirects" all file operations to a given directory but according to LFS 6.8 it does have caveats and isn't reliable (from what i've gathered) so i'm not using it , besides most if not all packages that hardwire paths have extra features in "make install" that can redirect the installation out of the box without the need for unreliable third party stuff , and those who don't can be solved with running sed over their scripts (incase they aren't binaries)

Quote:
Originally Posted by business_kid View Post
RPM is headaches. RPM lacks a --middle-finger option which it sorely needs.
well despite that fact that i'm not considering dumping RPM , i'm all ears to know about the "--middle-finger" option!
what's that ?
please elaborate...

Quote:
Originally Posted by knudfl
But why not always use the same folder for your chroot environment,
and simply do '../gcc-4.5.2/configure --prefix=/linux/test/ etc.',
or ../gcc-4.5.2/configure --prefix=/linux/test/gcc452/ etc.,
then all issues are avoided.
because things are lil' more complicated , the chroot environment is just a means to an end and not the end itself!
the target is to build a fully chrootable and self-contained toolchain to use for building an entire distro from scratch(scratch as from ziltch , this is not an LFS reference).
the second reason is that the method has to be packaging friendly as opposed to the spaghetti way of lfs , slack or else.

that said , i've made some progress here in the meantime and i'd like to share some results:

i've found out that if you run the following on your distro
Code:
chroot /chrootable/shell /bin/env -i /bin/bash
and assuming that "/chrootable/shell" contains a fully working GNU toolchain then attempting to compile with gcc with give you the exact same trouble that i'm getting !! (i.e cc1 not found)

and even more interestingly "gcc --print-search-dirs" will produce relative paths as opposed to absolute ones outside the chroot!

the conclusion , is that all distros (at least the once i've examined opensuse 11.2 and CentOS ) are facing the same problem with gcc search-dirs , i've also find out that different distros deal with the problem by installing additional third-party scripts or executables that sort of "search" on behalf of gcc for it's own compiler binaries

for instance in CentOS , an application that i couldn't isolate so far located in /sbin (/sbin is the $PATH variable) is responsible for doing the job (i.e removing/adding /sbin to $PATH will either break or fix gcc)

on opensuse , a package called "openmpi" acts as a proxy for any gcc installation.

the first question is , why not just appending the compiler binaries path directly to $PATH?
to which the answer is : to allow multiple gcc's or even several gcc installations of the same version all of which have the same "--prefix" value , this way every gcc binary would have prior and independent knowledge of it's compiler binaries (cc1 , cc1plus ..) therefore avoiding collision of several gcc's .

the second (and open) question, what's the ideal way to solve this ?
in other words , what tools should we use to point gcc to it's compiler bins?

kind regards
 
Old 01-11-2012, 10:45 AM   #7
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Just a postscript to all of this:

try gcc -print-file specs

and it prints a file called specs buried in the depths of some tree where nobody would expect it. Have you tried hacking that??
 
Old 01-14-2012, 09:09 PM   #8
entz
Member
 
Registered: Mar 2007
Location: Milky Way , Planet Earth!
Distribution: Opensuse
Posts: 453

Original Poster
Blog Entries: 3

Rep: Reputation: 40
well just as a note , i've solved this problem since my last post , forgot to mark the thread as solved , my bad
 
Old 01-15-2012, 09:08 AM   #9
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Quote:
Originally Posted by business_kid View Post
Just a postscript to all of this:

try gcc -print-file specs

and it prints a file called specs buried in the depths of some tree where nobody would expect it. Have you tried hacking that??
It would be good to post HOW you solved the problem as people search these forums. Let others benefit from your experience
 
1 members found this post helpful.
Old 09-02-2012, 10:05 PM   #10
Ramune
LQ Newbie
 
Registered: Apr 2009
Posts: 4

Rep: Reputation: 0
I had the same problem... solution was to do 'export PATH' in bash; that made gcc paths become absolute instead of relative. Does anyone know why gcc's built-in paths would depend on the PATH environment variable?
 
Old 09-03-2012, 03:22 AM   #11
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
oops! Ignore this.

Last edited by business_kid; 09-03-2012 at 03:23 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of Memory when making GCC-4.5.2 BrandonJ Linux From Scratch 3 05-18-2011 08:13 PM
How to build httpd-2.2.3-22 as a relocatable rpm package in RHEL 5.3 renjunix Linux - Server 3 11-02-2009 09:04 AM
AIX relocatable package help vibhor_agarwalin AIX 0 05-06-2009 12:55 AM
question about making GCC-2.95.3 dylbit Linux - General 1 03-21-2006 03:43 AM
Making GCC Compile Executables? The Pentium Guy Debian 3 11-06-2004 09:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration