Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Build a GCC 3.3 C compiler for Intel Mac OS X UNIX
Tiger only hintI use a GCC cross compiler for embedded systems development on my Mac. I use Apple's supplied GCC to build the cross toolchain, but when Apple started using GCC 4.0.x, I could no longer compile the specific version of binutils and GCC that I need.

On PowerPC Macs, I could revert to Apple's GCC 3.3 to compile my toolcain, but on my new Macbook Pro, Xcode does not come with GCC 3.3. It is my understanding that Apple will not be providing a GCC 3.3 for Intel OS X.

Fixing my toolchain to compile with GCC 4.0.x is not an option, because the tools are under configuration management and build fine on all of the other computers in my organization ( cygwin and linux ).

After much expermenting, I finally was able to build Apple's GCC 3.3 so I could then build an Intel OS X hosted version of my cross toolchain.

Here is what I did: 1. Download the source code for Apple's GCC 3.3 in Xcode 2.2 here. Get the file named gcc_os-1819.tar.gz

2. Unpack the source.

$ tar -zxf gcc_os-1819.tar.gz

3. Fix a line that causes it to not compile: in the file gcc_os-1819/gcc/gcc.c, on line 5883, change the line to look like this:

(char ) v[q - vt] = 0;

4. Make a build directory and run configure. I installed my compiler in /opt/gcc3, and I only built the C compiler. This would not work for building C++ or Cocoa applications.
$ mkdir build
$ cd build
$ ../gcc_os-1819/configure --prefix=/opt/gcc3 --enable-languages=c
5. Build the compiler:

$ make all

6. Install the compiler in /opt/gcc3:

$ sudo make install

7. Test it:
$ /opt/gcc3/bin/gcc -v
Reading specs from /opt/gcc3/lib/gcc-lib/i686-apple-darwin8.6.1/3.3/specs
Configured with: ../gcc_os-1819/configure --prefix=/opt/gcc3 --enable-languages=c
Thread model: single
gcc version 3.3 20030304 (Apple Computer, Inc. build 1819)
Now, you can use the compiler to build Unix packages that will not build with GCC 4.0.x.

[kirkmc adds: I haven't tested this.]
    •    
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[26,874 views]  

10.4: Build a GCC 3.3 C compiler for Intel Mac OS X | 10 comments | Create New Account
Click here to return to the '10.4: Build a GCC 3.3 C compiler for Intel Mac OS X' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: wgscott on Apr 27, '06 07:56:57AM

I'm hoping this might permit compiling g77 as well...



[ Reply to This | # ]
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: wgscott on Apr 27, '06 12:52:09PM

No such luck.

g95 and gfortran will have to do I guess (until someone smarter than me figures it out).



[ Reply to This | # ]
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: alexandre.h on Apr 27, '06 08:17:23AM

sudo gcc_select 3.3 works fine for me.



[ Reply to This | # ]
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: Ranger Rick on Apr 27, '06 11:46:52AM

alexandre.h, the gcc-3.3 provided with 10.4 can only build binaries for a powerpc machine, not for intel. If you have a new intel mac you're forced to use gcc4 unless you build a cross-compiler.



[ Reply to This | # ]
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: ework on Apr 27, '06 10:10:37AM

Awesome hint!



[ Reply to This | # ]
Crosstool
Authored by: vocaro on Apr 27, '06 01:42:55PM
Could you not use Crosstool?

[
Reply to This | # ]
DP
Authored by: mkb218 on Apr 28, '06 07:13:18AM

DarwinPorts has a set of gcc3-based cross-compilers:

arm-aout-gcc cross/arm-aout-gcc @3.3.3 gcc cross-compilers for arm-aout, with newlib runtime library.
arm-elf-gcc cross/arm-elf-gcc @4.0.0 gcc cross-compilers for arm-elf, with newlib runtime library.
arm-rtems-gcc cross/arm-rtems-gcc @3.2.3 gcc cross-compilers for arm-rtems, with newlib runtime library.
avr-gcc cross/avr-gcc @4.0.2 gcc cross-compilers for avr
i386-elf-gcc cross/i386-elf-gcc @3.4.3 gcc cross-compilers for i386-elf, with newlib runtime library.
i386-mingw32-gcc cross/i386-mingw32-gcc @3.4.2-20040916-1 Mingw32 cross-compiler for i386-Win32
i386-rtems-gcc cross/i386-rtems-gcc @3.2.3 gcc cross-compilers for i386-rtems, with newlib runtime library.
i960-rtems-gcc cross/i960-rtems-gcc @3.2.3 gcc cross-compilers for i960-rtems, with newlib runtime library.
m68k-elf-gcc cross/m68k-elf-gcc @3.4.3 gcc cross-compilers for m68k-elf, with newlib runtime library.
m68k-rtems-gcc cross/m68k-rtems-gcc @3.2.3 gcc cross-compilers for m68k-rtems, with newlib runtime library.
mips-elf-gcc cross/mips-elf-gcc @3.4.5 gcc cross-compilers for mips-elf, with newlib runtime library.
mips-rtems-gcc cross/mips-rtems-gcc @3.2.3 gcc cross-compilers for mips-rtems, with newlib runtime library.
mipsel-linux-gcc34 cross/mipsel-linux-gcc34 @3.4.4 gcc cross compiler for mips-linux with uClib
powerpc-rtems-gcc cross/powerpc-rtems-gcc @3.2.3 gcc cross-compilers for powerpc-rtems, with newlib runtime library.
sh-rtems-gcc cross/sh-rtems-gcc @3.2.3 gcc cross-compilers for sh-rtems, with newlib runtime library.
sparc-rtems-gcc cross/sparc-rtems-gcc @3.2.3 gcc cross-compilers for sparc-rtems, with newlib runtime library.

You're not pegged to those versions, either.

---
--
mkb



[ Reply to This | # ]
DP
Authored by: dodav666 on May 31, '06 01:17:58AM
I just tried to run up the darwinports version of the tool chain to see if they had incorporated the new devices patch for last years new devices. It appears currently to be pretty busted (avr-binutil) on both panther and tiger as of today. I was going to see if fink was in any better shape but when it insisted on builing tex and ghostscript and 36 other files in the /sw tree (when there are perfectly fine versions of most of these tools installed) I said to hell with that.
My journey to create a usable tool chain lead me to these instructions for building a package and saving us all the hassle: http://digithink.com/embedded/Avr/OSXToolChain
If someone built a binary for intel then we could run around like todays linux kids and just ftp,apt, or yum them down and use our tools instead of building them every time we change our environment.
I have multiple systems so it makes sense to me to package them. And if you package it you should make it avaliable.
I dunno.

[ Reply to This | # ]
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: ejalbert on Apr 29, '06 01:04:13PM

gcc 3.3 is not compatible with the ABI of Mac OS X on Intel. You can build it from the FSF sources if you'd like, but the resulting compiler will not generate working code in a variety of cases. Debugging those kinds of problems would be sufficiently annoying that you really, really, really want to use gcc 4.0 instead.



[ Reply to This | # ]
10.4: Build a GCC 3.3 C compiler for Intel Mac OS X
Authored by: dodav666 on Oct 26, '06 01:34:24PM

Yes but it is relatively critical to bootstrapping cross compilers.

Thanks for this article.



[ Reply to This | # ]