<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 - CFI tests not working on ARM (buildbot failure)"
   href="https://bugs.llvm.org/show_bug.cgi?id=38690">38690</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CFI tests not working on ARM (buildbot failure)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>cfi
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>peter.smith@linaro.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We have recently introduced a 2-stage clang LLD builder and I think it has
uncovered some latent problems with the CFI tests.

Builder URL: <a href="http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/">http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/</a>

I think that there are 3 separate problems:

The first problem is that the cmake logic for tests that require LLD (for
thin-lto) doesn't enable the tests from a clean build. This isn't ARM specific.
The problem is that COMPILER_RT_HAS_LLD depends on LLVM_TOOL_LLD_BUILD which is
set after the code in compiler-rt/CMakeLists.txt is run. I found I needed to
modify the compiler-rt/cfi/CMakeLists.txt file in order to get the LLD
dependent tests to run.

The second problem is that when the tests run on ARM there are assertion
failures in the tests when assertions are enabled. I think that this is due to
an assertion about the address of _cfi_check that doesn't hold on Thumb.
Specifically:
void ShadowBuilder::Add(uptr begin, uptr end, uptr cfi_check) {
  assert((cfi_check & (kShadowAlign - 1)) == 0);

The cfi_check function is always compiled to be Thumb and that means it will
have bit 0 set to 1 (to mark it as Thumb) so it will always fail that
assertion. 

The third problem is that the cross_dso tests fail when assertions are not
enabled. I don't have any more information other than I ran one of the test
binaries manually and it segfaulted.

At this stage I don't think it is LLD that is to blame, if I use gold I get
more failures.

Unfortunately this will probably need a native Arm machine to run the test,
qemu-arm can sometimes be used but sanitizers can often cause the user-mode
emulator problems. I'll try and provide an example that will be buildable on an
x86 machine but it may take some time.

The cmake files I used with a monorepo checkout:
      -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_ASSERTIONS=true\
      -DCMAKE_C_FLAGS='-mcpu=cortex-a57'\
      -DCMAKE_CXX_FLAGS='-mcpu=cortex-a57'\
      -DLLVM_TARGETS_TO_BUILD='ARM;AArch64'\
      -DLLVM_ENABLE_LLD=true

The compiler used was clang6.0 downloaded from
<a href="http://releases.llvm.org/download.html">http://releases.llvm.org/download.html</a>

I found I needed to touch the compiler-rt/cfi/CMakeLists.txt in order to
provoke it to run the cfi tests with LLD.</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>