Relink problem building LLVM 7.0.0 rc1 with Cmake, Ninja and gcc 7.1

I have previously built LLVM and Clang 6.0.0 with Cmake, Ninja and gcc 7.1

I am using cmake 3.6.2 and binutils 2.22 with ninja 1.8.2 (updated from 1.7.2 for the 6.0.0 build).

The underlying linux is Ubuntu 12.04, with the gcc 7.1 installed in /opt

My commands for Cmake are these:

/opt/cmake/bin/cmake -GNinja
-DCMAKE_INSTALL_PREFIX=/home/fletcher/LLVM/llvm-7.0.rc1/local -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_TARGETS_TO_BUILD=“host” -DLLVM_PARALLEL_LINK_JOBS=1 -DCMAKE_EXE_LINKER_FLAGS=“-Xlinker -R/opt/gcc-7.1/lib64 -L/opt/gcc-7.1/lib64” …/llvm

I have had several problems. Some with versions of cuda I have solved for now by excluding openmp from the build.

After this the build failed when linking a library as follows

FAILED: lib/clang/7.0.0/lib/linux/libclang_rt.fuzzer_no_main-x86_64.a
–localize-hidden: not found

I have traced this to the fact that the file CmakeCache.txt omits the following lines when built for 7.0.0 which are in the same file for 6.0.0 and the result is that objcopy is not found. --localize_hidden is an argument to objcopy.

//Path to a program.

//Path to a program.

//Path to a program.

//Path to a program.

When I restore these lines to CmakeCache.txt the build of 7.0.0 proceeds to completion.

Install now fails with the following message:

file INSTALL cannot find

This is because the location does not exist. Again, comparing with 6.0.0, there the file to be installed was found from /home/fletcher/LLVM/llvm-6.0.distrib/build/lib/libPolly.a

There is a file in the corresponding location in 7.0.0. It is not being used and instead a relinked file is looked for.

It seems that the relink process has not been organised.

I have not looked beyond LVMPolly as the install process will not go any further.

I hope that you can identify what the problem is.

Thank you

John Fletcher

I have never seen a CMakeRelink.dir in my build directory. You might
try disabling Polly if it is the only cause if the error:



Thank you for this. I reran the task with these commands added. This time the install ran much further and failed with a similar failure for

  file INSTALL cannot find

Fortunately this is near the end of the install process and I have a working system for clang, which is what I was looking for.

I think this means that this is an issue for llvm-dev, which I am not subscribed too.

Would someone please forward this to llvm-dev.

It seems to me that there are issues from changes in configuration from 6.0.0 to 7.0.0 which are causing these problems.



Doing some more digging, there seems to be an issue between Cmake and Ninja. The Relinking problem has surfaced in a number of different contexts over several years.


there is a long discussion which includes this:

Re 0013934:0034738: Yes. CMake by default links binaries so they can run in the build tree, so their RPATH points at build tree locations. This is not desirable for installation so CMake needs to change the RPATH to a different value (or remove it) during installation. For ELF CMake knows how to edit the binaries as they are installed. For other binary formats that support RPATH CMake needs to re-run the linker with the new RPATH options. That is done during the "preinstall" step which is a dependency of "make install" and is missing from "ninja install".

FYI, one can use CMAKE_BUILD_WITH_INSTALL_RPATH to tell CMake to put the install-tree RPATH in the build-tree binaries so that no relinking or editing is needed on installation (at the cost of not easily running in the build tree):

CMake - Cross Platform Make [^]
CMake - Cross Platform Make [^]

I don't know enough about this to comment further.

This is not the only problem I have reported. It maybe that the combination of Cmake and Ninja is just not suitable at the moment.