[llvm-bugs] [Bug 39906] New: Cannot build builtins on ARMv6 (unsupported instructions)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 6 17:42:25 PST 2018


            Bug ID: 39906
           Summary: Cannot build builtins on ARMv6 (unsupported
           Product: compiler-rt
           Version: unspecified
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: builtins
          Assignee: unassignedbugs at nondot.org
          Reporter: lizardm4 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 21199
  --> https://bugs.llvm.org/attachment.cgi?id=21199&action=edit
Build log for gcc and clang and Dockerfile

Compiler-rt cannot be built on ARMv6 architectures such as ARM1176JZF-S, there
are some memory barrier instructions in
`compiler-rt/lib/builtins/arm/sync-ops.h` that are not supported (namely
This means it can't be truly build for Raspbian or on a Raspberry Pi, but the
error occurs also when trying to cross compile with `-march=armv6`. Indeed the
library `libclang_rt.builtins-armhf.a` is completely missing from Raspbian
(package `libclang-common-3.8-dev`).
I also found that the problem has already been mentioned in the llvm-dev
mailing list at http://lists.llvm.org/pipermail/llvm-dev/2016-May/099780.html.

I'm attaching the logfile of the errors when building
`compiler-rt/lib/builtins/arm/sync_fetch_and_add_4.S` on a Raspberry Pi with
Raspbian Stretch (kernel 4.14.79+) both with gcc (Raspbian
6.3.0-18+rpi1+deb9u1) 6.3.0 20170516 and clang (version 3.8.1-24+rpi1
tags/RELEASE_381/final). I am also attaching a Dockerfile which tries to
cross-compile compiler-rt for armv6, and also triggers the same error.

On the ARM1176JZF-S with Raspbian, I cloned the release 7.0 of llvm and
compiler-rt, and then ran `cmake` with no extra define. I ignored the errors
from CMake and I then ran `make builtins --trace` to extract the command line
used to build `sync_fetch_and_add_4.S`. The command line computed by CMake for
that file wrongly specified `-march=armv7-a`:

-D__STDC_LIMIT_MACROS -I/home/pi/build/projects/compiler-rt/lib/builtins
-I/home/pi/llvm/projects/compiler-rt/lib/builtins -I/home/pi/build/include
-I/home/pi/llvm/include  -fPIC -g    -march=armv7-a -mfloat-abi=hard -fno-lto
-std=c11 -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET -o
CMakeFiles/clang_rt.builtins-armhf.dir/arm/sync_fetch_and_add_4.S.o -c

When crosscompiling, I had manually specified `-march=armv6`, and that
triggered the error. When replacing the architecture on the command line, I
observed the same error on the real hardware. The command line specified above
is sufficient to reproduce.
It seems the architecture is not set correctly at
`compiler-rt/cmake/base-config-ix.cmake:201` by using `test_target_arch` from

I tried to build all the targets in the Makefiles of compiler-rt in Docker to
see whether the issue is limited to that instruction, and (at least with clang)
it seems to be the case, all the other sources compiled correctly, failing only
at linking because of the missing `sync_fetch_*.S.o`.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181207/e523f44e/attachment-0001.html>

More information about the llvm-bugs mailing list