[LLVMdev] make error building llvm/clang 3.2 on Linux

Michael Young
Tue, 26 Feb 2013 14:19:32 -0000

Just in case someone is having similar problems and/or following this
thread, here's my final "solution" (at least, for now).

In my bash build script, prior to configure, I set the C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH to empty strings, and then set some other
environment variables instead:

export C_INCLUDE_PATHexport CPLUS_INCLUDE_PATH
SYSTEM_INCLUDE_PATH="/usr/include/i386-linux-gnu"

export CC=gcc
export CXX=g++
export CFLAGS="-isystem
""${SYSTEM_INCLUDE_PATH}"""
export CXXFLAGS="-isystem
""${SYSTEM_INCLUDE_PATH}"""

This allowed me to build (configure and make) without error.

It's not pretty, it's not perfect, but it seems to work.

Since the LIBRARY_PATH environment variable is still set in this
"solution", I'm slightly concerned that I may be picking up
incorrect
libraries with clang (I'm not sure whether clang actually uses this
variable), but everything so far, including the testsuite (with a
subsequent "make check-all"), does seem to compile, link, and run
without problems.

Note that I did try to do the same with LIBRARY_PATH (using
SYSTEM_LIBRARY_PATH="/usr/lib/i386-linux-gnu"
export LDFLAGS="-L""${SYSTEM_LIBRARY_PATH}"""
instead), but configure still choked when running gcc - it couldn't
find the crt*.o libraries. Here's the relevant output from the
config.log file:

***
configure:2141: checking for C compiler default output file name
configure:2168: gcc -isystem /usr/include/i386-linux-gnu
-L/usr/lib/i386-linux-gnu conftest.c>&5
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
configure:2171: $? = 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME "LLVM"
| #define PACKAGE_TARNAME "llvm"
| #define PACKAGE_VERSION "3.2svn"
| #define PACKAGE_STRING "LLVM 3.2svn"
| #define PACKAGE_BUGREPORT "http://llvm.org/bugs/"
| #define LLVM_VERSION_MAJOR 3
| #define LLVM_VERSION_MINOR 2
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:2210: error: C compiler cannot create executables
***

I tried compiling a simple program using gcc, similar to what the
configure script indicated, but with -v on the command line:

echo "int main(){;return 0;}"> test.c
gcc -v -isystem /usr/include/i386-linux-gnu -L/usr/lib/i386-linux-gnu test.c

Here's the output from that:

***
$ gcc -v -isystem /usr/include/i386-linux-gnu -L/usr/lib/i386-linux-gnu test.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/libexec/gcc/i686-pc-linux-gnu/4.7.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured
 with:
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/source/gcc-4.7.2/configure

--prefix=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install

--with-local-prefix=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/local

--with-gmp=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/source/../gmp

--with-mpfr=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/source/../mpfr

--with-mpc=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/source/../mpc
 --enable-languages=c,c++,java
--with-pkgversion=''\''MJY_Build__2013/02/22_04:52'\'''
Thread model: posix
gcc version 4.7.2 ('MJY_Build__2013/02/22_04:52')
COLLECT_GCC_OPTIONS='-v'
 '-isystem' '/usr/include/i386-linux-gnu'
'-L/usr/lib/i386-linux-gnu'
'-mtune=generic' '-march=pentiumpro'
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/libexec/gcc/i686-pc-linux-gnu/4.7.2/cc1
 -quiet -v -isystem /usr/include/i386-linux-gnu test.c -quiet -dumpbase
test.c -mtune=generic -march=pentiumpro -auxbase test -version -o
/tmp/ccUYclfj.s
GNU C ('MJY_Build__2013/02/22_04:52') version 4.7.2 (i686-pc-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.1.0, MPFR version 3.1.1, MPC
version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/i386-linux-gnu"
ignoring nonexistent directory
"/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/local/include"
ignoring
 nonexistent directory
"/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/i386-linux-gnu
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/include
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/include
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/include-fixed
/usr/include
End of search list.
GNU C ('MJY_Build__2013/02/22_04:52') version 4.7.2 (i686-pc-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.1.0, MPFR version 3.1.1, MPC
version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 72f68229415f19718f7dd812e60ab105
COLLECT_GCC_OPTIONS='-v'
 '-isystem' '/usr/include/i386-linux-gnu'
'-L/usr/lib/i386-linux-gnu'
'-mtune=generic' '-march=pentiumpro'
as -v --32 -o /tmp/ccB5jzCx.o /tmp/ccUYclfj.s
GNU assembler version 2.22 (i686-linux-gnu) using BFD version (GNU Binutils for
Ubuntu) 2.22
COMPILER_PATH=/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/libexec/gcc/i686-pc-linux-gnu/4.7.2/:/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/libexec/gcc/i686-pc-linux-gnu/4.7.2/:/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/libexec/gcc/i686-pc-linux-gnu/:/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/:/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/
LIBRARY_PATH=./:/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/:/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v'
 '-isystem' '/usr/include/i386-linux-gnu'
'-L/usr/lib/i386-linux-gnu'
'-mtune=generic' '-march=pentiumpro'
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/libexec/gcc/i686-pc-linux-gnu/4.7.2/collect2
 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 crt1.o
crti.o
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/crtbegin.o
 -L/usr/lib/i386-linux-gnu -L.
-L/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2

-L/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/../../..
 /tmp/ccB5jzCx.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed
/home/youngmj/DevTools/Gnu_Compiler_Collection-gcc/Version_4.7.2/install/lib/gcc/i686-pc-linux-gnu/4.7.2/crtend.o
 crtn.o
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
$
***

Note that the invocation of gcc's collect2 has references on the
command line to the missing libraries that precede the -L option to
add the directory needed to find these libraries. I'm not a gcc
expert, but this looks rather suspicious to me, and may be what's
preventing me from using LDFLAGS rather than LIBRARY_PATH.

- Mike