Install LLVM on CentOS-5

    技术2022-05-20  36

    Here's some tips of installing LLVM, CLANG and LLVM-GCC on CentOS computer:

    I download the newst version llvm (version 2.8), and so are clang and llvm-gcc, the installation mostly followed the instructions on the official website: http://llvm.org/docs/GCCFEBuildInstrs.html. 

    I installed llvm first:

     

    1) Unpack the compress file llvm-2.8.tgz and clang-2.8.tgz, put clang source file in llvm-2.8/tools, so clang will be build with llvm automatically, and create an new directory for stroring object files and an extra directory for installing binary files. That's to say:

    MAKE_DIR: $SRC_PATH/configure --prefix=$INSTALL_DIR --disable-optimized ......

         MAKE_DIR: make; make install

     

    2) The most difficult thing is building llvm-gcc.

    firstly, I installed llvm-gcc from source code, just follow the steps above like installing llvm, remember to create an new directory for storing object files, while you can still use the old directory for installing binary files.But building failed, the errors are something like: force_align_functions_log undefined or void restore(void) used but undefined, and there are several other errors, so it seems building from source code is not gonna working.

    secondly, I downloaded the binary file directly, setup is very easy: add llvm-gcc binary path to .bashrc and add set the LD_LIBRARY_PATH as "llvm-gcc/lib", but when I tested, error appeared: cann't find GLIBC_2.7. That means the llvm-gcc binary is built with a higher glibc version than the version on CentOS(which is version 2.5 actually), so I tried to update glibc by yum, but failed, and download glibc-2.7.tar.gz, while building from souce was also unsuccessful. Finally I found the reason, it seems I need to update the kernel, the followinig is cited from: http://www.held.org.il/blog/2008/03/glibc-27-on-centos-rhel-5/

    "glibc 2.7 introduces a new flag to open() syscall, called O_CLOEXEC.The official redhat 2.6.18 kernel (even of version 5.1) doesn’t support it, and returns errors (in strace it looks like open() returns unknown error 530). So.. just try not to use glibc 2.7 on RedHat, until they support it. If you want an adventure,this kernel seems to do the job.. "

     

    So, It seems I need to update the kernel or use a lower llvm version, but maybe there is a better solution which I stilled have no idea, expecting that cause the installation was not completed yet.

     

     


    最新回复(0)