Error when attempting to build llvm-gcc-4.2-2.4.source on Mac OS X 10.5.6

Hi,
I’m new to LLVM and I want to setup the Trident Compiler system on Mac OS X. I downloaded the llvm-gcc-4.2-2.4.source.tar.gz package, created a build directory and ran the following command to configure

$ …/src/configure --program-prefix=llvm- --disable-bootstrap --enable-checking --enable-languages=c,c++
$ make -j 2

Configure works fine, but I get the following error after running the make command:

gcc -c -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute -fno-common -mdynamic-no-pic -DHAVE_CONFIG_H -I. -I. -I…/…/src/gcc -I…/…/src/gcc/. -I…/…/src/gcc/…/include -I./…/intl -I…/…/src/gcc/…/libcpp/include -I…/…/src/gcc/…/libdecnumber -I…/libdecnumber …/…/src/gcc/tree-nested.c -o tree-nested.o
…/…/src/gcc/tree-nested.c: In function ‘convert_tramp_reference’:
…/…/src/gcc/tree-nested.c:1846: error: ‘BUILT_IN_ADJUST_TRAMPOLINE’ undeclared (first use in this function)
…/…/src/gcc/tree-nested.c:1846: error: (Each undeclared identifier is reported only once
…/…/src/gcc/tree-nested.c:1846: error: for each function it appears in.)
make[2]: *** [tree-nested.o] Error 1
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2

How can I resolve this error?

Best regards,

Elvis Dowson

Hello, Elvis

$ ../src/configure --program-prefix=llvm- --disable-bootstrap
--enable-checking --enable-languages=c,c++

You haven't configured llvm-gcc properly. Please do read readme.llvm file.

However, afair, Trident was LLVM 1.5-based, and it will require
massive rewrite to use LLVM 2.x
(bytecode format was also changed)

Thanks Anton,
Yes, I just realized this. I am going through the steps now.

So, you’re saying that Trident will not work with llvm-2.4?

If I have to use llvm-1.5, which is the corresponding C front end? I couldn’t locate the C front end package on the Trident Compiler website.

Best regards,

Elvis Dowson

Hi,
Here are the steps that I followed to create a successful build on Mac OS X 10.5.6.

Best regards,

Elvis Dowson

Technote llvm-gcc4.2-2.4-001: How to build llvm-gcc4.2-2.4 for Mac OS X 10.5.6

Procedure

Step 01: Configure, build and install llvm-2.4.

Directory structure:

llvm-2.4
/ build
/ src

The following commands will build a debug version of llvm.

$ cd build
$ …/src/configure
$ make -j 2 ENABLE_OPTIMIZED=0

To build a release version of llvm, type the following command

$ make ENABLE_OPTIMIZED=1

Step 02: Configure, build and install llvm-gcc4.2-2.4.

When building the llvm-gcc front end with a debug version of llvm, ensure that the --enable-checking configure option is set.

If building for Darwin/X86 (32-bit support):
TARGETOPTIONS=‘–with-arch=nocona --with-tune=generic’

In addition, you must specify the following options to configure:
–with-gxx-include-dir=/usr/include/c++/4.0.0

With these options, llvm-gcc will build the same way as Apple’s system GCC.

Directory structure:

llvm-gcc4.2-2.4
/ build
/ install
/ src

Type the following commands to build a debug version of llvm-gcc

$ cd build
$ export TARGETOPTIONS=‘–with-arch=nocona --with-tune=generic’
$ export TRIPLE=i386-apple-darwin9.6.0
$ export BUILDOPTIONS=LLVM_VERSION_INFO=2.4
$ …/src/configure --enable-checking --with-gxx-include-dir=/usr/include/c++/4.0.0 --prefix=pwd/…/install --program-prefix=llvm- --enable-llvm=$LLVM_HOME/build --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS --disable-bootstrap --disable-multilib
$ make $BUILDOPTIONS -j 2 ENABLE_OPTIMIZED=0
$ make install

Step 03: Update PATH environment variable

export LLVM_HOME=$HOME/Tool/llvm-2.4
export LLVM_GCC_HOME=$HOME/Tool/llvm-gcc4.2-2.4
export PATH=$PATH:$LLVM_HOME/build/Debug/bin:$LLVM_GCC_HOME/install/bin

Step 04: Verify the installation

$ llvm-gcc -v
$ gcc version 4.2.1 (Based on Apple Inc. build 5623) (LLVM build 2.4)

If the -v line above doesn’t include “LLVM”, you probably mistyped the --enable-llvm=xxx line and have a normal gcc, not an llvm-gcc.

