<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;"><br><div><div>On Dec 9, 2013, at 3:54 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="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;">On Mon, Dec 9, 2013 at 3:48 PM, Andrew Trick <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:<br><blockquote type="cite"><br>On Dec 9, 2013, at 3:09 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br><br><blockquote type="cite">On Mon, Dec 9, 2013 at 3:02 PM, Andrew Trick <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:<br><blockquote type="cite"><br>On Dec 9, 2013, at 2:50 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br><br>On Mon, Dec 9, 2013 at 1:58 PM, Filip Pizlo <<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>> wrote:<br><br><br>On Dec 9, 2013, at 12:42 PM, Andrew Trick <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:<br><br><br>On Dec 9, 2013, at 12:01 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br><br>Out of curiosity why isn't it able to get a compilation dir?<br><br><br>Probably one of these.<br><br> The getcwd() function will fail if:<br><br> [EACCES] Read or search permission was denied for a component<br>of the pathname.<br><br> [ENOENT] A component of the pathname no longer exists.<br><br>Phil might know for sure.<br><br><br>I'm not sure, actually. ;-) When I hit the bug it was probably ENOENT<br>caused by weirdness in our JSC test harness.<br><br>But, broadly, there is no requirement for a client of JavaScriptCore to run<br>with $PWD set to anything remotely sensible. Moreover, it's my<br>understanding that libraries and frameworks in general never assume anything<br>about the sanity of $PWD unless they are asked to do relative path IO. This<br>isn't just a JSC bug: if the claim is that LLVM is a JIT library then it's<br>probably best if LLVM gracefully handles not having a sane $PWD.<br><br><br>That's not quite what I'm talking about, FWIW I agree that you<br>shouldn't have to have an environment at all :)<br><br>Basically the lines of code in MCDwarf.cpp are supposed to be when<br>generating dwarf for assembly files and I wasn't under the impression<br>you were compiling .s files. :)<br><br>That code should probably have some decent fallback in it, but I don't<br>think a null DW_AT_compilation_dir is the correct one. It should omit<br>the attribute if it can't get a valid value.<br><br><br>You think we should omit the entire compile_unit DIE if we don’t find the<br>absolute path? If we simply omit the DIE, do you think any tools could be<br>confused? Is it worth adding a special case for a situation that cannot<br>conceivably happen in the context of compiling .s files? I’d be happy to<br>simply assert that CompilationDir is non-empty if that’s preferable to<br>emitting a DIE with an empty path.<br><br></blockquote><br>No, I think you should omit the DW_AT_compilation_dir attribute on the<br>DIE if it's empty. I still don't understand how you're getting down<br>this path, but…<br></blockquote><br>Maybe the problem was my commit comment:<br><br>---<br>MCJIT needs to be able to run in hostile environments, even when PWD<br>is invalid. There's no need to crash MCJIT in this case.<br><br>The obvious fix is to simply leave MCContext's CompilationDir empty<br>when PWD can't be determined. This way, MCJIT clients,<br>and other clients that link with LLVM don’t need a valid working directory.<br><br>If we do want to guarantee valid CompilationDir, that should be done<br>only for clients of getCompilationDir(). This is as simple as checking<br>for an empty string.<br><br>The only current use of getCompilationDir is EmitGenDwarfInfo. This case won’t<br>conceivably run with an invalid working dir, and if it did (hypothetically), skipping<br>the AT_comp_dir attribute is a reasonable way to handle it.<br></blockquote><br>I understood all of this.<br><br><blockquote type="cite">---<br><br>I’m not sure how to “omit the attribute” other than emitting a NULL byte in its place.<br><br></blockquote><br>You don't emit it at all. You'll probably need to adjust the<br>abbreviation as well.<br><br>An alternate workaround is to set it via the "command line" in the<br>case that you're running into.<br></div></blockquote><br></div><div>We’re not running into this case, nor do I think it is possible. However, I did hack an LLVM build to test this code path, and I think this is the patch you’re looking for:</div><br><div></div></body></html>