<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 - [compiler-rt] .init_array section cmake check fails silently when -DLLVM_PROFDATA_FILE passed"
   href="https://bugs.llvm.org/show_bug.cgi?id=45022">45022</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[compiler-rt] .init_array section cmake check fails silently when -DLLVM_PROFDATA_FILE passed
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </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>zhizhouy@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This bug happens after <a href="https://reviews.llvm.org/rL372209">https://reviews.llvm.org/rL372209</a> is in.

To reproduce:

1. cmake -G Ninja -DLLVM_ENABLE_PROJECTS=compiler-rt \
-DLLVM_PROFDATA_FILE=/foo/bar.profdata path-to-llvm

2. Build llvm and `objdump -D
lib64/clang/10.0.0/lib/linux/clang_rt.crtbegin-x86_64.o`:

Disassembly of section .ctors:

0000000000000000 <.ctors>:
   0:   ff                      (bad)
   1:   ff                      (bad)
   2:   ff                      (bad)
   3:   ff                      (bad)
   4:   ff                      (bad)
   5:   ff                      (bad)
   6:   ff                      (bad)
   7:   ff                      .byte 0xff

Disassembly of section .bss.__do_fini.__finalized:

0000000000000000 <.bss.__do_fini.__finalized>:
        ...

Disassembly of section .dtors:

0000000000000000 <.dtors>:
   0:   ff                      (bad)
   1:   ff                      (bad)
   2:   ff                      (bad)
   3:   ff                      (bad)
   4:   ff                      (bad)
   5:   ff                      (bad)
   6:   ff                      (bad)
   7:   ff                      .byte 0xff



Root cause:

check_cxx_section_exists() in compiler-rt/lib/crt/CMakeLists.txt will fail
silently when -DLLVM_PROFILE_FILE is passed, causing .init_array section check
to return False after this check, and later compiler will generate objects with
bad .ctors/.dtors section.

To make this hidden error show up:

Adding command to print execution result error after `COMMAND
${test_compiler_command}` in compiler-rt/lib/crt/CMakeLists.txt,

error: Could not read profile
"/usr/local/google/home/zhizhouy/chromiumos/src/scripts/Workspace/llvm.profdata":
No such file or directory</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>