<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang's coverage mapping uses absolute paths instead of relative paths"
   href="https://bugs.llvm.org/show_bug.cgi?id=43614">43614</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang's coverage mapping uses absolute paths instead of relative paths
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>arphaman@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, nicolasweber@gmx.de, richard-llvm@metafoo.co.uk, vk@vedantk.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Originally reported as <a href="https://crbug.com/1010267">https://crbug.com/1010267</a>.

Clang has a few options that are meant to help prevent absolute paths from
appearing in the compiler's output:
- -fdebug-compilation-dir .
- -no-canonical-prefixes

The intention is that when using these flags, the output should be the same
regardless of the CWD used to run the compiler, as long as all the input files
exist at the same relative paths in two compilations. This makes it possible to
distribute local compilation to another machine without having to set up a
chroot or recreate the user's CWD on the remote machine.

However, when enabling the coverage mapping with -fprofile-instr-generate
-fcoverage-mapping, the coverage mapping data ends up containing absolute
paths. The code calls sys::fs::make_absolute here:
<a href="https://github.com/llvm/llvm-project/blob/367405008755640eac6114b18ec8c98be0cf5392/clang/lib/CodeGen/CoverageMappingGen.cpp#L1283">https://github.com/llvm/llvm-project/blob/367405008755640eac6114b18ec8c98be0cf5392/clang/lib/CodeGen/CoverageMappingGen.cpp#L1283</a>

std::string normalizeFilename(StringRef Filename) {
  llvm::SmallString<256> Path(Filename);
  llvm::sys::fs::make_absolute(Path);
  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
  return Path.str().str();
}

The make_absolute call seems to be present in the original version of the code
added in r214752.

What would be the best way to indicate to the coverage code that we don't want
absolute paths in the output? Should the coverage code reuse the logic of
`CGDebugInfo::remapDI` to respect -fdebug-prefix-map? Coverage mapping info is
kind of like debug info, but it's certainly not DWARF.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>