From 6b57ae05e08029c54339421b9f39d8fb0015b28b Mon Sep 17 00:00:00 2001 From: Mehdi Amini <mehdi.amini@apple.com> Date: Mon, 21 Nov 2016 21:27:58 +0000 Subject: [PATCH] [LTO] Merge r285254 into 3.9.1 (Darwin clang driver always pass -lto_library) See: https://llvm.org/PR30840 git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_39@287579 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 30 +++++++++++++++--------------- test/Driver/darwin-ld-lto.c | 9 ++++----- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 31d43601845..6821addfe4a 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -7637,22 +7637,22 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, CmdArgs.push_back("-object_path_lto"); CmdArgs.push_back(TmpPath); } + } - // Use -lto_library option to specify the libLTO.dylib path. Try to find - // it in clang installed libraries. If not found, the option is not used - // and 'ld' will use its default mechanism to search for libLTO.dylib. - if (Version[0] >= 133) { - // Search for libLTO in <InstalledDir>/../lib/libLTO.dylib - StringRef P = llvm::sys::path::parent_path(D.getInstalledDir()); - SmallString<128> LibLTOPath(P); - llvm::sys::path::append(LibLTOPath, "lib"); - llvm::sys::path::append(LibLTOPath, "libLTO.dylib"); - if (llvm::sys::fs::exists(LibLTOPath)) { - CmdArgs.push_back("-lto_library"); - CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); - } else { - D.Diag(diag::warn_drv_lto_libpath); - } + // Use -lto_library option to specify the libLTO.dylib path. Try to find + // it in clang installed libraries. If not found, the option is not used + // and 'ld' will use its default mechanism to search for libLTO.dylib. + if (Version[0] >= 133) { + // Search for libLTO in <InstalledDir>/../lib/libLTO.dylib + StringRef P = llvm::sys::path::parent_path(D.getInstalledDir()); + SmallString<128> LibLTOPath(P); + llvm::sys::path::append(LibLTOPath, "lib"); + llvm::sys::path::append(LibLTOPath, "libLTO.dylib"); + if (llvm::sys::fs::exists(LibLTOPath)) { + CmdArgs.push_back("-lto_library"); + CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); + } else { + D.Diag(diag::warn_drv_lto_libpath); } } diff --git a/test/Driver/darwin-ld-lto.c b/test/Driver/darwin-ld-lto.c index 23e006a0185..d244f988df7 100644 --- a/test/Driver/darwin-ld-lto.c +++ b/test/Driver/darwin-ld-lto.c @@ -3,22 +3,21 @@ // Check that ld gets "-lto_library" and warnings about libLTO.dylib path. // RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -mlinker-version=133 -flto 2> %t.log -// RUN: cat %t.log -// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s < %t.log +// RUN: -ccc-install-dir %T/bin -mlinker-version=133 2> %t.log +// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log // // LINK_LTOLIB_PATH: {{ld(.exe)?"}} // LINK_LTOLIB_PATH: "-lto_library" // RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -flto 2> %t.log +// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log // RUN: cat %t.log // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s < %t.log // // LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead // RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto -flto 2> %t.log +// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 2> %t.log // RUN: cat %t.log // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s < %t.log // -- GitLab