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

Install GCC 3.1 on 10.1.5 UNIX
This quick guide will allow you to install GCC 3.1 (Free Software Foundation version, not Apple's) along with the C, C++, and objective-C compilers. This is useful if you want to test out your code before Apple's release of GCC3 in Jaguar (10.2). Features of 3.1 include faster compilation, better code optimization, a new C++ library, and better support for the ANSI code standards.

However, there are some problems with this release. GCC will not recognize some compiler flags and the dynamic linker does not work with this build - you will often have to link statically and configure software with the "--disabled-" shared flag. If anyone knows how to get around these problems, feel free to post in the comments.

Read the rest of the article for the how-to (the Dev Tools are required)...

NOTE: Compiling GCC can take several hours depending on your machine's speed, so plan accordingly.
  1. Go to the mirrors page and select one of the mirrors.

  2. Go to 'releases', then 'gcc-3.1' then download 'gcc-3.1.tar.bz2' (about 20MB).

  3. After expanding (about 150MB), open the file gcc-3.1/gcc/ginclude/stddef.h in a text editor (recommend Project Builder or pico).

  4. Below the line
    #ifndef _SIZE_T_DEFINED
    #ifndef _BSD_SIZE_T_DEFINED_
  5. Below the line
    #define _SIZE_T_DEFINED
    #define _BSD_SIZE_T_DEFINED_  /* for Darwin */
  6. Below the line
    #endif /* ___int_size_t_h */
    #endif /* _BSD_SIZE_T_DEFINED_ */
  7. Save, then open the file gcc-3.1/libstdc++-v3/include/c_std/std_cctype.h in a text editor.

  8. Below the line
    #undef toupper
    /* APPLE LOCAL begin supply missing ctype.h decls 2001-07-11 sts */
    /* These are supposed be in ctype.h like the standard says! We need
    this until Darwin ctype.h gets fixed and/or GCC has a fixincludes
    to supply these if they're missing. */
    extern "C" {
    extern int isalnum(int c);
    extern int isalpha(int c);
    extern int iscntrl(int c);
    extern int isdigit(int c);
    extern int isgraph(int c);
    extern int islower(int c);
    extern int isprint(int c);
    extern int ispunct(int c);
    extern int isspace(int c);
    extern int isupper(int c);
    extern int isxdigit(int c);
    /* APPLE LOCAL end supply missing ctype.h decls 2001-07-11 sts */
  9. Save, and in the Terminal navigate to the gcc-3.1 directory (VERY IMPORTANT!)

  10. Type
     % limit stacksize 3072
    % mkdir ../gcc_build;cd ../gcc_build
    % ../gcc-3.1/configure --enable-languages='c,c++,objc'
    % make bootstrap-lean
    % sudo make install
  11. Once installed, you can remove the gcc_build directory. If you want to use the Apple 2.95 compiler, use the command "cc".

    Altivec Notes:
    There is a configure option that is supposed to enable Altivec support for the ABI, but does not compile properly.

    From GCC 3.1 Changes:
    Aldy Hernandez, of Red Hat, Inc has contributed extensions to the PowerPC port supporting the AltiVec programming model (SIMD). The support, though presently useful, is experimental and is expected to stabilize for 3.2. The support is written to conform to Motorola's AltiVec specs. See -maltivec. Because I have a G3 system, I have not tested using the -maltivec flag.

    [Editor's note: I have not tested this, and I hope that I haven't messed up any of the commands during the formatting process. If you see something that doesn't look right, please let me know...]
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Install GCC 3.1 on 10.1.5 | 10 comments | Create New Account
Click here to return to the 'Install GCC 3.1 on 10.1.5' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Will this even work?
Authored by: babbage on Jul 23, '02 10:46:18AM

I thought the gcc Apple was shipping had been hacked up in ways incompatible to the standard version in order to make it work on OSX. I forget the details -- sorry -- but I thought they had to come up with custom hacks to deal with Darwin, HFS+, NetInfo, etc and that the standard version of GCC would not have such customizations available. Have Apple's changes been folded into the main trunk version, or are those hacks in some other way approximated by this hack? If not, this sounds very risky to me...

[ Reply to This | # ]
Will this even work? - Maybe
Authored by: Anonymous on Jul 23, '02 01:06:09PM

I would rather go with Apple's gcc3 as it is posted in the April DevTools.
I think the other one will work, since Apple submits changes back and those for mere BSD-compatibility will probably be folded in (why shouldn't they).

However, Apple's version includes some auto-vectorization features to push sequences of floating-point ops into AltiVec Ops to achive notable speedups - these optimizations are not likely to be folded in soon.

I think this is well documented with the Dev-Tools, and probably these optimizations are the reason for a part of the 10.2 speedup. (Even if you don't have a QE-compatible Mac.


[ Reply to This | # ]
gcc3 part of April Dev Tools
Authored by: hayne on Jul 23, '02 11:01:03AM

I don't really see the point of going through all that to get gcc3 since it is already included in the April 2002 (beta) version of the Developer Tools.
By default, the compiler used with the April Dev Tools is gcc2 but gcc3 is there and the release notes document that gets installed on your hard drive:
tells you how to switch to use gcc3 instead of gcc2.

I have switched to use gcc3 (from the April Dev Tools) for all my commmand-line compiling. I did this via the command
sudo /usr/sbin/gcc_select 3
as given in the release notes. I have seen no problem at all.

I have not yet tried using gcc3 in Project Builder. The releases notes tell you how to do this - it is a separate step and it is fine to continue to use gcc2 within PB even though your default compiler (/usr/bin/cc) is gcc3.

By the way, as far as I know, the gcc3 that is supplied with the Dev Tools is identical to the one you can download from GNU, so there should be no problem with compatibility.

[ Reply to This | # ]
gcc3 part of April Dev Tools
Authored by: c15zyx on Jul 23, '02 06:24:07PM

Yup, using apple's gcc under the dev tools is far better, but this was written for people on dialups who would rather download 20MB compared to 200MB. Apple's gcc is quite a bit different from the FSF version, however the strange thing is that there have always been fixes and hacks to support darwin but have never been commited or placed in the mainline. Strange.

[ Reply to This | # ]
Authored by: brett_ on Jul 23, '02 01:18:18PM
i haven't read this thread too carefully, but iirc you have to add the following flags to compile under gcc3:
setenv CFLAGS "-O1 -mdynamic-no-pic -no-cpp-precomp"
you can also add
-faltivec -mcpu=7450 -mtune=7450
fwiw. brett

[ Reply to This | # ]
Authored by: brett_ on Jul 23, '02 01:32:08PM

oops, i didn't mean to put the -O1 in the required category. just the dynamic and precomp flags. also, the optional flags are things to look into.

[ Reply to This | # ]
precompiled binaries available
Authored by: j-beda on Jul 23, '02 02:24:29PM
In getting Fortran stuff working for my wife, I found that had precompiled binaries available in a nice .pkg format. Some other tools for scientific programing are also available at [PS - why does the "preview" button create extra spaces in the HTML paragraph tags?]

[ Reply to This | # ]
Easy way out
Authored by: c15zyx on Jul 24, '02 12:55:45AM
If you know how to use CVS, you can register for free at Apple's public source page so you can get Apple's gcc3 from its cvs servers. Apple's version of gcc is highly recommended over the FSF version, because it is the most compatible with darwin. Installation is also easier, no files have to be edited just to get it to compile. see Apple's page on using cvs. basically, just register with apple (free), check out the source using
cvs -d login
cvs -d -z9 co gcc3
Then just follow the instructions in the README.Apple file

[ Reply to This | # ]
Easy way out
Authored by: wspies on Aug 20, '02 08:14:31AM

I tried to get gcc3 from CVS. Got it but it needs gnumake. Got gnumake but it needs cc....and so on and so on...

Any place I can get the Apple binaries?

[ Reply to This | # ]
Successful 3.2 bootstrap
Authored by: c15zyx on Aug 28, '02 01:01:27PM