clang 3.8 on CentOS 6.9

Issues related to applications and software problems
Mitmischer
Posts: 1
Joined: 2017/08/13 08:09:58

clang 3.8 on CentOS 6.9

Postby Mitmischer » 2017/08/13 09:31:29

Hello,

I am experiencing issues with setting up clang on CentOS 6.9. The machine I work on is a university machine, as such I cannot install any additional software.

Compiling clang works just fine. However, clang cannot reliably build software. I need to build shadow ( https://shadow.github.io/ ) and one of the errors I get, is:

Code: Select all

In file included from [...]/shadow/src/plugin/llvm-hoist-pass/HoistGlobals.cpp:19:
In file included from ~/.shadow/include/llvm/Pass.h:381:
In file included from ~/.shadow/include/llvm/PassSupport.h:27:
In file included from ~/.shadow/include/llvm/PassRegistry.h:20:
In file included from ~/.shadow/include/llvm/ADT/DenseMap.h:17:
In file included from ~/.shadow/include/llvm/ADT/DenseMapInfo.h:17:
In file included from ~/.shadow/include/llvm/ADT/ArrayRef.h:13:
In file included from ~/.shadow/include/llvm/ADT/Hashing.h:49:
In file included from ~/.shadow/include/llvm/Support/Host.h:17:
In file included from ~/.shadow/include/llvm/ADT/StringMap.h:18:
In file included from ~/.shadow/include/llvm/Support/Allocator.h:24:
In file included from ~/.shadow/include/llvm/ADT/SmallVector.h:29:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/memory:83:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/shared_ptr.h:146:24: error: cannot use typeid with -fno-rtti
      { return __ti == typeid(_Deleter) ? &_M_del._M_del : 0; }


Note that a c++-4.4.7-stdlib is included. This is not correct and gcc actually uses a newer stdlib:

Code: Select all

$ `gcc -print-prog-name=cc1plus` -v
[ ... ]
#include "..." search starts here:
#include <...> search starts here:
  [...]
  /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64- redhat-linux/4.8.2/../../../../include/c++/4.8.2
  /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64- redhat-linux/4.8.2/../../../../include/c++/4.8.2/x86_64- redhat-linux
  /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64- redhat-linux/4.8.2/../../../../include/c++/4.8.2/backward
  /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64- redhat-linux/4.8.2/include
  /usr/local/include
  /opt/rh/devtoolset-2/root/usr/include
  /usr/include


clang only finds the old stdlib...

Code: Select all

$ clang -v
clang version 3.8.0 (tags/RELEASE_380/final)
[...]
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/3.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64


... and, quite surprisingly, it has a point:

Code: Select all

-bash-4.1$ ls /usr/lib/gcc/x86_64-redhat-linux/
3.4.6  4.4.4  4.4.7


Next, I tried installing a gcc on my own, as described here: https://llvm.org/docs/GettingStarted.ht ... -toolchain , however without any apparent effect. I can point clang to my self-built gcc and it will use it for building, but still clang will use the system's include directories for compilation.

I also tried building llvm's libcxx along with clang, but that didn't work either (I will post the error if you are interested, but I have to build llvm again for this.)

On the Internet, one finds hacks to change stdlib-include paths for gcc, but that broke compilation for hello wold.. I am a bit clueless now. I think, the easiest way would be to get my self-compiled gcc to use its own stdlib and not the system's one, but I don't know how this will work.

Summing up, I need to get clang 3.8 working and I am limited to installing software myself (no root-privileges). Also I have no experience with CentOs, so I cannot tell if our CentOS is misconfigured. I'd be glad for any help on this!

User avatar
TrevorH
Forum Moderator
Posts: 20646
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: clang 3.8 on CentOS 6.9

Postby TrevorH » 2017/08/13 10:47:09

Your newer gcc is an SCL. Did you use scl enable ... to start the command prompt you are using for this?
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

chemal
Posts: 372
Joined: 2013/12/08 19:44:49

Re: clang 3.8 on CentOS 6.9

Postby chemal » 2017/08/13 17:07:21

Either type

Code: Select all

clang -gcc-toolchain /opt/rh/devtoolset-2/root/usr ...
or use a more recent version of clang that knows about devtoolsets.