[PATCH] D24357: Report original emulation name in "unknown emulation" error

Ed Maste via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 10:59:11 PDT 2016


emaste created this revision.
emaste added reviewers: ruiu, rafael, davide.
emaste added a subscriber: llvm-commits.
emaste added a project: lld.

We strip a trailing `_fbsd` from emulation names, but if the result is not a valid emulation the error was somewhat confusing:
```
% ld.lld -m elf_amd64_fbsd
unknown emulation: elf_amd64
```
Use the unmodified emulation name in error messages.

https://reviews.llvm.org/D24357

Files:
  ELF/Driver.cpp

Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -54,7 +54,8 @@
 }
 
 // Parses a linker -m option.
-static std::pair<ELFKind, uint16_t> parseEmulation(StringRef S) {
+static std::pair<ELFKind, uint16_t> parseEmulation(StringRef Emul) {
+  StringRef S = Emul;
   if (S.endswith("_fbsd"))
     S = S.drop_back(5);
 
@@ -77,9 +78,9 @@
 
   if (Ret.first == ELFNoneKind) {
     if (S == "i386pe" || S == "i386pep" || S == "thumb2pe")
-      error("Windows targets are not supported on the ELF frontend: " + S);
+      error("Windows targets are not supported on the ELF frontend: " + Emul);
     else
-      error("unknown emulation: " + S);
+      error("unknown emulation: " + Emul);
   }
   return Ret;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24357.70727.patch
Type: text/x-patch
Size: 788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160908/bddceecd/attachment.bin>


More information about the llvm-commits mailing list