[PATCH] D71030: Tighten the check for Tool name ( ar, nm, dlltool, lib)

Khem Raj via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 12:06:49 PST 2019


raj.khem created this revision.
Herald added subscribers: llvm-commits, rupprecht, dexonsmith, kristof.beyls, inglorion.
Herald added a project: LLVM.

This helps in creating canonical names for cross tool versions which may contain lib in their name. In Yocto this is common when creating multilib versions that lib32/lib/lib64 is added to canonical name to indicate multilib variant. This fails if we do not check the toolname to be at the end of string.

In multilib(lib32) case, the arm-pokymllib32-linux-gnueabi-llvm-ar (${TARGET_PREFIX}llvm-ar) gives:
qc: no such file or directory

Which is because when the llvm-ar symbol link's name contains "lib", it would be considered as llvm-lib:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71030

Files:
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -1179,16 +1179,16 @@
   llvm::InitializeAllAsmParsers();
 
   Stem = sys::path::stem(ToolName);
-  if (Stem.contains_lower("dlltool"))
+  if (Stem.endswith_lower("dlltool"))
     return dlltoolDriverMain(makeArrayRef(argv, argc));
 
-  if (Stem.contains_lower("ranlib"))
+  if (Stem.endswith_lower("ranlib"))
     return ranlib_main(argc, argv);
 
-  if (Stem.contains_lower("lib"))
+  if (Stem.endswith_lower("lib"))
     return libDriverMain(makeArrayRef(argv, argc));
 
-  if (Stem.contains_lower("ar"))
+  if (Stem.endswith_lower("ar"))
     return ar_main(argc, argv);
   fail("not ranlib, ar, lib or dlltool");
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71030.232188.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191204/828b96ff/attachment.bin>


More information about the llvm-commits mailing list