<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 - LLVM_ENABLE_RUNTIMES broken on linux/musl"
   href="https://bugs.llvm.org/show_bug.cgi?id=49795">49795</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM_ENABLE_RUNTIMES broken on linux/musl
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Build scripts
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>cmake
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chris@arachsys.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>TL;DR: LLVM_ENABLE_RUNTIMES in both release/12.x and main appears to be broken
on linux/musl but not on linux/glibc.

I stumbled over this whilst packaging llvm/clang/etc for a weird local linux
distribution, but I reproduce and demonstrate below with mainstream Alpine
Linux and Debian images.


In a linux/musl image, such as

   
<a href="https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-minirootfs-3.13.3-x86_64.tar.gz">https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-minirootfs-3.13.3-x86_64.tar.gz</a>
    apk add alpine-sdk cmake linux-headers python3

running

    mkdir build && cd build
    cmake -W no-dev \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;libunwind;libcxx;libcxxabi" \
      -DLLVM_INCLUDE_TESTS=No \
      -DLLVM_TARGETS_TO_BUILD="Native" \
      -DLIBCXX_HAS_MUSL_LIBC=Yes \
      -DCOMPILER_RT_BUILD_LIBFUZZER=No \
      -DCOMPILER_RT_BUILD_MEMPROF=No \
      -DCOMPILER_RT_BUILD_SANITIZERS=No \
      -DCOMPILER_RT_BUILD_XRAY=No \
      ../llvm && make -j16

completes successfully, and the resulting compiler and runtimes can be
re-used to fully bootstrap. However, the same thing with ENABLE_RUNTIMES:

    cmake -W no-dev \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_PROJECTS="clang" \
      -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \
      -DLLVM_INCLUDE_TESTS=No \
      -DLLVM_TARGETS_TO_BUILD="Native" \
      -DLIBCXX_HAS_MUSL_LIBC=Yes \
      -DCOMPILER_RT_BUILD_LIBFUZZER=No \
      -DCOMPILER_RT_BUILD_MEMPROF=No \
      -DCOMPILER_RT_BUILD_SANITIZERS=No \
      -DCOMPILER_RT_BUILD_XRAY=No \
      ../llvm && make -j16

crashes when the runtimes build tries to configure:

    [...]
    -- Performing Test COMPILER_RT_HAS_FUSE_LD_LLD_FLAG
    -- Performing Test COMPILER_RT_HAS_FUSE_LD_LLD_FLAG - Failed
    -- Performing Test COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT
    -- Performing Test COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT - Failed
    -- Performing Test COMPILER_RT_HAS_VERSION_SCRIPT
    -- Performing Test COMPILER_RT_HAS_VERSION_SCRIPT - Failed
    CMake Error at /root/llvm-project/compiler-rt/cmake/config-ix.cmake:196
(message):
      Please use architecture with 4 or 8 byte pointers.
    Call Stack (most recent call first):
      /root/llvm-project/compiler-rt/CMakeLists.txt:245 (include)

    -- Configuring incomplete, errors occurred!
    See also
"/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeOutput.log".
    See also
"/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeError.log".
    make[2]: *** [runtimes/CMakeFiles/runtimes.dir/build.make:126:
runtimes/runtimes-stamps/runtimes-configure] Error 1
    make[1]: *** [CMakeFiles/Makefile2:34100:
runtimes/CMakeFiles/runtimes.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....

During this configure step, every runtimes-bin test is down as 'Failed',
even things like 'C_SUPPORTS_FPIC' or 'Looking for fopen in c'. Looking at
runtimes/runtimes-bin/CMakeFiles/CMakeError.log shows link repeatedly
failing like this:

    Run Build Command(s):/usr/bin/make cmTC_ac0dd/fast && make[3]: Entering
directory
'/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp'
    /usr/bin/make  -f CMakeFiles/cmTC_ac0dd.dir/build.make
CMakeFiles/cmTC_ac0dd.dir/build
    make[4]: Entering directory
'/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_ac0dd.dir/src.cxx.o
    /root/llvm-project/build2/./bin/clang++ --target=x86_64-unknown-linux-gnu  
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-comment
-DCOMPILER_RT_HAS_VERSION_SCRIPT  -nostdinc++  -isystem
/root/llvm-project/runtimes/../libcxx/include
-Wl,--version-script,/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp/dummy.vers
-o CMakeFiles/cmTC_ac0dd.dir/src.cxx.o -c
/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp/src.cxx
    clang-12: warning:
-Wl,--version-script,/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp/dummy.vers:
'linker' input unused [-Wunused-command-line-argument]
    Linking CXX executable cmTC_ac0dd
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ac0dd.dir/link.txt
--verbose=1
    /root/llvm-project/build2/./bin/clang++ --target=x86_64-unknown-linux-gnu 
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-comment
-DCOMPILER_RT_HAS_VERSION_SCRIPT  -nostdinc++  -isystem
/root/llvm-project/runtimes/../libcxx/include
-Wl,--version-script,/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp/dummy.vers
CMakeFiles/cmTC_ac0dd.dir/src.cxx.o -o cmTC_ac0dd
    clang-12: warning: argument unused during compilation: '-nostdinc++'
[-Wunused-command-line-argument]
    /usr/bin/ld: cannot find crtbegin.o: No such file or directory
    /usr/bin/ld: cannot find -lgcc
    clang-12: error: linker command failed with exit code 1 (use -v to see
invocation)
    make[4]: *** [CMakeFiles/cmTC_ac0dd.dir/build.make:106: cmTC_ac0dd] Error 1
    make[4]: Leaving directory
'/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp'
    make[3]: *** [Makefile:140: cmTC_ac0dd/fast] Error 2
    make[3]: Leaving directory
'/root/llvm-project/build2/runtimes/runtimes-bins/CMakeFiles/CMakeTmp'


This doesn't happen on a linux/glibc image, such as Debian unstable with

   
<a href="https://raw.githubusercontent.com/debuerreotype/docker-debian-artifacts/dist-amd64/unstable/rootfs.tar.xz">https://raw.githubusercontent.com/debuerreotype/docker-debian-artifacts/dist-amd64/unstable/rootfs.tar.xz</a>
    apt-get install build-essential cmake python3 python3-distutils

where

      cmake -W no-dev \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_PROJECTS="clang" \
      -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \
      -DLLVM_INCLUDE_TESTS=No \
      -DLLVM_TARGETS_TO_BUILD="Native" \
      -DCOMPILER_RT_BUILD_LIBFUZZER=No \
      -DCOMPILER_RT_BUILD_MEMPROF=No \
      -DCOMPILER_RT_BUILD_SANITIZERS=No \
      -DCOMPILER_RT_BUILD_XRAY=No \
      ../llvm && make -j16

completes fine, as does a build with the runtimes in LLVM_ENABLE_PROJECTS.
(Same cmake command except I've dropped -DLIBCXX_HAS_MUSL_LIBC.)</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>