<div dir="ltr"><div>I vote for option #4, that is use the `-ffile-prefix-map` flag and handle this on `llvm::Module` creation. I'd like to avoid introducing new flags unless needed, and handle it in a way that works for all passes, not just sanitizers.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 13, 2020 at 5:44 PM Leonard Chan <<a href="mailto:leonardchan@google.com">leonardchan@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">Hi all,<div><br></div><div>I noticed that some asan-instrumented binaries varied in size depending on the length of my build path despite using `-ffile-prefix-map`. I discovered that asan bakes in the absolute path of whatever I'm compiling through the module ID (<a href="https://github.com/llvm/llvm-project/blob/80397d2d12b042586cb3bafdeb12ef8d982b8875/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L2254" target="_blank">https://github.com/llvm/llvm-project/blob/80397d2d12b042586cb3bafdeb12ef8d982b8875/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L2254</a>) which is currently unaffected by `-ffile-prefix-map`. This means binaries shipped in asan-instrumented toolchains, like libunwind, may vary depending on where it's built.</div><div><br></div><div>From what I see, there doesn't seem to be an existing way of indicating to asan that I'd like to map prefixes, so I have a couple of implementation ideas that I wanted to see if people had opinions on:</div><div><br></div><div>1. Have a separate flag orthogonal to `-fmacro-prefix-map` and `-fdebug-prefix-map` that controls which paths sanitizers (or at least asan) use. This can be named something like `-fsanitizer-prefix-map` and would also be turned on when `-ffile-prefix-map` is used.</div><div><br></div><div>2. Same as 1, but we wouldn't be adding a new flag (`-fsanitizer-prefix-map`) and the sanitizers would just use whatever value is passed to `-ffile-prefix-map`.</div><div><br></div><div>3/4. Same as 1/2, but instead of catching this at sanitizer creation, we catch this on llvm::Module creation, so anything that calls `Module::getModuleIdentifier()` will always return a path whose prefix was replaced according to whatever appropriate mapping.</div><div><br></div><div>Thanks,</div><div>Leonard</div></div>
</blockquote></div></div>