LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-08-2006, 02:51 AM   #1
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
how can I compile older versions of gcc?


I am trying to get the SDK for Symbian based mobile devices working and it requires a modded version of gcc called GCC-3.0-psion-98r2 located here. Now from what I have read, you need gcc to compile gcc, and to make it even more difficult, you need the same versions.

I build the objdir in a separate folder from the srcdir as outlined in the build documentation and ran from the objdir:
Code:
./../srcdir/configure --prefix=<build directory>
make bootstrap
But I get the following errors:
Code:
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
elf-init.oS(.text+0x1d): undefined reference to `__init_array_end'
elf-init.oS(.text+0x23): undefined reference to `__init_array_start'
elf-init.oS(.text+0x43): undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_fini':
elf-init.oS(.text+0x7a): undefined reference to `__fini_array_end'
elf-init.oS(.text+0x80): undefined reference to `__fini_array_start'
elf-init.oS(.text+0xa3): undefined reference to `__fini_array_start'
collect2: ld returned 1 exit status
make[2]: *** [gengenrtl] Error 1
make[2]: Leaving directory `/home/drkstr/pkg/builds/gcc-psion-3.0/gcc'
make[1]: *** [stage2_build] Error 2
make[1]: Leaving directory `/home/drkstr/pkg/builds/gcc-psion-3.0/gcc'
make: *** [bootstrap] Error 2
It was hard to find information specic to my situation, but the majority of what I found that also included this error, seemed to indicate incompatible gcc versions.

My questions is how would one go about compiling older (or newer) versions of gcc that are not compatible to the one you currently have installed (3.3.6 for me). Has anyone attempted anything like this? If so, could you please recommend any strategies or reading material?

Thanks for the help!
...drkstr

Last edited by drkstr; 06-08-2006 at 03:06 AM.
 
Old 06-08-2006, 11:30 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
See this directory for how I do it, and they don't overwrite or inetrfere with your regular compiler.
best to try 3.1 or 3.2.3 first. Using gcc-2.95 ma ybe more comlicated. but that's what I worked out first yo maybe the notes are better. I use these all the time without problems using the provided wrapper scripts to call them.

http://distro.ibiblio.org/pub/linux/...es/DevelTools/
 
Old 06-08-2006, 12:18 PM   #3
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Sweet, thanks for the help. The gcc version I have is 3.0 so hopefully the SlackBuild will work with it. I'm not to familiar with using SlackBuild files, but I would imagine I just copy it to the source directory of my gcc and run it? Do you think I will run into any problems with it being a slightly different version? I saw that most of the stuff used variables so I don't think it would, but then again this kind of stuff is all new to me.

I'll give it a try when I get home and let you know how it goes.

thanks again!
...drkstr
 
Old 06-09-2006, 01:54 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
If you mean using the PkgBuild script that I provide, it's meant to be used with my PkgBuild program. If you look at the two scripts for gcc-3.1 and 3.2.3 you'll see that they are nearly identical.
One thing that I do is repackage the sources so that the package is not named just gcc. That will cause problems with installpkg because of using the same name.
Unpack your tarball and renam the folder to gcc30-3.0. Then re-tar it and gzip or bzip it. Then use my script for gcc-3.1 and just change the name and version at the top. But be sure and install PkgBuild itself first:
http://distro.ibiblio.org/pub/linux/...4-noarch-1.tgz

Note that using a regular Slackware gcc SlackBuild script will cause you a lot of misery since they are for building a 'primary' compiler. I install all man-pages, bins and libraries into /opt/gcc-version so that they don't overwrite your main compiler files. To actually use the compiler then, you must add the /opt/gcc-3.0 path to your path. I include wrappers for this. You just need to modify it to use /opt/gcc-3.0/bin instead og gcc-3.1
The wrapper are called like GCC31, GCC295, etc. What they do is just reset the path so that the gcc you want get's found and used instead of your regular compiler. You use them like this:
'GCC31 make' or GCC make install, etc
 
Old 06-09-2006, 02:26 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
On second thought, I just downloaded the sources to give it a go. Took about 2 minutes to get it started compiling. If you are using --prefix=/usr you'll overwrite your regular compiler.
 
Old 06-09-2006, 08:40 AM   #6
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
I just downloaded the sources to give it a go. Took about 2 minutes to get it started compiling.
You were able to get it working with the SlackBuild script, or just strait up? I gave it a quick shot yesterday with the Slackbuild, but I was unsucsessful. Probably because I didn't install the package build utility. I'll mess around with it more today and give that a try. Is it diffrent then the standard 'pkgtools' that come with Slackware?

Quote:
If you are using --prefix=/usr you'll overwrite your regular compiler.
I'm using '--prefix=/home/drkstr/gcc-psion-3.0-build' I want to build it as a non-root user to make sure I don't over write anything important. One I have everything correct, I was going to package it as root and install.

thanks for the help!
...drkstr
 
Old 06-09-2006, 11:34 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
You definitely should not use --prefix=/usr. This thing should be kept completely out of your ordinary path or your regular compiles will done by this compiler.

I got it to compile right away using my PkgBuild script as a regular ix86 compiler. One thing, the sources you point to are repackaged any way, but badly named for Slackname conformity.
Anyway, I didn't fully understand whyt you want to do. Are you wanting to comoile binaries to run under Symbian? And with which architecture?

Note that you probably need to pass some extra arguments to configure more than just --prefix. Bets results will be obtained using configs from a similar version. You can look through the Slackware site for SlackBuilds from earlier versions with the options close to what you need. Slack-8.1 used gcc-2.95 and had 3.0 in /extra. Slack-9.1 used gcc-3.1
 
Old 06-09-2006, 01:45 PM   #8
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
I didn't fully understand whyt you want to do. Are you wanting to comoile binaries to run under Symbian? And with which architecture?
I'm trying to compile an nfs client (p3nfs) that works over bluetooth for my nokia 9300 (which uses symbian 7.0). The make file for p3nfs point to some Makerules that is in <prefix>gcc-3.0-psion-98r2/lib/makerules/defines.series80.v2. This is all pretty much over my head but I am taking a guess that I had to install the symbian gcc in order to get the above mentiond makerules. The symbian-gcc version allows you to compile for the ARM architecture which is what the processor is on my phone.

FYI:
I think I might have found the fix to the error I was getting, but I hope I don't break my system in the process. Acording to this release, a patch has been made for uclibc which...
Quote:
adds support for ELF preinit_array, init_array and fini_array.
The general approach is similar to that used by glibc, in particular
__uClibc_main now gets passed __libc_csu_init and __libc_csu_fini instead
of _init and _fini, and these wrapper functions take care of calling the
init/fini array functions and _init/_fini in the right order.
I'm not sure what this means to be honest, but I do now that it says it deines __libc_csu_init which is what I am getting as "undefined" when I try to compile symbian-gcc.

I'm not really sure what uclibc is (something about inbeded Linux?), and if it will break my glibc which everythign is compiled against. Have any ideas? If this is not a good idea to implement on my system, do you know if ARM is supported in glibc at all?

thanks!
...drkstr

**edit**
you said you were able to build sucsessfully with no compile errors? What version of glibc do you have? maybe I should just try and upgrade to glibc from Slack-current before messing with all this patching stuff?
**edit**

Last edited by drkstr; 06-09-2006 at 02:02 PM.
 
Old 06-10-2006, 03:57 AM   #9
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
Okay, I looked into this further. Of course all this is supposed to produce a compiler which produces binaries for arm processors, arm-epoch-pe to be xact.
I compiled this error-free their way, even without the SDK.

You need the sdk2unix-1.9.tar.gz and the gcc-3.0-psion98r2-9.tar.gz tarballs.

Best to make yourself a directory in /usr/src like /usr/src/Symbian-SDK
Then unpack the sdk2unix tarball there. cd inside of it and you'll directories:
bin data etc genaif and others. The 'defines' file you are looking for is in data/gcc30. But don't worry about it. It gets copied to the installation directory.

Inside the sdk2unix directory run this command:
bin/install_gcc3.0 /path/to/gcc-3.0-psion98r2-9.tar.gz /opt/gcc-3.0-psion

That will compile and install everything under /opt for you. The main binaries names all have prefixes anyway, but some of the bins have the same names as those of your regular compiler, so don't give prefix=/usr or /usr/local.
Read the install_gcc-3.0 script to see how its'all configured and made.
It makes a log for you in /tmp/sdk.log.

Perhaps you don't even need the compiler for what you are doing. If what you ultimately want to compile is meant to run under linux, then you will not use this compiler to create those binaries. Binaries made with this psion compiler will only run on the phone itself. As I understand it, they don't even really run under Symbian OS, rather they run directly on the phone hardware.
If you want to test these binraies under linux, you need an epoch emulator.
The defines files you seek winds up in /opt/gcc-3.0-psion/lib/makerules.

If you DO want to compile binaries with this compiler, then you need to modify your path so that any generic calls to gcc related programs from the Makefile will use the psion compiler bins instead of the regular gcc. This is what I do with my wrapper scripts. Looks like this

#!/bin/bash

PATH=/opt/gcc-3.0-psion/bin:$PATH
# LD_LIBRARY_PATH=/opt/gcc-3.0-psion/lib:$LD_LIBRARY_PATH
# LD_LIBRARY_PATH=/usr/uCLibc
exec "$@"
exit 0

LD_LIBRARY_PATH is the path to the libraries which the binaries produced are to link with. When you compile programs for your regular system you don't need this, usually. I give two examples. The first one is used if the program needs access to the compiler libraries. The second shows using uClibc. uClibc is a small replaement for the regular GLIBC libraries of a full distro. It's used for systems that run on phones, pda's, etc.
Then, to use the wrapper just save it as GCCpsion and place in your path.
Then when you want to compile type: 'GCCpsion make' instead of 'make' and your psion compiler will be used.
I didn't download an SDK so I'm not sure what you do with all that. You may have to adjust paths so it knows where the compiler is installed.
As far as I can tell this doesn't install anything at all under /usr. You don't want regular document installation as it will overwrite your current files.
I'm using glibc-2.3.4 and gcc-3.3.5
 
Old 06-10-2006, 03:44 PM   #10
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
WOW! Thank you very much for takeing the time to find a solution. Everything is working and I was able to compile the nfs client for my phone (which will in fact run on the phone not the Linux box).

I actually kind of feel like a moron now because I deleted sdk2unix after I used it to install the Symbian SDK, not realizing that I also needed it to install Symbian-gcc as well. I even saw the 'bin/install_gcc3.0 <tarball> <install path>' command in the SDK on Unix HOWTO and was thinking to myself "there's no 'bin' folder in the gcc source path! whoever wrote these directions needs to put down the crack pipe!" I guess maybe I'm the one who needs to lay off the pipe. Thanks for making the connection between the two, which I apparently missed.

Also, thanks for the tips on making sure my two gcc versions don't conflict. I just installed it to a temporary directory in my home drive then moved everything to '<build dir>/usr/local/gcc-3.0-psion-98r2'. From there I just turned it into a SLack-pkg with 'makepkg'. I havent decided weather or not to add the bin dir to my PATH yet. For the most part the binaries are uniquely named, such as 'arm-epoc-pe-gcc'. But there were a few that did have the same name, such as 'gccbug'. I will probably just leave it out unless I plan to build any more Symbian apps down the road. In which case I can just add the PATH to the specific Makefile like you said.

Quick question though
Quote:
#LD_LIBRARY_PATH=/opt/gcc-3.0-psion/lib:$LD_LIBRARY_PATH
is this meant to be commented out, or do you think I will need it?


Thanks again for all your help!
...drkstr
 
Old 06-11-2006, 04:11 AM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
Your only need to set LD_LIBRARY_PATH when the compiler has trouble finding the libraries or the libraries are non-standard, etc.

It's all set up to install in /usr/local, but I don't like that -it places the psion binaries in your path before the regular bins since bins in /usr/local/bin are found before those in /usr/bin. Plus, it's probably not a good idea to move them -the compiler library paths are compiled into the binaries according to --prefix. Not all code uses these libraries, but if it does, then is when you need to use LD_LIBRARY_PATH set to include the gcc-lib dir that goes with this compiler. If you compile code that uses uClibc then you'd set it to include that directory also.
I think I'll package this whole thing or as 2 packages, since it is a little weird to set up. Did you notice that it uses wine to run a DOS executable for extracting the cab files?
 
Old 06-11-2006, 11:10 AM   #12
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
I think I'll package this whole thing or as 2 packages, since it is a little weird to set up.
That would be great! If you have the time you should package the SDK's as well. I also had a little bit of trouble with them.

Quote:
Did you notice that it uses wine to run a DOS executable for extracting the cab files?
I installed wine for the sole purpose of getting the SDK working. I didn't notice sdk2unix calling wine directly, but when I pulled up the install script in a text editor, it does look like it uses it for a couple diffrent things. It doesn't appear to use it to intsll gcc however.

Quote:
it places the psion binaries in your path before the regular bins since bins in /usr/local/bin are found before those in /usr/bin. Plus, it's probably not a good idea to move them -the compiler library paths are compiled into the binaries according to --prefix.
oops. I will recompile as root with the 'prefix=/usr/local/gcc-3.0-psion-98r2' then turn it into a package from this directory. This way the prefix will be set right in my package and the binaries will not go in my PATH.

Thanks again for all the help gnashley, you really know a lot about this stuff!

regards,
...drkstr
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
gcc versions compatibility with kernel versions.. mahesh_manthapuri SUSE / openSUSE 1 03-22-2006 12:28 AM
Revoval of older kernel versions strobart Fedora 4 11-30-2004 11:16 AM
how to use older versions of glibc turls Programming 4 07-07-2004 03:40 PM
up2date for older RH versions thegooch49 Linux - Newbie 4 03-30-2004 02:28 PM
older versions alaios Linux - General 9 10-01-2003 12:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:00 AM.

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