<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 - call_apsr.S fails to build during builtins test"
   href="https://bugs.llvm.org/show_bug.cgi?id=46630">46630</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>call_apsr.S fails to build during builtins test
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>builtins
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>p.waydan@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23700" name="attach_23700" title="cmake arguments">attachment 23700</a> <a href="attachment.cgi?id=23700&action=edit" title="cmake arguments">[details]</a></span>
cmake arguments

I successful built and linked the compiler-rt builtins for armv6m using an
Alpine Linux docker image. Most of the tests pass, but I still have four
failures.

********************
********************
Failed Tests (4):
  Builtins-armv6m-linux :: arm/aeabi_cdcmpeq_test.c
  Builtins-armv6m-linux :: arm/aeabi_cdcmple_test.c
  Builtins-armv6m-linux :: arm/aeabi_cfcmpeq_test.c
  Builtins-armv6m-linux :: arm/aeabi_cfcmple_test.c


Testing Time: 10.56s
  Unsupported      :  94
  Passed           : 104
  Expectedly Failed:   1
  Failed           :   4

Looking at the fail logs, I can see that call_apsr.S could not be compiled
correctly.

: 'RUN: at line 2';       /usr/bin/clang  -c -march=armv6m
/tmp/llvm-project/compiler-rt/test/builtins/Unit/arm/call_apsr.S -o
/tmp/llvm-project/build-rt/test/builtins/Unit/ARMV6MLinuxConfig/arm/Output/aeabi_cfcmple_test.c.tmp.aspr.o

Trying the above compilation command directly from the terminal gives the
following error:

error: unknown target CPU 'armv6m'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom,
silvermont, slm, goldmont, goldmont-plus,
      tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
core-avx-i, haswell, core-avx2,
      broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake,
cannonlake, icelake-client, icelake-server,
      tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
athlon64-sse3, opteron-sse3, amdfam10,
      barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1,
znver2, x86-64

All these targets are x86 which indicates that clang is targeting the host
machine.

I found the relative code in compiler-rt/test/builtins/Unit/lit.cfg.py lines
84:90.

# FIXME: move the call_apsr.s into call_apsr.h as inline-asm.
# some ARM tests needs call_apsr.s
call_apsr_source = os.path.join(builtins_lit_source_dir, 'arm', 'call_apsr.S')
march_flag = '-march=' + target_arch
call_apsr_flags = ['-c', march_flag, call_apsr_source]
config.substitutions.append( ("%arm_call_apsr ", \
                              build_invocation(call_apsr_flags)) )

So lit.cfg.py is calling clang with an -march argument and no -target argument.
I can solve the issue and successfully build and run the tests by adding
--target=arm-none-eabi to the call_apsr_flags list, but this is not an
acceptable argument if compiling with gcc.</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>