Index: llvm-toolchain-snapshot_3.4~svn184409/clang/lib/Driver/ToolChains.cpp =================================================================== --- llvm-toolchain-snapshot_3.4~svn184409/clang/lib/Driver/ToolChains.cpp (revision 184409) +++ llvm-toolchain-snapshot_3.4~svn184409/clang/lib/Driver/ToolChains.cpp (working copy) @@ -2328,6 +2328,13 @@ addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths); addPathIfExists(SysRoot + "/usr/lib/../" + Multilib, Paths); + // In Debian we install LLVM lib with version string + // /usr/lib/llvm-X.Y/lib/LLVMGold.so + if (IsDebian(Distro)) { + addPathIfExists(SysRoot + "/usr/lib/llvm-" + CLANG_VERSION_STRING + "/lib/", + Paths); + } + // Try walking via the GCC triple path in case of multiarch GCC // installations with strange symlinks. if (GCCInstallation.isValid()) Index: llvm-toolchain-snapshot_3.4~svn184409/clang/lib/Driver/Tools.cpp =================================================================== --- llvm-toolchain-snapshot_3.4~svn184409/clang/lib/Driver/Tools.cpp (revision 184409) +++ llvm-toolchain-snapshot_3.4~svn184409/clang/lib/Driver/Tools.cpp (working copy) @@ -6147,6 +6147,14 @@ if (D.IsUsingLTO(Args) || Args.hasArg(options::OPT_use_gold_plugin)) { CmdArgs.push_back("-plugin"); std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so"; + if ( ! llvm::sys::fs::exists(Plugin)) { + // Plugin is not in driver-based relative path, try system libs + // on Debian for instance + std::string PluginSystem = ToolChain.GetFilePath("LLVMgold.so"); + if (llvm::sys::fs::exists(PluginSystem)){ + Plugin = PluginSystem; + } + } CmdArgs.push_back(Args.MakeArgString(Plugin)); // Try to pass driver level flags relevant to LTO code generation down to