[llvm-bugs] [Bug 39376] New: Compiler-rt missing long double builtins for x86_64

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 21 19:41:05 PDT 2018


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

            Bug ID: 39376
           Summary: Compiler-rt missing long double builtins for x86_64
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: builtins
          Assignee: unassignedbugs at nondot.org
          Reporter: manojgupta at google.com
                CC: llvm-bugs at lists.llvm.org

Chrome OS bug: https://bugs.chromium.org/p/chromium/issues/detail?id=843822


With glibc 2.27, clang cannot compile a static binary with compiler-rt since
compiler-rt does not have support for long double builtins for x86_64.

With glibc 2.27
cat a.c
#include "stdio.h"
int main() {
  printf("hello.\n");
}

 clang -static a.c -rtlib=compiler-rt
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/libc.a(printf_fp.o):
In function `__printf_fp_l':
(.text+0x5ea): undefined reference to `__unordtf2'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/libc.a(printf_fphex.o):
In function `__printf_fphex':
(.text+0x9a): undefined reference to `__unordtf2'


The following patch is enough to add the builtins to compiler-rt but not sure
of the correctness or any other implications. Interesting thing to note is that
__LDBL_MANT_DIG__ is 64 so the check __LDBL_MANT_DIG__ == 113 failed on
x86_64/Linux. 

diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt
index 82332967b..c49d9af00 100644
--- a/lib/builtins/CMakeLists.txt
+++ b/lib/builtins/CMakeLists.txt
@@ -232,6 +232,7 @@ set(x86_ARCH_SOURCES

 if (NOT MSVC)
   set(x86_64_SOURCES
+      ${GENERIC_TF_SOURCES}
       x86_64/floatdidf.c
       x86_64/floatdisf.c
       x86_64/floatdixf.c
diff --git a/lib/builtins/fp_lib.h b/lib/builtins/fp_lib.h
index a0e19ab6a..c4f9d1d90 100644
--- a/lib/builtins/fp_lib.h
+++ b/lib/builtins/fp_lib.h
@@ -103,7 +103,7 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t
*hi, rep_t *lo) {
 COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b);

 #elif defined QUAD_PRECISION
-#if __LDBL_MANT_DIG__ == 113
+#ifdef __LP64__
 #define CRT_LDBL_128BIT
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;

-- 
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/20181022/26cde4c2/attachment.html>


More information about the llvm-bugs mailing list