Skip to content

Linker error truncating from float #10

@MinliLiao

Description

@MinliLiao

I got the following linker error when trying with the example from README:

  1. ld.lld: error: undefined symbol: __raptor_fprt_ieee_32_func_sqrtf referenced by __raptor_done_truncate_op_func_ieee_32_to_mpfr_5_8_0_0_1__ZSt4sqrtf
  2. ld.lld: error: undefined symbol: __raptor_fprt_ieee_32_binop_fadd referenced by __raptor_done_truncate_op_func_ieee_32_to_mpfr_5_8_0_0_1__Z3barff.
  • Source code that resulted in the linker error:

    #include <math.h>
    
    template <typename fty> fty *__raptor_truncate_op_func(fty *, int, int, int, int);
    
    float bar(float a, float b) {
      return a + b;
    }
    float foo(float *a, float b) {
      a[0] = sqrt(b);
      return bar(a[1], b);
    }
    
    int main() {
      float a[2], b;
      auto f = __raptor_truncate_op_func(
        /* function */    foo,
        /* from_type */   32,
        /* to_type: 0 for builtin IEEE type, 1 for MPFR */   1,
        /* to_exponent */ 5,
        /* to_mantissa */ 8);
    
      f(a,b);
    
      return 0;
    }
  • Compiled with raptor-clang++ <sourcefile>

  • LLVM was installed with spack install llvm+clang+flang+lld+mlir@20, the spec in my spack env is as follows:

    ==> 2 root specs
    -- no arch / no compilers ---------------------------------------
    [+] llvm@20+clang+flang+lld+mlir  [+] py-lit
    
    -- linux-fedora42-x86_64 / no compilers -------------------------
    gcc@15.2.1  glibc@2.41
    
    -- linux-fedora42-zen2 / %c,cxx=gcc@15.2.1 ----------------------
    berkeley-db@18.1.40  cmake@3.31.11  expat@2.7.4  hwloc@2.12.2  llvm@20.1.8           nghttp2@1.67.1  openssl@3.6.1  re2c@4.4    zlib-ng@2.3.2
    binutils@2.43.1      curl@8.18.0    gettext@1.0  libffi@3.5.2  ncurses@6.5-20250705  ninja@1.13.2    python@3.14.3  swig@4.1.1  zstd@1.5.7
    
    -- linux-fedora42-zen2 / %c=gcc@15.2.1 --------------------------
    bzip2@1.0.8     gmake@4.4.1           libiconv@1.18      libxml2@2.15.1  perl@5.42.0    readline@8.3   unzip@6.0
    diffutils@3.12  libbsd@0.12.2         libmd@1.1.0        lua@5.3.6       pigz@2.8       sqlite@3.51.2  util-linux-uuid@2.41
    gdbm@1.26       libedit@3.1-20240808  libpciaccess@0.17  pcre2@10.44     pkgconf@2.5.1  tar@1.35       xz@5.6.3
    
    -- linux-fedora42-zen2 / no compilers ---------------------------
    ca-certificates-mozilla@2025-08-12  gcc-runtime@15.2.1      py-lit@18.1.8  py-setuptools@80.9.0  python-venv@1.0
    compiler-wrapper@1.0                perl-data-dumper@2.173  py-pip@25.1.1  py-wheel@0.45.1       util-macros@1.20.2
    
  • Other details:
    There was no problem when truncating from double instead of float.
    Same error occurs when using #include <cmath> and std::sqrt, looks like sqrtf is used for float from both cmath and math.h.

PS: The "TYPE" on line 38 of runtime/ir/Flops.def may be a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions