[llvm-dev] Bug in compiling libc on AArch64 (rasberry pi4)

Siva Chandra via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 30 11:00:29 PST 2020


Hello,

Thanks for the detailed report. We do test libc build on Aarch64 regularly
but we use the Ninja generator and clang for our compiler. The problems you
are seeing are perhaps linked to using gcc as a compiler. We are working on
getting the build going gcc. We will also add a CI builder testing
everything end-to-end with gcc.

Thanks,
Siva Chandra

On Mon, Nov 30, 2020 at 10:38 AM Juergen Ilse via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello,
>
> i got errors, when i tried to compile llvm-11.0.0 on rasberry pi4 (8 GB
> model),
> I tried to compile llvm-11.0.0 with gcc-8.3.0 as it was per default
> installed
> on the RaspiOS 64 Bit Version. First i git error Messages, because gcc
> does not know anything about the command-line option
> "--print-resource-dir", which was
> used to detect an llvm directory. To get around that issue, i used a script
> named g++ instead of the real compiler found in /usr/bin/g++. The script
> looked like this:
>
> #!/bin/sh
> if test "x$1" = "x--print-resource-dir"; then
>         echo /usr/local/lib/clang/11.0.0
> else
>         /usr/bin/`basename $0` "$@"
> fi
>
> That was a (quick and dirty) workaround for this first issue. If you know
> a better workaround, please let me know.
>
> The second error was, that one test tried to include <malloc/malloc.h>,
> but
> on RaspiOS, the include file malloc.h is not in a subdirectory "malloc".
>
> To avoid this error, i changed temporarily my system with creating a
> directory /usr/include/malloc and creating a softlink from
> /usr/include(malloc.h to /usr/include/malloc/malloc.h.This workaround was
> more simple than searching and patching the CMakefiles to test for
> <malloc.h> and <malloc/malloc.h>
>
> The next error was with testing cpu geatures. I found a special and (i
> hope)
> portable workaround for the case, that there are no special cpu features.
>
> I simply applied the following patch to the file
> llvm-project-11.0.0/libc/cmake/modules/cpu_features/
> check_cpu_features.cpp.in:
>
> +++
> llvm-project-11.0.0/libc/cmake/modules/cpu_features/check_cpu_features.cpp.in.orig
> 2020-11-30 00:18:12.569056896 +0100
> @@ -17,7 +17,7 @@
>
>  int main(int, char **) {
>    const char *strings[] = {
> -      @DEFINITIONS@ ""
> +      @DEFINITIONS@
>    };
>    const size_t size = sizeof(strings) / sizeof(strings[0]);
>    for (size_t i = 0; i < size; ++i) {
>
>
> With adding the empty string in this line, there will be no change in the
> case, where @DEFINITIONS@ is empty (because ISO C++ will concatenate the
> last string in @DEFINITIONS@ with the empty string, which will result in
> the same string), but it will lead to a non empty list of strings
> consisting only of the emptystring in the case of an empty @DEFINITIONS at .
> With an empty @DEFINITIONS@, the above source will result in syntax
> errors,
> because C++ does not allow "const char *strings[] = { };" ...
>
> For the next error, i didn't find a workaround, because my C++ knowledge
> is not good enough to find a fix for this error:
>
> [ 76%] Building CXX object
> projects/libc/src/math/CMakeFiles/libc.src.math.modff_objects.dir/modff.cpp.o
> In file included from
> /usr/src/llvm-11/llvm-project-11.0.0/libc/utils/FPUtil/ManipulationFunctions.h:9,
>                  from
> /usr/src/llvm-11/llvm-project-11.0.0/libc/src/math/modff.cpp:10:
> /usr/src/llvm-11/llvm-project-11.0.0/libc/utils/FPUtil/FPBits.h:103:37:
> error: expected ‘)’ before ‘x’
>    explicit FPBits<long double>(XType x) {
>                                ~     ^~
>                                      )
> /usr/src/llvm-11/llvm-project-11.0.0/libc/utils/FPUtil/FPBits.h: In
> instantiation of ‘__llvm_libc::fputil::FPBits<T>::FPBits(XType) [with XType
> = float; typename __llvm_libc::cpp::EnableIf<__llvm_libc::cpp::IsSame<T,
> XType>::Value, int>::Type <anonymous> = 0; T = float]’:
> /usr/src/llvm-11/llvm-project-11.0.0/libc/utils/FPUtil/ManipulationFunctions.h:88:13:
>  required from ‘T __llvm_libc::fputil::modf(T, T&) [with T = float;
> typename
> __llvm_libc::cpp::EnableIf<__llvm_libc::cpp::IsFloatingPointType<Type>::Value,
> int>::Type <anonymous> = 0]’
> /usr/src/llvm-11/llvm-project-11.0.0/libc/src/math/modff.cpp:15:31:
>  required from here
> /usr/src/llvm-11/llvm-project-11.0.0/libc/utils/FPUtil/FPBits.h:81:13:
> warning: dereferencing type-punned pointer will break strict-aliasing rules
> [-Wstrict-aliasing]
>      *this = *reinterpret_cast<FPBits<T> *>(&x);
>              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/src/llvm-11/llvm-project-11.0.0/libc/utils/FPUtil/FPBits.h:81:11:
> warning: dereferencing type-punned pointer will break strict-aliasing rules
> [-Wstrict-aliasing]
>      *this = *reinterpret_cast<FPBits<T> *>(&x);
>      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> make[2]: ***
> [projects/libc/src/math/CMakeFiles/libc.src.math.modff_objects.dir/build.make:63:
> projects/libc/src/math/CMakeFiles/libc.src.math.modff_objects.dir/modff.cpp.o]
> Fehler 1
> make[1]: *** [CMakeFiles/Makefile2:27781:
> projects/libc/src/math/CMakeFiles/libc.src.math.modff_objects.dir/all]
> Fehler 2
> make: *** [Makefile:152: all] Fehler 2
>
> Can you please try to fix those errors in the next release of llvm?
> I would like to compile llvm ibcuding libc on 64 Bit Version of RaspiOS
> on my Raspi4 ... A "MinSizeRel" build with all other subproject was
> successful on my raspi4, but libc led to the above issues (and i think
> i found an acceptable workaround for one of them, see the patch above).
>
> I hope, this information about trying to compile LLVM on RaspiOS 64 Bit
> is helpful to make llvm better and more portable.
>
> Thanks in advance,
>         Juergen Ilse                    (juergen at usenet-verwaltung.de)
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201130/b82661b9/attachment.html>


More information about the llvm-dev mailing list