https://bugs.llvm.org/show_bug.cgi?id=34396

            Bug ID: 34396
           Summary: llvm-ar accidentally provides the wrong exit code when
                    given an invalid command
           Product: tools
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-ar
          Assignee: unassignedb...@nondot.org
          Reporter: mvogels...@rocketmail.com
                CC: llvm-bugs@lists.llvm.org

llvm-ar parses its arguments, and if it can't make sense of them it shows it's
help message and exits. In particular llvm-ar calls `show_help` ( see it at
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-ar/llvm-ar.cpp#L169
)
'''
show_help(const std::string &msg) {
  errs() << ToolName << ": " << msg << "\n\n";
  cl::PrintHelpMessage();
  exit(1);
}
'''

llvm-ar dutifully tries to show some help and exit with a code indicating
error. Unfortunately, if one follows the `cl::PrintHelpMessage` function (found
at http://llvm.org/doxygen/CommandLine_8cpp_source.html#l02100) they'll find
that it ends up calling `exit(0)`. The exit(1) never gets reached. 

This became a problem for us because GHC takes the AR implementation its given
and runs it with a variety of arguments to see what it supports. It relies on
the exit code to determine success or failure.

I'm not sure what would be technically the most appropriate fix would be in the
context of the LLVM project. Would simply changing `show_help` to print out
something like "unknown command line argument: run llvm-ar with -help for usage
information" and then call `exit(0)` be fine?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to