[llvm-bugs] [Bug 28652] New: Compiler-RT contains math functions but doesn't use -lm when linking programs

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 21 15:57:27 PDT 2016


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

            Bug ID: 28652
           Summary: Compiler-RT contains math functions but doesn't use
                    -lm when linking programs
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: krejzi at email.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

When using Compiler-RT as the default runtime on Linux x86_64 and trying to
build another clang with the clang that uses Compiler-RT as the default
runtime, I get the following failure when building openmp part:

Linking C shared library ../../../../lib/libomp.so
cd /sources/llvm-build/projects/openmp/runtime/src && /usr/bin/cmake -E
cmake_link_script CMakeFiles/omp.dir/link.txt --verbose=1
/tools/bin/clang  -fPIC -march=skylake -fomit-frame-pointer -O2 -pipe -fPIC
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers
-pedantic -Wno-long-long -Wcovered-switch-default -Wdelete-non-virtual-dtor
-Werror=date-time -ffunction-sections -fdata-sections -O3 -DNDEBUG
-Wl,--warn-shared-textrel -Wl,--as-needed
-Wl,--version-script=/sources/llvm/projects/openmp/runtime/src/exports_so.txt
-static-libgcc -Wl,-z,noexecstack -Wl,-fini=__kmp_internal_end_fini 
-Wl,-z,defs -shared -Wl,-soname,libomp.so -o ../../../../lib/libomp.so
CMakeFiles/omp.dir/kmp_alloc.c.o CMakeFiles/omp.dir/kmp_atomic.c.o
CMakeFiles/omp.dir/kmp_csupport.c.o CMakeFiles/omp.dir/kmp_debug.c.o
CMakeFiles/omp.dir/kmp_itt.c.o CMakeFiles/omp.dir/kmp_environment.c.o
CMakeFiles/omp.dir/kmp_error.c.o CMakeFiles/omp.dir/kmp_global.c.o
CMakeFiles/omp.dir/kmp_i18n.c.o CMakeFiles/omp.dir/kmp_io.c.o
CMakeFiles/omp.dir/kmp_runtime.c.o CMakeFiles/omp.dir/kmp_settings.c.o
CMakeFiles/omp.dir/kmp_str.c.o CMakeFiles/omp.dir/kmp_tasking.c.o
CMakeFiles/omp.dir/kmp_taskq.c.o CMakeFiles/omp.dir/kmp_threadprivate.c.o
CMakeFiles/omp.dir/kmp_utility.c.o CMakeFiles/omp.dir/z_Linux_util.c.o
CMakeFiles/omp.dir/kmp_gsupport.c.o
CMakeFiles/omp.dir/thirdparty/ittnotify/ittnotify_static.c.o
CMakeFiles/omp.dir/kmp_ftn_cdecl.c.o CMakeFiles/omp.dir/kmp_ftn_extra.c.o
CMakeFiles/omp.dir/kmp_version.c.o CMakeFiles/omp.dir/kmp_barrier.cpp.o
CMakeFiles/omp.dir/kmp_wait_release.cpp.o CMakeFiles/omp.dir/kmp_affinity.cpp.o
CMakeFiles/omp.dir/kmp_dispatch.cpp.o CMakeFiles/omp.dir/kmp_lock.cpp.o
CMakeFiles/omp.dir/kmp_sched.cpp.o CMakeFiles/omp.dir/kmp_taskdeps.cpp.o
CMakeFiles/omp.dir/kmp_cancel.cpp.o CMakeFiles/omp.dir/z_Linux_asm.s.o
-lpthread -lm -ldl -Wl,-rpath,"\$ORIGIN/../lib" 
clang-3.9: warning: argument unused during compilation: '-static-libgcc'
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a(divdc3.c.o):
In function `__divdc3':
divdc3.c:(.text.__divdc3+0x35): undefined reference to `fmax'
divdc3.c:(.text.__divdc3+0x3a): undefined reference to `logb'
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a(divsc3.c.o):
In function `__divsc3':
divsc3.c:(.text.__divsc3+0x32): undefined reference to `fmaxf'
divsc3.c:(.text.__divsc3+0x37): undefined reference to `logbf'
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a(divxc3.c.o):
In function `__divxc3':
divxc3.c:(.text.__divxc3+0x22): undefined reference to `fmaxl'
divxc3.c:(.text.__divxc3+0x2c): undefined reference to `logbl'
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)
make[2]: *** [projects/openmp/runtime/src/CMakeFiles/omp.dir/build.make:901:
lib/libomp.so] Error 1

Note, however, that there's -lm included on the command line (I manually added
it with cmake parameter), but it still isn't being picked up. Running the
command manually, and using -v, gives the following linker invocation command:

 "/tools/bin/ld" --eh-frame-hdr -m elf_x86_64 -shared -o
../../../../lib/libomp.so /tools/bin/../lib64/crti.o
/tools/bin/../lib/clang/3.9.0/64/crtbeginS.o -L/tools/bin/../lib/clang/3.9.0/64
-L/tools/bin/../lib64 -L/lib/../lib64 -L/tools/bin/../lib -L/lib -L/usr/lib
--warn-shared-textrel --as-needed
--version-script=/sources/llvm/projects/openmp/runtime/src/exports_so.txt -z
noexecstack -fini=__kmp_internal_end_fini -z defs -soname libomp.so
CMakeFiles/omp.dir/kmp_alloc.c.o CMakeFiles/omp.dir/kmp_atomic.c.o
CMakeFiles/omp.dir/kmp_csupport.c.o CMakeFiles/omp.dir/kmp_debug.c.o
CMakeFiles/omp.dir/kmp_itt.c.o CMakeFiles/omp.dir/kmp_environment.c.o
CMakeFiles/omp.dir/kmp_error.c.o CMakeFiles/omp.dir/kmp_global.c.o
CMakeFiles/omp.dir/kmp_i18n.c.o CMakeFiles/omp.dir/kmp_io.c.o
CMakeFiles/omp.dir/kmp_runtime.c.o CMakeFiles/omp.dir/kmp_settings.c.o
CMakeFiles/omp.dir/kmp_str.c.o CMakeFiles/omp.dir/kmp_tasking.c.o
CMakeFiles/omp.dir/kmp_taskq.c.o CMakeFiles/omp.dir/kmp_threadprivate.c.o
CMakeFiles/omp.dir/kmp_utility.c.o CMakeFiles/omp.dir/z_Linux_util.c.o
CMakeFiles/omp.dir/kmp_gsupport.c.o
CMakeFiles/omp.dir/thirdparty/ittnotify/ittnotify_static.c.o
CMakeFiles/omp.dir/kmp_ftn_cdecl.c.o CMakeFiles/omp.dir/kmp_ftn_extra.c.o
CMakeFiles/omp.dir/kmp_version.c.o CMakeFiles/omp.dir/kmp_barrier.cpp.o
CMakeFiles/omp.dir/kmp_wait_release.cpp.o CMakeFiles/omp.dir/kmp_affinity.cpp.o
CMakeFiles/omp.dir/kmp_dispatch.cpp.o CMakeFiles/omp.dir/kmp_lock.cpp.o
CMakeFiles/omp.dir/kmp_sched.cpp.o CMakeFiles/omp.dir/kmp_taskdeps.cpp.o
CMakeFiles/omp.dir/kmp_cancel.cpp.o CMakeFiles/omp.dir/z_Linux_asm.s.o
-lpthread -lm -ldl -rpath "\$ORIGIN/../lib" /usr/lib/libmvec_nonshared.a
/usr/lib/libmvec.a /usr/lib/libm.a
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a -lc
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a
/tools/bin/../lib/clang/3.9.0/64/crtendS.o /tools/bin/../lib64/crtn.o

Strange thing is, if I add -lm at the end of the mentioned command (after
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a) it gets
linked correctly.

I'm not sure if this is clang or compiler-rt bug, so please reassign as
necessary.

-- 
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/20160721/d59f90c7/attachment.html>


More information about the llvm-bugs mailing list