Using odcctools with gcc

  1. Downloading odcctools
  2. Configuring odcctools
  3. Building & Installing odcctools
  4. Downloading gcc
  5. Configuring gcc
  6. Building & Installing gcc
  7. Verifying the installation

Downloading odcctools

You can download the source for odcctools from http://www.opendarwin.org/downloads/odcctools-20050327.tar.bz2. If you choose to use CVS to access the source, you will need to do me:

% cvs co odcctools

% cd src

% make regen

This will unpack the Apple cctools distribution, and patch it to create the odcctools distribution directory.

Configuring odcctools

odcctools uses autoconf for configuration. It also supports building outside the source directory, just like gcc. A basic configure step would be:

% mkdir odcctools-build

% cd odcctools-build

% ../odcctools-20050327/configure --prefix=/usr/local/gcc

Building & Installing odcctools

Building odcctools is a simple matter of issuing the following commands. Your install directory can also be configured not to require sudo to elevate priveleges.

% make

% sudo make install

Downloading gcc

Download gcc however you normally would. For instance, you can use a gcc snapshot, or gcc CVS.

Configuring gcc

Before you can configure gcc, you must make some changes to the source to support using a version of cctools not installed in /usr/bin. First, you must change the patch used to execute libtool(1):

% perl -pi -e 's,/usr/bin/libtool,/usr/local/gcc/bin/libtool,;' gcc/config/darwin.h

Configure gcc as your normally would, but in addition provide the --with-as and --with-ld arguments. For example:

% mkdir -p gcc-build

% cd gcc-build

% ../gcc/configure --prefix=/usr/local/gcc --disable-checking --enable-languages=c,c++ \

        --with-as=/usr/local/gcc/bin/as --with-ld=/usr/local/gcc/bin/ld

Building & Installing gcc

Build gcc as you normally would. For example:

% make -j3 bootstrap

% sudo make install

Verifying the installation

At this point, you should verify that the installation worked, and that the newly built gcc is using the correct tools.

% cat > foo.c

void foo(void) {}

^D

% cat > main.c

extern void foo(void);

int main(int argc, char *argv[]) {

        foo();

        return 0;

}

^D

% /usr/local/gcc/bin/gcc -o test main.c foo.c -v -Wa,-v -Wl,-v

Reading specs from /usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/specs

Configured with: ../gcc/configure --prefix=/usr/local/gcc --disable-checking --enable-languages=c,c++ --with-as=/usr/local/gcc/bin/as --with-ld=/usr/local/gcc/bin/ld

Thread model: posix

gcc version 3.5.0 20040822 (Apple Computer, Inc. build 1779)

 /usr/local/gcc/libexec/gcc/powerpc-apple-darwin7.5.0/3.5.0/cc1 -quiet -v -D__DYNAMIC__ -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 main.c -mconstant-cfstrings -fPIC -quiet -dumpbase main.c -auxbase main -version -o /var/tmp//ccxBtdkf.s

ignoring nonexistent directory "/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/../../../../powerpc-apple-darwin7.5.0/include"

#include "..." search starts here:

#include <...> search starts here:

 /usr/local/include

 /usr/local/gcc/include

 /usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/include

 /usr/include

 /System/Library/Frameworks

 /Library/Frameworks

End of search list.

GNU C version 3.5.0 20040822 (Apple Computer, Inc. build 1779) (powerpc-apple-darwin7.5.0)

        compiled by GNU C version 3.5.0 20040822 (Apple Computer, Inc. build 1779).

GGC heuristics: --param ggc-min-expand=65 --param ggc-min-heapsize=65536

 /usr/local/gcc/bin/as -arch ppc -v -o /var/tmp//ccSGI7AK.o /var/tmp//ccxBtdkf.s

Apple Computer, Inc. version odcctools-576od7, GNU assembler version 1.38

 /usr/local/gcc/libexec/gcc/powerpc-apple-darwin7.5.0/3.5.0/cc1 -quiet -v -D__DYNAMIC__ -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 foo.c -mconstant-cfstrings -fPIC -quiet -dumpbase foo.c -auxbase foo -version -o /var/tmp//ccxBtdkf.s

ignoring nonexistent directory "/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/../../../../powerpc-apple-darwin7.5.0/include"

#include "..." search starts here:

#include <...> search starts here:

 /usr/local/include

 /usr/local/gcc/include

 /usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/include

 /usr/include

 /System/Library/Frameworks

 /Library/Frameworks

End of search list.

GNU C version 3.5.0 20040822 (Apple Computer, Inc. build 1779) (powerpc-apple-darwin7.5.0)

        compiled by GNU C version 3.5.0 20040822 (Apple Computer, Inc. build 1779).

GGC heuristics: --param ggc-min-expand=65 --param ggc-min-heapsize=65536

 /usr/local/gcc/bin/as -arch ppc -v -o /var/tmp//ccFqAJN5.o /var/tmp//ccxBtdkf.s

Apple Computer, Inc. version odcctools-576od7, GNU assembler version 1.38

 /usr/local/gcc/libexec/gcc/powerpc-apple-darwin7.5.0/3.5.0/collect2 -arch ppc -dynamic -o test -lcrt1.o /usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/crt2.o -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0 -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/../../.. /var/tmp//ccSGI7AK.o /var/tmp//ccFqAJN5.o -v -lgcc -lgcc_eh -lSystem -lmx

collect2 version 3.5.0 20040822 (Apple Computer, Inc. build 1779) (Darwin/PowerPC)

/usr/local/gcc/bin/ld -arch ppc -dynamic -o test -lcrt1.o /usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/crt2.o -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0 -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/../../.. /var/tmp//ccSGI7AK.o /var/tmp//ccFqAJN5.o -v -lgcc -lgcc_eh -lSystem -lmx

Apple Computer, Inc. version odcctools-576od7

% /usr/local/gcc/bin/gcc -o libfoo.dylib -dynamiclib foo.c -v -Wl,-v

/usr/local/gcc/bin/libtool -arch_only ppc -dynamic -noall_load -o libfoo.dylib -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0 -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/../../.. /var/tmp//ccO8qLk6.o -v -lgcc -lgcc_eh -lSystem -lmx

+ /usr/local/gcc/bin/ld -arch ppc -dylib -dynamic -force_cpusubtype_ALL -no_arch_warnings -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0 -L/usr/local/gcc/lib/gcc/powerpc-apple-darwin7.5.0/3.5.0/../../.. -ldylib1.o /var/tmp//ccO8qLk6.o -lgcc -lgcc_eh -lSystem -lmx -o libfoo.dylib