[PATCH] D26944: Suppress -Wliblto warning when -flto is not present

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 21 15:29:07 PST 2016


rnk created this revision.
rnk added reviewers: mehdi_amini, thakis.
rnk added a subscriber: cfe-commits.

Without -flto, it's unlikely that users will experience LLVM version
skew. The system installation of libLTO should be able to handle any
pre-compiled LLVM bitcode from static archives.


https://reviews.llvm.org/D26944

Files:
  lib/Driver/Tools.cpp
  test/Driver/darwin-ld-lto.c


Index: test/Driver/darwin-ld-lto.c
===================================================================
--- test/Driver/darwin-ld-lto.c
+++ test/Driver/darwin-ld-lto.c
@@ -1,5 +1,3 @@
-// REQUIRES: system-darwin
-
 // Check that ld gets "-lto_library" and warnings about libLTO.dylib path.
 
 // RUN: mkdir -p %T/bin
@@ -12,12 +10,20 @@
 // LINK_LTOLIB_PATH: {{ld(.exe)?"}}
 // LINK_LTOLIB_PATH: "-lto_library"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %s \
+// Only warn if -flto is on the command line.
+//
+// RUN: %clang -target x86_64-apple-darwin10 -### %s -flto \
 // RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s -input-file %t.log
 //
 // LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead
 
+// Don't warn if -flto isn't present of -Wno-liblto is present.
+//
+// RUN: %clang -target x86_64-apple-darwin10 -### %s \
+// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s -input-file %t.log
+//
 // RUN: %clang -target x86_64-apple-darwin10 -### %s \
 // RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s -input-file %t.log
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8232,7 +8232,9 @@
     if (llvm::sys::fs::exists(LibLTOPath)) {
       CmdArgs.push_back("-lto_library");
       CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
-    } else {
+    } else if (D.isUsingLTO()) {
+      // Warn if we're using LTO with the system version of libLTO. It might not
+      // understand LLVM bitcode generated by our version of LLVM.
       D.Diag(diag::warn_drv_lto_libpath);
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26944.78797.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161121/33614f85/attachment.bin>


More information about the cfe-commits mailing list