Compiler-RT CLANG LLVM - gcc

I have GCC 4.1.2 and like to build CLANG / LLVM using this GCC compiler version ony. I need source to source translation library so that I can modify my existing source code for some requirement.
Initially I faced issues regarding usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found during LLVM / CLANG make. So in downloaded and build GCC 4.5.0 and installed at a local path. I found that libstdc++.so.6 of GCC 4.5.0 has GLIBCXX_3.4.9 version. Since I wanted to compile using GCC 4.1.2 I set my dynamic library path as:
setenv LD_LIBRARY_PATH /local/gcc-4.5.0/lib64:$LD_LIBRARY_PATH
And stated the make again after 'make clean'. Now that error did not occur.
However I am facing issues while compiling 'Compiler-RT' modules. I am not sure for which purpose Compiler-RT module is required but it seems LLVM and CLANG has compiled well.
Is it possible that I can exclude Compiler-RT from download , build and installation:
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
Build LLVM and Clang only
Is it right to set my shared library path to use libstdc++.so.6 of GCC 4.5.0 and is Compiler-RT is a madatory step to download and build it with CLANG / LLVM
I found this sample code here - do I require Compiler-RT - I don't see reference to same but just wanted to confirm?

Related

Targetting an older version of libstdc++ with recent GCC when cross-copiling to an embedded-linux ARM device

