<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Mar 21, 2016 at 9:32 PM Justin Bogner <<a href="mailto:mail@justinbogner.com">mail@justinbogner.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Chandler Carruth via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br>
> Owen Anderson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br>
>> resistor created this revision.<br>
>> resistor added a reviewer: chandlerc.<br>
>> resistor added a subscriber: llvm-commits.<br>
>> resistor set the repository for this revision to rL LLVM.<br>
>><br>
>> Currently MCContext tries to lookup CWD on construction.  This causes<br>
>> sandboxing violations when using LLVM in a daemon without filesystem<br>
>> access.  The solution is defer CWD lookup until absolutely necessary.<br>
><br>
> The goal here makes perfect sense, but I wonder if this is the right<br>
> fix... It seems almost too surgical, and makes it really easy to<br>
> change MC in a way that yet again violates things.<br>
><br>
> I feel like the MCContext shouldn't be looking at the filesystem *at<br>
> all*, and it should be the client that sets up the MCContext that<br>
> provides a compilation directory, potentially via the filesystem<br>
> query, where appropriate. Does that make sense here?<br>
<br>
For all intents and purposes, this is already done and the code Owen's<br>
removing here is functionally dead.<br>
<br>
- Clang calls setCompilationDir (by passing -fdebug-compilation-dir to<br>
  clang -cc1) with the result of current_path unless current_path fails,<br>
  but it would just fail again if that happened.<br>
<br>
- opt and llc don't generate debug info, so they just pass along the<br>
  AT_comp_dir directive in the IR if it's there.<br>
<br>
- llvm-mc does rely on this, but (1) it's a testing tool, and (2) it's<br>
  trivial to make it call current_path.<br>
<br>
I think we just want to remove the call to current_path in LLVMContext's<br>
constructor and add a call to setCompilationDir in llvm-mc, like in the<br>
attached patch. WDYT?<br></blockquote><div><br></div><div>LGTM, but should probably confirm with Eric as well.</div></div></div>