<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 - Building on Linux via clang with compiler-rt fails due to missing linking against libm"
   href="https://bugs.llvm.org/show_bug.cgi?id=44404">44404</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Building on Linux via clang with compiler-rt fails due to missing linking against libm
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Runtime Library
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>benni.buch@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=22969" name="attach_22969" title="Reproduce the bug via Docker">attachment 22969</a> <a href="attachment.cgi?id=22969&action=edit" title="Reproduce the bug via Docker">[details]</a></span>
Reproduce the bug via Docker

You can not build libomp on Linux with clang and compiler-rt because it is not
linked against libm while compiler-rt depends on libm.

I added an Dockerfile to reproduce the Bug. It builds clang on Ubuntu 18.04 in
3 steps. (First with system GCC, then with clang and then with clang and
compiler-rt.)

Build (optional: skip first line to use my prebuild version from Docker-Hub)
and run it with:


$ docker build -t bebuch/clang-omp-build --build-arg "branch=release/9.x" .
$ docker run -it --rm bebuch/clang-omp-build


Then run inside the container the make process:


# ninja omp
[20/35] Building C object
projects/openmp/runtime/src/CMakeFiles/omp.dir/thirdparty/ittnotify/ittnotify_static.c.o
/tmp/llvm-project/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c:1101:25:
warning: unannotated fall-through between switch labels
[-Wimplicit-fallthrough]
                        case 1:
                        ^
/tmp/llvm-project/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c:1101:25:
note: insert '[[clang::fallthrough]];' to silence this warning
                        case 1:
                        ^
                        [[clang::fallthrough]];                                 
/tmp/llvm-project/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c:1101:25:
note: insert 'break;' to avoid fall-through
                        case 1:
                        ^
                        break;                                                  
1 warning generated.
[35/35] Linking C shared library lib/libomp.so
FAILED: lib/libomp.so 
: && /usr/local/bin/clang -fPIC -fPIC -Werror=date-time
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter
-Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long
-Wimplicit-fallthrough -Wcovered-switch-default -Wdelete-non-virtual-dtor
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3
-DNDEBUG  -stdlib=libc++ -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld
-Wl,--color-diagnostics  -Wl,--warn-shared-textrel -Wl,--as-needed
-Wl,--version-script=/tmp/llvm-project/openmp/runtime/src/exports_so.txt
-static-libgcc -Wl,-z,noexecstack -Wl,-fini=__kmp_internal_end_fini -shared
-Wl,-soname,libomp.so -o lib/libomp.so
projects/openmp/runtime/src/CMakeFiles/omp.dir/thirdparty/ittnotify/ittnotify_static.c.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_alloc.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_atomic.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_csupport.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_debug.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_itt.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_environment.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_error.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_global.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_i18n.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_io.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_runtime.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_settings.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_str.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_tasking.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_threadprivate.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_utility.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_barrier.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_affinity.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_dispatch.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_lock.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_sched.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_util.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_gsupport.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_taskdeps.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_cancel.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_ftn_cdecl.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_ftn_extra.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_version.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/ompt-general.cpp.o
projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_asm.S.o  -lpthread -ldl
&& cd /tmp/llvm-project/build/lib && /usr/bin/cmake -E create_symlink libomp.so
libgomp.so && /usr/bin/cmake -E create_symlink libomp.so libiomp5.so && cd
/tmp/llvm-project/build/projects/openmp/runtime/src && /usr/bin/cmake -E
make_directory
/tmp/llvm-project/openmp/runtime/exports/common.ompt.optional/include &&
/usr/bin/cmake -E copy omp.h
/tmp/llvm-project/openmp/runtime/exports/common.ompt.optional/include && cd
/tmp/llvm-project/build/projects/openmp/runtime/src && /usr/bin/cmake -E copy
omp-tools.h
/tmp/llvm-project/openmp/runtime/exports/common.ompt.optional/include && cd
/tmp/llvm-project/build/projects/openmp/runtime/src && /usr/bin/cmake -E
make_directory
/tmp/llvm-project/openmp/runtime/exports/lin_32e.ompt.optional/lib &&
/usr/bin/cmake -E copy /tmp/llvm-project/build/lib/libomp.so
/tmp/llvm-project/openmp/runtime/exports/lin_32e.ompt.optional/lib
clang-9: warning: argument unused during compilation: '-static-libgcc'
[-Wunused-command-line-argument]
ld.lld: error: undefined symbol: fmaxl
<span class="quote">>>> referenced by divxc3.c
>>>               divxc3.c.o:(__divxc3) in archive /usr/local/lib/clang/9.0.1/lib/linux/libclang_rt.builtins-x86_64.a</span >

ld.lld: error: undefined symbol: logbl
<span class="quote">>>> referenced by divxc3.c
>>>               divxc3.c.o:(__divxc3) in archive /usr/local/lib/clang/9.0.1/lib/linux/libclang_rt.builtins-x86_64.a</span >
clang-9: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.</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>