<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 - -fsanitize-coverage=trace-pc-guard errors when a c file defines more than one function w/ extern linkage"
   href="https://bugs.llvm.org/show_bug.cgi?id=38370">38370</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-fsanitize-coverage=trace-pc-guard errors when a c file defines more than one function w/ extern linkage
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>scott.determan@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If a c file defines more than one function with external linkage, and
`-fsanitize-coverage=trace-pc-guard` is set then the compiled program will
either crash (if the lld linker is used) or fail to compile (if it is not
used).

The link error is:
Link error is:

[1/2] Linking CXX executable two_c_funs FAILED: two_c_funs : &&
/home/swd/apps/clang-6.0/bin/clang++ -fsanitize=fuzzer
-fsanitize-coverage=trace-pc-guard -rdynamic
CMakeFiles/two_c_funs.dir/test.cpp.o CMakeFiles/two_c_funs.dir/two_c_funs.c.o
-o two_c_funs && : .text.sancov.module_ctor.6' referenced in
section.init_array.2[sancov.module_ctor.6]' of
CMakeFiles/two_c_funs.dir/two_c_funs.c.o: defined in discarded section
`.text.sancov.module_ctor.6[sancov.module_ctor]' of
CMakeFiles/two_c_funs.dir/two_c_funs.c.o clang-6.0: error: linker command
failed with exit code 1 (use -v to see invocation) [2/2] Linking CXX executable
one_c_fun ninja: build stopped: subcommand failed.

I created a minimal test in this repository:
<a href="https://github.com/seelabs/sanitizer_coverage_bug">https://github.com/seelabs/sanitizer_coverage_bug</a></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>