<div dir="ltr"><div>I agree with others that the a.out behaviour is weird (I've even thought this about the linker output being called a.out since I started programming, but perhaps that's a different story). The use-case I can imagine is something like:</div><div><br></div><div>$ ld.lld test.o</div><div>$ llvm-objdump -d</div><div><br></div><div>I.e. using a tool immediately after generating the linker output. However, I don't think this is likely actually done by anybody, and I think it's probably safe to change the behaviour here. I'd rather be universal across the tools (e.g. always read from stdin) than do this frankly. An error message about a missing input file might be nice in some cases (llvm-readelf, llvm-objdump, llvm-nm), but I think we definitely want to support the option of stdin redirection if nothing else but for test purposes. If it's complicated to achieve both the error under non-redirection cases, and no error in redirection cases then I'd prefer the latter.</div><div><br></div><div>Regards,</div><div><br></div><div>James<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 26 Jun 2019 at 08:28, Alex Brachet-Mialot via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Sounds good, I'll work on removing these in favor of defaulting to stdin then?<br></div><div><br></div><div>> I think it would be much friendlier to just print "file or pipe expected" and then print the help. <br></div><div>Do you have thoughts on this? I'm not sure there is a clean way to do this, the cleanest would be through getFileOrSTDIN(), but I'm not sure all of its users want this behavior. I don't think we need it personally, but if you think its a good quality of life change to the tools and worth working on, I'd be happy to do so.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 26, 2019 at 1:41 AM Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">GNU addr2line, nm, objdump, and size default to a.out when no input file is specified.<br>Among llvm binary utilities, llvm-nm llvm-objdump llvm-size llvm-dwarfdump default to a.out.<br><br>I agree with Michael that a.out behavior may not be used by many people. If people don't care too much<br>about these utilities' compatibility with GNU, deleting the default a.out LGTM.<br><br>(I am opposed to make more utilities default to a.out)<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 26, 2019 at 9:02 AM Alex Brachet-Mialot via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>> Does anyone actually use the default to a.out behavior?</div><div>This is a good point. What bugs me is continuity across the tools, I agree with you that it isn't particularly useful to default to a.out. But we are kind of stuck with the weird way that GNU's binutils do things. I am not in favor of llvm-objdump defaulting to a.out, but llvm-readelf giving this warning message. My guess is that moving away from using a.out by default for llvm-objdump, llvm-nm and others whose gnu counter parts do this would be more disruptive than my proposal. <br></div><div><br></div><div>As Jake pointed out we use "-" to describe stdin/stdout, GNU's tools do not do this, so I think there is some precedence for us slightly modifying behavior when we can reasonably say things will not happen, like the file "-" existing. <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 25, 2019 at 8:28 PM Michael Spencer <<a href="mailto:bigcheesegs@gmail.com" target="_blank">bigcheesegs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><div dir="ltr" class="gmail-m_-3185601811318489541gmail-m_5261095213657952751gmail-m_7201754116644821551gmail-m_18328425899994697gmail_signature">On Tue, Jun 25, 2019 at 4:58 PM Alex Brachet-Mialot via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Some binutils, nm comes to mind, when to input file is specified will default to a.out. Others do not do this and read from stdin by default. The rest of this email will be specifically referencing these which read from stdin, and not the tools which for various reasons do things differently.</div><div><br></div><div>I propose that we change the behavior of these tools to use a.out when appropriate. By appropriate I mean firstly, no input file specified and also no stream redirection to stdin. These are the file types of stdin in these scenarios:<br></div><div>$ writes-to-stdout | prog # named pipe (fifo)<br></div><div>$ prog < file # regular file</div><div>$ prog # reading from tty, character device</div><div><br></div><div>Perhaps if stdin is a named pipe or regular file, then the default behavior should be as it always was, to read from stdin, but if stdin is a tty then we should use a.out as a default file. This lets these tools act the same as their gnu counterparts (when meaningful) but also adds what I think is convenient to not have to specify a.out. <br></div><div><br></div><div>This proposal would look something like this:<br></div><div>$ llvm-strings # not meanigful to read from stdin here, look for a.out</div><div>$ llvm-strings < file # use stdin</div><div><br></div><div>I may have got the behavior of stream redirection wrong here, or missed a situation when reading from the terminal is useful. I would love some feedback.<br></div><div><br></div><div>Best,</div><div>Alex<br></div></div><br></blockquote><div><br></div><div>Does anyone actually use the default to a.out behavior? I think it would be much friendlier to just print "file or pipe expected" and then print the help. </div><div><br></div><div>- Michael Spencer </div></div></div>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-3185601811318489541gmail-m_5261095213657952751gmail_signature"><div dir="ltr">宋方睿</div></div>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>