We need to find a cross-compilation toolchain for an ARM embedded linux target that satisfies the following criteria:
Kernel 3.17
GLIBC 2.18
Recent version of GCC is required to compile some third-party code
Those requirements brought me to generate a custom cross-compilation toolchain using crosstool-ng. I selected the min kernel version, min glibc version and it seemed to work well until I tried to compile code containing C++.
Because the new GCC is using a more recent libstdc++ than what is available on the target, the executable won't run and we get an error like this:
/usr/lib/libstdc++.so.6: version `CXXABI_1.3.9' not found
The code compiled fine with an older version of GCC.
Looking at the configuration options for crosstool-ng I didn't find anything that would let me change the min libstdc++ version, like for glibc.
Is there a way to target an older libstdc++ version without downgrading GCC?
Can I use the headers and libstdc++.so files from the target to replace the ones GCC is using when cross-compiling?

Version of GCC required to build cmake 3.X.Y

I'm trying to compile cmake version 3.0.2 on GCC 4.9.2 but I'm getting the error message
/home/DrNo/cmake-3.0.2/Bootstrap.cmk/cmake: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/DrNo/cmake-3.0.2/Bootstrap.cmk/cmake)
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
I've taken a look at the ABI strings(?) in libstdc++.so.6 and can't find GLIBCXX_3.4.15:
$ strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
I've tried cmake compiling versions 3.0.0, 3.0.1, 3.0.2 and 3.7.2 but all require GLIBCXX_3.4.15, so it looks like I'm going to have to upgrade my version of GCC on this system (CentOS), which I don't want to because I've built this project on another system (Ubuntu with prepackaged cmake 3.0.2) with GCC 4.9.2.
Is it possible to have two GCC installs. A more recent one to build cmake and GCC 4.9.2 to build the rest of the project.
I hope you managed to get rid of the problem i am just leaving this comment here as a future reference:
I did have a similar problem when compiling cmake version 3.10.0 on gcc4.1.2 . I looked at my LD_LIBRARY_PATH and saw that there was a path from a former gcc version.
I simply set it to the correct path something along the lines gcc_4.1.2/linux50_64/lib64 via setenv. Nifty trick I learned was using setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}/your/path/here: which basically appends your path to the everything inside LD_PATH_LIBRARY variable.

omp.h not found, OS X Yosemite not using newest gcc version

I am trying to build GraphChi on OS X Yosemite but get the following error:
fatal error: 'omp.h' file not found
From this question - How to include omp.h in OS X? - I learned that Yosemite uses Clang instead of gcc, which does not include omp.h.
$ which gcc
/usr/bin/gcc
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
Next, I installed gcc via Homebrew
$ brew info gcc
gcc: stable 4.9.2 (bottled)
http://gcc.gnu.org
/usr/local/Cellar/gcc/4.9.2_1 (1092 files, 177M)
Built from source with: --without-multilib
and updated $PATH to include the path to the new gcc version
$ echo $PATH
/usr/local/Cellar/gcc/4.9.2_1:usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
however, gcc -v and which gcc still point to the old version, and building GraphChi still doesn't work due to the missing omp.h file
Does anyone know what else I need to do?
Update
locate omp.h returned:
/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/lib/gcc/i686-apple-darwin11/4.2.1/include/omp.h
/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include/omp.h
my ~/.profile:
export PATH=/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include:/usr/local/Cellar/gcc/4.9.2_1/bin:usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH
I solved this with installing gcc with homebrew:
brew install gcc --without-multilib
and then building the source code with
CC=gcc-5 CXX=g++-5 cmake ..
CC=gcc-5 CXX=g++-5 make -j7
Once you have installed gcc-4.9 with homebrew, it will automatically be in your path. To use OpenMP, you just need to make sure you are using the newly installed gcc-4.9, and it will be able to find omp.h.
In the case of GraphChi, you will have to go change line 3 of the Makefile to be gcc-4.9. From there, running make should just work. They describe this in their README, but at least the version they describe is out of date https://github.com/GraphChi/graphchi-cpp#problems-compiling-on-mac.
clang does not support OpenMP yet. Also gcc by default links to Apple's LLVM clang compiler (not the GCC installed from brew).
Instead gcc-4.9 would link to GCC. I think if -fopenmp is specified omp.h is included automatically.
It is possible to manually build a version of clang with OpenMP support, see http://clang-omp.github.io
You shouldn't add the include path to PATH; instead, specify it as CFLAGS, including the -I option. You can export the CFLAGS variable, or set it on the fly.
Depending on how you compile things, you could do
CFLAGS=-I/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h gcc <whatever>
Of course, in this case you can specify it directly on the gcc command (as -I/usr/local/....), but the CFLAGS variable also works with configure (as configure often won't have an option to specify where it should look for specific include files); probably with make, or even for those installing a Python package: CFLAGS=-I... pip install <some-package>.
Other flags to consider are
CXXFLAGS: C++ specific pre-processor flags
LDFLAGS: linker specific flags (e.g. LDFLAGS=-L/some/path/... for linking with dynamic libraries).
CC: specify the C compiler to use. This is an easy way to avoid the built-in gcc alias for clang on OS X. Just use CC=/usr/local/bin/gcc-4 make or similar.
CXX: specify the C++ compiler to use.

Default compiler from llvm-clang to llvm-gcc42 (command line)

I'm trying to compile a project from the command line. The default compiler LLVM-clang and i need to compile with LLVM-gcc42. Switching a compiler in Xcode is really easy. However, on command line it seems to be more problematic. To my understanding "/usr/bin/cc" and "/use/bin/gcc" are used for pointing c/c++ compilers. I noticed that "cc" was linked to "clang" in same directory. So, i changed "cc" to point at "gcc". Did not helped. When i run
$ gcc -v
i get response
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.5.0
How do i change the clang to gcc?
My setup is:
MAC OS X 10.8.5
Xcode 4.6.2
Command line tools
EDIT 13.02.2014
The project is a QT project which uses mixture of third party c/c++ libraries. My task is to write a new objective C lib to it. The project is build with -spec macx-g++ parameter. The configuration scripts can be found /QTROOT/mkspecs/macx-g++ and /QTROOT/mkspecs/common. In g++-base.conf key variables are defined as:
QMAKE_CC = gcc
QMAKE_CXX = g++
Instead of changing links which can affect other programs use the full path to the llvm executables in your build script
e.g. if you have installed the command line tools
QMAKE_CC = /usr/bin/llvm-gcc-4.2
QMAKE_CXX = /usr/bin/llvm-g++-4.2
Okay, nailed the problem. Solution was simple. I deleted the old links from /usr/bin/gcc and /usr/bin/g++ and created new ones pointing to the proper compilers.
gcc -> /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2
and
g++ -> /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-g++-4.2

Building Qt 4.8.1 from src on MacOS using gcc 4.5

I have a question about building Qt SDK 4.8.1 using gcc on Mac. I need to use gcc 4.5 or higher, so I installed mp-gcc45 package using macports (so tried with mp-gcc47), selected this version of gcc, so
gcc -v
Says me that gcc version 4.5.4 (MacPorts gcc45 4.5.4_6)
So I downloaded QtSDK src from official site, configure it and there is an error at first step:
cc1plus: error: unrecognized command line option "-fconstant-cfstrings"
Maybe its stupid solution, but I remove this flags from configure file, so I get a error after make call:
g++: unrecognized option '-Xarch_x86_64'
Can you give me an advice, how to build Qt using this version of gcc?
Non-Apple gcc will never work with Qt of any version. Only Apple gcc recognizes those Apple flavored compiler options.
You are stuck with gcc 4.2 on Mac. There's no way around it.

Resources