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

1,638 views
Skip to first unread message

Michael Young

unread,
Feb 20, 2013, 7:15:19 PM2/20/13
to llv...@cs.uiuc.edu

I'm attempting to build a native build of clang from the 3.2 source
distribution tarballs, but I ran into this build error that's got me
really puzzled. My platform is Linux - 32-bit Ubuntu (12.04) running
on a PC. Here's the (abbreviated) output from make:

***************************************
...
make[3]: Entering directory `/home/youngmj/DevTools/LLVM/Version_3.2/build/tools/clang/runtime'
make[4]: Entering directory `/home/youngmj/DevTools/LLVM/Version_3.2/build/tools/clang/runtime/compiler-rt'
make[5]: Entering directory `/home/youngmj/DevTools/LLVM/Version_3.2/source/compiler-rt-3.2.src'
MKDIR: /home/youngmj/DevTools/LLVM/Version_3.2/build/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib
COMPILE: clang_linux/full-i386/i386: /home/youngmj/DevTools/LLVM/Version_3.2/source/llvm-3.2.src/projects/compiler-rt/lib/absvdi2.c
<* SNIP *>
COMPILE: clang_linux/full-i386/i386: /home/youngmj/DevTools/LLVM/Version_3.2/source/llvm-3.2.src/projects/compiler-rt/lib/divxc3.c
COMPILE: clang_linux/full-i386/i386: /home/youngmj/DevTools/LLVM/Version_3.2/source/llvm-3.2.src/projects/compiler-rt/lib/enable_execute_stack.c
In file included from /home/youngmj/DevTools/LLVM/Version_3.2/source/llvm-3.2.src/projects/compiler-rt/lib/enable_execute_stack.c:13:
/usr/include/i386-linux-gnu/sys/mman.h:23:10: fatal error: 'features.h' file not found
#include <features.h>
^
1 error generated.
...
***************************************

[Note: I created a symlink from <LLVM_SRC_DIR>/projects/compiler-rt to
the directory created by unpacking the tarball source for compiler-rt
(which is located on the same level as <LLVM_SRC_DIR> and has a suffix
of "-3.2.src" in the name), so that's why the directory names may look
a little funny.]

Running "gcc -x c -E -v -" gives me the following:

***************************************
$ gcc -xc -E -v -
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i686'
/usr/lib/gcc/i686-linux-gnu/4.6/cc1 -E -quiet -v -imultilib . -imultiarch i386-linux-gnu - -mtune=generic -march=i686 -fstack-protector
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i686-linux-gnu/4.6/../../../../i686-linux-gnu/include"
ignoring duplicate directory "/usr/include/i386-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/i386-linux-gnu
/usr/lib/gcc/i686-linux-gnu/4.6/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6/include-fixed
/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
COMPILER_PATH=/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i686'
$
***************************************

Running "gcc -x c++ -E -v -" gives me the following:

***************************************
$ gcc -x c++ -E -v -
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i686'
/usr/lib/gcc/i686-linux-gnu/4.6/cc1plus -E -quiet -v -imultilib . -imultiarch i386-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=i686 -fstack-protector
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i686-linux-gnu/4.6/../../../../i686-linux-gnu/include"
ignoring duplicate directory "/usr/include/i386-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/i386-linux-gnu
/usr/include/c++/4.6
/usr/include/c++/4.6/i686-linux-gnu/.
/usr/include/c++/4.6/backward
/usr/lib/gcc/i686-linux-gnu/4.6/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6/include-fixed
/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
COMPILER_PATH=/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i686'
$
***************************************

Notice that "#include<...> search" has "/usr/include" in the list, for
both c and c++. Now I do a ls -l /usr/include/features.h, and I see
the following:

***************************************

$ ls -l /usr/include/features.h
-rw-r--r-- 1 root root 13084 Oct 5 16:34 /usr/include/features.h
$

***************************************

So I'm confused! Why can't the header file be found by the compiler
when making clang/compiler-rt?

Thanks,
Michael

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Michael Young

unread,
Feb 23, 2013, 11:03:56 PM2/23/13
to llv...@cs.uiuc.edu

I'm continuing this here in llvm-dev since the thread was started here,
but, in hindsight, it may have been better in cfe-dev, because the
problem seems to be related to clang.

I turned on "verbose" mode in make (VERBOSE=1 TOOL_VERBOSE=1) and found
that it is clang, not gcc, that is being used at this point in the make.
Based on the command issued (particularly with the --sysroot options),
I surmised that I'm picking up the wrong <mman.h>. The one in the
specified sysroot dir doesn't have a #include <features.h> (which is not
being found). So where is the mman.h being picked up??? Well, I find
it at /usr/include/i386-linux-gnu/sys, and, lo and behold, there is a
#include <features.h> at line 23, just at the location reported with
the error. And why is clang looking in "/usr/include/i386-linux-gnu"?
Because I had defined the C_INCLUDE_PATH environment variable with this
directory. When I reset this (and LIBRARY_PATH and CPLUS_INCLUDE_PATH)
to empty, I can proceed with the make.

Here's the problem - I have to have these environment variables defined
to allow gcc to work (without them, I can't even get through configure).
Ubuntu 11.10, 12.04, and perhaps later versions, put things in
"non-standard" locations, and this is the workaround - see
"http://gcc.gnu.org/ml/gcc/2012-02/msg00314.html" for details. That's
fine, but clang apparently uses these environment variables, too, and,
based on my results, I really don't think I want clang to pick these
up, at least not when clang has sysroot specified (as it is in the
make).

Unfortunately, the make later reverts back to using gcc (actually g++),
and it breaks again without the environment variables being defined
with the appropriate directories.

So is there an easy way to have gcc/g++ use these variables and not
clang? That should allow me to get through a build (make) cleanly.

Thanks,
Mike

Duncan Sands

unread,
Feb 26, 2013, 3:57:25 AM2/26/13
to llv...@cs.uiuc.edu
Hi Michael, you don't need compiler-rt to use clang. If you don't need it, I
suggest you don't bother building it.

Ciao, Duncan.

Michael Young

unread,
Feb 26, 2013, 9:19:32 AM2/26/13
to llv...@cs.uiuc.edu

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_PATH=
export 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

Michael Young

unread,
Feb 26, 2013, 10:31:41 AM2/26/13
to bald...@free.fr, llv...@cs.uiuc.edu

>
> Hi Michael, you don't need compiler-rt to use clang. If you don't need it, I
> suggest you don't bother building it.
>

Thanks for the advice.

I realize that clang doesn't need it, but I was going to investigate
compiler-rt for use in my own project(s), so I was compiling the works.
That may be a little premature, since I still have a lot to grok with
just LLVM, where my primary interest lies (specifically, in developing
a compiler).  I'm interested in clang because, thus far, amongst all
the compilers I know of, it has the best C++11 support.

Anyway, I seem to have found a build setup that works.

Thanks,
   Mike

Marc J. Driftmeyer

unread,
Feb 26, 2013, 5:32:32 PM2/26/13
to llv...@cs.uiuc.edu
Michael,

This behavior repeats itself on Debian Linux when I update GCC 4.7.2 to anything above the current pathways of the Sid branch release of GCC/Libstdc++ collection.

I've tested it twice with their latest updates for the 4.7.2 branch in Experimental and nothing on there end changes and from prior issues with this someone either has to update the pathways for these directory structures in LLVM/Clang or don't even bother first building LLVM/Clang with anything newer than

gcc-4.7.2-5 and all that includes with gcc-4.7-base, etc.

This is fine with me because I'd rather let Debian muck with all the llvm-toolchain-3.2 attempts they continue to try:

http://qa.debian.org/developer.php?login=pkg-ll...@lists.alioth.debian.org

before I update any release from them. I've just stuck with 4.7.2-5 and building trunk once and then configuring with cmake the necessary paths in the newest trunk to make everything build under /usr/local

- Marc Driftmeyer
--
Marc J. Driftmeyer
Email :: m...@reanimality.com
Web :: http://www.reanimality.com
Cell :: (509) 435-5212
mjd.vcf

Michael Young

unread,
Apr 13, 2013, 11:10:43 AM4/13/13
to llv...@cs.uiuc.edu
Following up just in case anyone is looking at this in the future in an attempt to solve a similar issue.
I can now successfully build gcc-4.8.0 (and llvm/compiler-rt/clang/test-suite 3.2) on Ubuntu 12.04 (x86, 32-bit, desktop edition) without setting any environment variables (C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, LIBRARY_PATH).  So the ideal solution is to not use a locally built gcc-4.7 on Ubuntu 12.04, especially to build LLVM 3.2.
  - Michael
Reply all
Reply to author
Forward
0 new messages