Compiling llvm and Clang on Linux

Hello all,
I am new to this mailing list so I hope this is the right place to post the
following question.

We are considering using Clang front end for our tool. I tried to compile
LLVM
(using configure followed by make from the llvm top directory) on LINUX
X86 with gcc 4.1.2.

I got several compilation error messages of the form

/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c+
+/4.1.2/i386-redhat-linux/bits/gthr-default.h:117:1: error:
      weakref declaration must have internal linkage
__gthrw(pthread_mutexattr_destroy)

Could you guide me on how to resolve these errors?
I downloaded the sources from the web page (not from SVN).
Thanks,
Sitvanit

Sitvanit Ruah
Formal Verification Group
IBM Haifa Research Laboratory

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] On Behalf Of Sitvanit Ruah
Subject: [LLVMdev] Compiling llvm and Clang on Linux

We are considering using Clang front end for our tool. I tried to compile
LLVM (using configure followed by make from the llvm top directory) on
LINUX X86 with gcc 4.1.2.

4.1.2 is known to be a bit flakey:
http://llvm.org/docs/GettingStarted.html#brokengcc

Since that version of gcc is over five years old, you might want to try something a bit newer.

- Chuck

THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

Hi Sitvanit,

We are considering using Clang front end for our tool. I tried to compile
LLVM
(using configure followed by make from the llvm top directory) on LINUX
X86 with gcc 4.1.2.

  I believe the GCC you're using is too old/buggy to compile LLVM/Clang,
please check [1].

HTH,
chenwj

[1] http://llvm.org/docs/GettingStarted.html#requirements

Hi,

According to http://llvm.org/docs/GettingStarted.html#brokengcc FCC 4.1.2 is broken on RedHat. You might have to upgrade your version there.

It's undocumented FAQ, if you are using RHEL5 (or clone).

  - install gcc44-c++
  - Build with CC=gcc44 CXX=g++44
  - You may need "CC=clang -std=gnu89" to use clang with its glibc.

Have fun!

ps. AFAIK, clang can be built more easily on centos6.

...Takumi

Thanks for the information.

I am running on a machine on which gcc44 is installed but whose default
installation is 4.1.2.

I ran
../llvm/configure CC=gcc44 CXX=g++44
make

and still got the same error (I checked and CC=gcc44 and CXX=g++44 now in
build/Makefile.config)..
I tried also

../llvm/configure CC=gcc44 CXX=g++44 --include_dir=<gcc44 include dir>

but it didn't help either.

I couldn't find in the gcc44 directories the the file gthr-default.h, on
which the error is issued.
The error is issued while compiling the line line #include <algorithm>
in llvm/projects/compiler-rt/lib/asan/asan_posix.cc

the line is preceded by the comment
// Should not add dependency on libstdc++

Below are the gcc44 directories installed on the machine. Do you know what
else is needed in order to resolve the problem?

Thanks,
Sitvanit

/usr/bin/gcc44
/usr/bin/gcov44
/usr/bin/i386-redhat-linux6E-gcc44
/usr/lib/gcc
/usr/lib/gcc/i386-redhat-linux6E
/usr/lib/gcc/i386-redhat-linux6E/4.4.6
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtbegin.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtbeginS.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtbeginT.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtend.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtendS.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtfastmath.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtprec32.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtprec64.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/crtprec80.o
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/abmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/ammintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/avxintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/bmiintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/bmmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/cpuid.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/cross-stdarg.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/emmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/float.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/fma4intrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/immintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/iso646.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/limits.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/lwpintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/mm3dnow.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/mm_malloc.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/mmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/nmmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/omp.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/pmmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/popcntintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/smmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/stdarg.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/stdbool.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/stddef.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/stdfix.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/syslimits.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/tbmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/tmmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/unwind.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/varargs.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/wmmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/x86intrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/xmmintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/include/xopintrin.h
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libcloog.so.0
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgcc.a
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgcc_eh.a
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgcc_s.so
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgcov.a
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgomp.a
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgomp.so
/usr/lib/gcc/i386-redhat-linux6E/4.4.6/libgomp.spec
/usr/libexec/gcc
/usr/libexec/gcc/i386-redhat-linux6E
/usr/libexec/gcc/i386-redhat-linux6E/4.4.6
/usr/libexec/gcc/i386-redhat-linux6E/4.4.6/cc1
/usr/libexec/gcc/i386-redhat-linux6E/4.4.6/collect2
/usr/share/doc/gcc44-4.4.6
/usr/share/doc/gcc44-4.4.6/COPYING
/usr/share/doc/gcc44-4.4.6/COPYING.LIB
/usr/share/doc/gcc44-4.4.6/COPYING3
/usr/share/doc/gcc44-4.4.6/COPYING3.LIB
/usr/share/doc/gcc44-4.4.6/ChangeLog-1997.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-1998.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-1999.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2000.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2001.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2002.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2003.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2004.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2005.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2006.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2007.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog-2008.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.dataflow.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.lib.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.ptr.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.tree-ssa.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.tuples.bz2
/usr/share/doc/gcc44-4.4.6/ChangeLog.vta.bz2
/usr/share/doc/gcc44-4.4.6/README.Portability

Sitvanit Ruah
Formal Verification Group
IBM Haifa Research Laboratory
Tel: 972-4-828-1249

Hi,

I ran
../llvm/configure CC=gcc44 CXX=g++44
make

and still got the same error (I checked and CC=gcc44 and CXX=g++44 now in
build/Makefile.config)..

is it exactly the same error? The original error referred to gcc-4.1 header
files. Does the new error still refer to gcc-4.1 header files, or is it now
talking about gcc-4.4 header files?

Ciao, Duncan.

Yes, it is the same error referring to 4.1.2.

/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c+
+/4.1.2/i386-redhat-linux/bits/gthr-default.h:114:1: error: weakref
declaration must have internal
      linkage
__gthrw(pthread_key_delete)

There are several such errors.

Sitvanit Ruah
Formal Verification Group
IBM Haifa Research Laboratory
Tel: 972-4-828-1249

I couldn’t find in the gcc44 directories the the file gthr-default.h, on
which the error is issued.
The error is issued while compiling the line line #include
in llvm/projects/compiler-rt/lib/asan/asan_posix.cc

FYI: we’ve just got rid of #include in llvm trunk for an unrelated reason.

the line is preceded by the comment
// Should not add dependency on libstdc++

There was no contradiction.
The parts we were using were completely implemented in the STL headers and did not cause a link-time dependency on libstdc++.
Anyway, this code is gone now.

–kcc