[PATCH] Use GCC_INSTALL_PREFIX for rpath if set.

This way, an LLVM compiled after setting GCC_INSTALL_PREFIX will work correctly
if you don't want to install LLVM into the GCC_INSTALL_PREFIX.

This looks like it would remove the origin/…/lib RPATH which would break finding libraries related to Clang such as libc++?

It makes sense to add the GCC install prefix to the RPATH though. I wonder, should we try to do something about the lib vs. lib{32,64} business? I don’t know that either of these does the right thing there.

The behavior of automatically detecting libraries installed in the same prefix feels like magic to me anyway. Perhaps it would be better to have project-level variables for specifying the path to them individually? The default value for them could remain as origin/…/lib which would keep from breaking things.

This patch just prepends the gcc install prefix to the rpath rather than
overriding it. It also uses the LLVM_LIBDIR_SUFFIX under the assumption that if
you want llvm to install to lib{32,64} that you also installed gcc under that
directory.

This way, an LLVM compiled after setting GCC_INSTALL_PREFIX will work correctly
if you don't want to install LLVM into the GCC_INSTALL_PREFIX.

I’m pretty hesitant to change this. We haven’t really had any complaints and it makes several scenarios “just work”. I’m sympathetic to your point, just not yet 100% convinced of what the change should be.

I would separate the LLVM_LIBDIR_SUFFIX change out. If we want to go that route, it should be applied both to the install rpath and to the GCC one. It seems unambiguously better for the install rpath, and probably better for the GCC one. But still, separate patch. Adding the GCC rpath seems like a good first step, feel free to commite.

I do depend on $ORIGIN/../lib.

This makes sure that a shared build of llvm find the correct libraries
both in the build and the install directory. It also means that the
install directory is relocatable.

Cheers,
Rafael