Related Topics

  1. Nabble - LLVM - Dev - llvm-gcc compilation error: BUILT_IN_ADJUST_TRAMPOLINE undeclared

Related Links

  1. http://www.llvm.org/
  2. Building the LLVM GCC Front-End

Hi, Elvis

So, you're saying that Trident will not work with llvm-2.4?

No idea, but most probably - yes, it won't work.

If I have to use llvm-1.5, which is the corresponding C front end? I
couldn't locate the C front end package on the Trident Compiler website.

I think you might try to grab some old source package from llvm-1.5
days. However, it was pre gcc-3.4-based and you'll definitely miss 2+
years of rapid LLVM progressing...

Hi Anton,
Where can I get gccas ? I am running Mac OS X 10.5.6 and I get the following error:

xgcc: installation problem, cannot exec gccas': No such file or directory make[2]: *** [libgcc/./_muldi3.o] Error 1 make[2]: *** Waiting for unfinished jobs.... xgcc: installation problem, cannot exec gccas’: No such file or directory
make[2]: *** [libgcc/./_negdi2.o] Error 1
make[1]: *** [libgcc.a] Error 2
make: *** [all-gcc] Error 2

Best regards,

Elvis Dowson

gccas was part of pre-2.0 versions of LLVM. LLVM and LLVM-GCC are version-locked. You won’t be able to build an llvm-gcc 1.5 frontend against a post-2.0 version of LLVM.

–Owen

2008/12/28 Elvis Dowson <elvis.dowson@mac.com>

Where can I get gccas ? I am running Mac OS X 10.5.6 and I get the following error:

gccas is one of the LLVM tools; you have to build them before building llvm-gcc and you should configure llvm-gcc with the --enable-llvm=[…] flag unless the LLVM tools are in your PATH.

See http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk/README.LLVM for more details; http://llvm.org/docs/GCCFEBuildInstrs.html is also applicable, even though it mostly talks about Ada.

Misha

Thanks!! :slight_smile: I managed to get the full environment working. :slight_smile:

The solution was to build the llvm tools first and then continue with the rest of the build process. I’ve attached the full procedure below.

Best regards,

Elvis

Procedure

Step 01: Specify environment variables

export LLVM_HOME=$HOME/Tool/llvm-1.5
export LLVM_GCC_HOME=$HOME/Tool/llvm-gcc-1.5
export PATH=$PATH:$ANT_HOME/bin:$LLVM_HOME/install/bin:$LLVM_GCC_HOME/install/bin:

Step 02: Configure, build and install llvm tools. This will build the gccas and gccld tools required to build the llvm-gcc front end.

$ …/src/configure --enable-checking --prefix=pwd/…/install --disable-bootstrap --disable-multilib
$ make tools-only $BUILDOPTIONS -j 2 ENABLE_OPTIMIZED=0
$ make install

The llvm tools will be installed into the $LLVM_HOME/install/bin directory.

Step 03: Configure, build and install llvm-gcc-1.5.

llvm-gcc-1.5
/ build
/ install
/ src

Type the following commands to build a debug version of llvm-gcc

$ cd build
$ export TARGETOPTIONS=‘–with-arch=i386’
$ export TRIPLE=i386-apple-darwin9.6.0
$ export BUILDOPTIONS=LLVM_VERSION_INFO=1.5
$ …/src/configure --enable-checking --with-gxx-include-dir=/usr/include/c++/4.0.0 --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE --prefix=pwd/…/install --program-prefix=llvm- --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS --disable-bootstrap --disable-multilib
$ make $BUILDOPTIONS -j 2 ENABLE_OPTIMIZED=0
$ make install

$ ln -sf /usr/lib/libstdc++.6.dylib pwd/…/install/lib
$ ln -sf /usr/lib/libstdc++.6.dylib pwd/…/install/lib/libstdc++.dylib

The last step, “ln -sf …” is required so that the linker (collect2) can find libstdc++ (‘-lstdc++’) and subsequently link C++ executables correctly.

Type the following command to see if llvm-gcc is correctly installed:

$ llvm-gcc -v
$ gcc version 3.4-llvm 20030924 (experimental)

Step 04: Configure, build and install llvm-1.5.

Directory structure:

llvm-1.5
/ build
/ src

The following commands will build a debug version of llvm.

$ cd build
$ …/src/configure
$ make -j 2 ENABLE_OPTIMIZED=0

To build a release version of llvm, type the following command

$ make ENABLE_OPTIMIZED=1