<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Aug 14, 2013, at 3:00 PM, Dan Gohman <<a href="mailto:dan433584@gmail.com">dan433584@gmail.com</a>> wrote:<br><div><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr">Standard error is what many tools, including clang for example, use for their --verbose output. This is appropriate because it leaves standard output available for regular output data, which the user may wish to capture in a file or a pipe.</div></div></blockquote><div>Well, at least with the darwin linker, the linker main output goes to a file (specified by -o or “a.out”). So, since there is normally nothing going to stdout, -v and -t output goes to stdout.</div><div><br></div><div>Shankar, although not quite as convenient, we could change the core linker test cases from:</div><div>      lld … | FileCheck </div><div>to:</div><div>     lld …  -o %t && FileCheck < %t</div><div>Then change the core linker to not use “-“, but error if -o is not supplied.</div><div><br></div><div>-Nick</div><div><br></div><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 14, 2013 at 2:48 PM, Shankar Easwaran<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Hi Dan,<br><br>The other messages, need to go to stdout as well. Using stderr to output for a switch like --verbose is wrong in my opinion.<div><div class="h5"><br><br>On 8/14/2013 4:44 PM, Dan Gohman wrote:<br></div></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div><div class="h5">Would it be appropriate for lld's other output to go to standard error<br>instead of standard output, since standard output may be used for YAML<br>output?<br><br>Dan<br><br>On Wed, Aug 14, 2013 at 12:53 PM, Shankar Easwaran<br><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><u></u>wrote:<br><br></div></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div><div class="h5">Hi Dan,<br><br>lld takes a -emit-yaml option, which emits the intermediate<br>representation(atoms) in YAML form.<br><br>By default output goes to stdout, the user can control it by using the -o<br>option too.<br><br>The way its handled is, similiar to this piece of pseudo-code<br><br>if (dash_o_option)<br>     outputFile = dash_o_option->value()<br>else<br>   <span class="Apple-converted-space"> </span>outputFile = "-"<br><br>When lld tries to mix things that go to stdout using llvm::outs() and<br>-emit-yaml, it starts to get this error.<br><br>If there is a restriction like this, possibly it has to be mentioned<br>somewhere for usecases (or) raw_fd_ostream should not be accepting a '-' in<br>the argument.<br><br>What do you think ?<br><br>Thanks<br><br>Shankar Easwaran<br><br><br>On 8/14/2013 2:02 PM, Dan Gohman wrote:<br><br></div></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div><div class="h5">The high-level answer is that library code shouldn't hardcode output<br>paths,<br>including "-" and including using llvm::outs(). Library code should (in<br>general) instead accept an ostream in its API and write to wherever it is<br>being asked to write. If this is followed, the only place in any program<br>using llvm::outs() is code which is not part of a "library" -- i.e. it is<br>the "main" code, and it should only do so if it is a program which doesn't<br>open file names which could be "-".<br><br>Do you have a use-case where this restriction is too restrictive?<br><br>As a random aside, a more aggressive answer could be that "-" is a kind of<br>hack, and that it would be a better approach to use /dev/stdout and<br>/dev/stdin instead of "-", because they wouldn't require special-case<br>logic. Unfortunately, this may not be sufficiently portable.<br><br>Dan<br><br><br>On Wed, Aug 14, 2013 at 8:28 AM, Shankar Easwaran<br></div></div><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>>**<u></u>wrote:<br><br> <span class="Apple-converted-space"> </span>Hi,<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="im">When I run the below example, it results in :-<br><br>hello<br>world<br>LLVM ERROR: IO failure on output stream.<br><br>Testcase :-<br><br>#include <llvm/Support/raw_ostream.h><br><br>int fn() {<br>   <span class="Apple-converted-space"> </span>std::string errorInfo;<br>   <span class="Apple-converted-space"> </span>llvm::raw_fd_ostream out("-", errorInfo);<br>   <span class="Apple-converted-space"> </span>out << "world\n";<br>   <span class="Apple-converted-space"> </span>return 0;<br>}<br>int main(int argc, char **argv) {<br>   <span class="Apple-converted-space"> </span>llvm::outs() << "hello\n";<br>   <span class="Apple-converted-space"> </span>fn();<br>   <span class="Apple-converted-space"> </span>return 0;<br>}<br><br>I tried to fix this by making llvm::outs(), not close the stdout<br>descriptor, but I think its wrong. Recommendations ?<br><br>Thanks<br><br>Shankar Easwaran<br><br>--<br>Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>by the Linux Foundation<br><br><br><br></div>______________________________<u></u>****_________________<div class="im"><br><br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>       <span class="Apple-converted-space"> </span><a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br></div><a href="http://lists.cs.uiuc.edu/****mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/****<u></u>mailman/listinfo/llvmdev</a><<a href="http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev" target="_blank">http:<u></u>//lists.cs.uiuc.edu/**mailman/<u></u>listinfo/llvmdev</a>><br><http:**//<a href="http://lists.cs.uiuc.edu/mailman/**listinfo/llvmdev" target="_blank">lists.cs.uiuc.edu/<u></u>mailman/**listinfo/llvmdev</a><<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">htt<u></u>p://lists.cs.uiuc.edu/mailman/<u></u>listinfo/llvmdev</a>><br><br></blockquote></blockquote><div class="im">--<br>Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>by the Linux Foundation<br><br><br></div></blockquote></blockquote><br><div class="HOEnZb"><div class="h5"><br>--<span class="Apple-converted-space"> </span><br>Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</div></div></blockquote></div></div></div></blockquote></div><br></body></html>