[llvm] [llvm-objdump] Support --mcpu=help/--mattr=help without -d (PR #165661)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 01:11:07 PST 2025


================
@@ -3533,6 +3533,35 @@ commaSeparatedValues(const llvm::opt::InputArgList &InputArgs, int ID) {
   return Values;
 }
 
+static void mcpuHelp() {
+  Triple TheTriple;
+
+  if (!TripleName.empty()) {
+    TheTriple.setTriple(TripleName);
+  } else {
+    assert(InputFilenames.size());
+    Expected<OwningBinary<Binary>> OBinary = createBinary(InputFilenames[0]);
+    if (auto E = OBinary.takeError()) {
+      reportError(InputFilenames[0], "triple was not specified and could not "
+                                     "be inferred from the input file: " +
+                                         toString(std::move(E)));
+    }
+
+    Binary *Bin = OBinary->getBinary();
+    if (ObjectFile *Obj = dyn_cast<ObjectFile>(Bin))
+      TheTriple = Obj->makeTriple();
+    else
+      reportError(InputFilenames[0], "file format not recognized");
----------------
jh7370 wrote:

Test case is still missing (don't use an archive, since that's a planned extension and we don't want to have to modify the test case when support is added). Also, I'd say "input file is not an object file" or something to that effect, rather than "file format not recognized" because if it's successfully created a `Binary` from the input, LLVM knows what kind of input it is, it's just not a variety that can be converted to `ObjectFile`.

https://github.com/llvm/llvm-project/pull/165661


More information about the llvm-commits mailing list