From 78e1ea3cc07f0a74ee14bcdaba371f67444ea14d Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 23 Nov 2016 18:00:06 +0000 Subject: [LTO] Merge r287685 into the 3.9.1 branch, darwin: Unconditionally pass -lto_library, remove -Wliblto warning. See: https://llvm.org/bugs/PR31120 llvm-svn: 287784 --- clang/include/clang/Basic/DiagnosticDriverKinds.td | 2 -- clang/lib/Driver/Tools.cpp | 16 ++++++++-------- clang/test/Driver/darwin-ld-lto.c | 16 ++++------------ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 6b8db69..0a9b348 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -159,8 +159,6 @@ def err_drv_bitcode_unsupported_on_toolchain : Error< "-fembed-bitcode is not supported on versions of iOS prior to 6.0">; def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup; -def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead">, - InGroup; def warn_drv_optimization_value : Warning<"optimization level '%0' is not supported; using '%1%2' instead">, InGroup; def warn_ignored_gcc_optimization : Warning<"optimization flag '%0' is not supported">, diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 0795b15..270ed0a 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -7640,20 +7640,20 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, } // 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. + // it in clang installed libraries. ld64 will only look at this argument + // when it actually uses LTO, so libLTO.dylib only needs to exist at link + // time if ld64 decides that it needs to use LTO. + // Since this is passed unconditionally, ld64 will never look for libLTO.dylib + // next to it. That's ok since ld64 using a libLTO.dylib not matching the + // clang version won't work anyways. if (Version[0] >= 133) { // Search for libLTO in /../lib/libLTO.dylib StringRef P = llvm::sys::path::parent_path(D.Dir); 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); - } + CmdArgs.push_back("-lto_library"); + CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); } // Derived from the "link" spec. diff --git a/clang/test/Driver/darwin-ld-lto.c b/clang/test/Driver/darwin-ld-lto.c index d244f98..6b9b79b 100644 --- a/clang/test/Driver/darwin-ld-lto.c +++ b/clang/test/Driver/darwin-ld-lto.c @@ -1,6 +1,6 @@ // REQUIRES: system-darwin -// Check that ld gets "-lto_library" and warnings about libLTO.dylib path. +// Check that ld gets "-lto_library". // RUN: %clang -target x86_64-apple-darwin10 -### %s \ // RUN: -ccc-install-dir %T/bin -mlinker-version=133 2> %t.log @@ -9,16 +9,8 @@ // LINK_LTOLIB_PATH: {{ld(.exe)?"}} // LINK_LTOLIB_PATH: "-lto_library" +// Also pass -lto_library even if the file doesn't exist; if it's needed at +// link time, ld will complain instead. // RUN: %clang -target x86_64-apple-darwin10 -### %s \ // 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 2> %t.log -// RUN: cat %t.log -// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s < %t.log -// -// LINK_LTOLIB_PATH_NOWRN-NOT: warning: libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead +// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log -- cgit v1.1