[llvm-bugs] [Bug 46628] New: check-builtins fails on musl libc system

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 7 19:54:01 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46628

            Bug ID: 46628
           Summary: check-builtins fails on musl libc system
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: builtins
          Assignee: unassignedbugs at nondot.org
          Reporter: p.waydan at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23699
  --> https://bugs.llvm.org/attachment.cgi?id=23699&action=edit
Patch to disable glibc check when using musl

I am cross-compiling the compiler-rt builtins for armv6m on an Alpine Linux
docker image following the
https://llvm.org/docs/HowToCrossCompileBuiltinsOnArm.html guide. The builtins
compile and link successfully but running `ninja check-builtins` emits the
following error:

llvm-lit:
/tmp/llvm-project/build-rt/bin/../../llvm/utils/lit/lit/TestingConfig.py:99:
fatal: unable to parse config file
'/tmp/llvm-project/compiler-rt/test/lit.common.cfg.py', traceback: Traceback
(most recent call last):
  File
"/tmp/llvm-project/build-rt/bin/../../llvm/utils/lit/lit/TestingConfig.py",
line 88, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/tmp/llvm-project/compiler-rt/test/lit.common.cfg.py", line 398, in
<module>
    ver_line = sout.splitlines()[0]
IndexError: list index out of range

I ran lines 394:397 from compiler-rt/test/lit.common.cfg.py by hand and found
that `sout` is an empty string which explains the IndexError. I tried running
`ldd --version` in the terminal, but this command does not exist for the musl
ldd (ld-musl-x86_64.so.1) and output goes to stderr instead of stdout.

I found a workaround to this problem by adding a guard before `ver_line =
sout.splitlines()[0]` to check that the length of sout is greater than zero.
Please see the attached patch.

Cmake options are as follows:
cmake -GNinja ../compiler-rt \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
-DCOMPILER_RT_OS_DIR="baremetal" \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_PROFILE=OFF \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_C_COMPILER_TARGET="armv6m-none-eabi" \
-DCMAKE_ASM_COMPILER_TARGET="armv6m-none-eabi" \
-DCMAKE_AR=/usr/bin/llvm-ar \
-DCMAKE_NM=/usr/bin/llvm-nm \
-DCMAKE_RANLIB=/usr/bin/llvm-ranlib \
-DCOMPILER_RT_BAREMETAL_BUILD=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-DCMAKE_C_FLAGS="-I/tmp/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/include
--target=armv6-none-eabi" \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_ASM_FLAGS="" \
-DLLVM_CONFIG_PATH=/usr/bin/llvm-config \
-DLLVM_MAIN_SRC_DIR="../llvm" \
-DCOMPILER_RT_EMULATOR="qemu-arm -L
/tmp/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabi/arm-linux-gnueabi/libc" \
-DCOMPILER_RT_INCLUDE_TESTS=ON \
-DCOMPILER_RT_TEST_COMPILER=/usr/bin/clang \
-DCOMPILER_RT_TEST_COMPILER_CFLAGS="--target=arm-linux-gnueabi -march=armv7a
-mthumb -mfloat-abi=soft -mfpu=none -fuse-ld=lld \
--sysroot=/tmp/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabi/arm-linux-gnueabi/libc
\
--gcc-toolchain=/tmp/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabi"

-- 
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/20200708/8b7ad367/attachment-0001.html>


More information about the llvm-bugs mailing list