Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Undefined reference to `__truncdfhf2'

jboline
New Contributor I
1,021 Views

I am trying to compile a simple program to experiment with using _Float16 without hardware support. The code is:

 

#include <mathimf.h>
#include <stdio.h>

int main()
{
    _Float16 a;
    a = sin(1.0);

    printf("%f\n", (float) a);
}

 

However, when I attempt to compile it using the icx command "icx -march=znver2 -ffp-eval-method=source -fno-fast-math test.c -O0" I get an error about missing __truncdfhf2:

 

/tmp/icx-5661a33e8a/test-cacdee.o: In function `main':
test.c:(.text+0x16): undefined reference to `__truncdfhf2'
icx: error: linker command failed with exit code 1 (use -v to see invocation)

 

It seems this instruction is contained in compiler-rt, but when I add "-rtlib=compiler-rt" I get the errors:

 

/usr/bin/ld: cannot find /opt/intel/oneapi/compiler/2024.1/lib/clang/18/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
/usr/bin/ld: cannot find /opt/intel/oneapi/compiler/2024.1/lib/clang/18/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory

 

The only libclang_rt files I can find are contained in "/opt/intel/oneapi/compiler/2024.1/lib/clang/18/lib/x86_64-unknown-linux-gnu/" and even then there is no "libclang_rt.builtins-x86_64" library.

 

How do I go about getting this instruction in icx?

0 Kudos
15 Replies
Viet_H_Intel
Moderator
981 Views

I am able to compile on none-hardware support system.

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math t4.c -O0 -D__AVX512FP16__ -V
Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2025.0.0 Build 20241008
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

$ cat t4.c
#include <mathimf.h>
#include<stdio.h>

int main()
{
_Float16 a;
a = sinf16(1);
printf ("a is %f\n",(float)a);
return 0;
}

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math t4.c -O0 -Wno-implicit-function-declaration

$ ./a.out
Illegal instruction (core dumped)

0 Kudos
jboline
New Contributor I
977 Views

I am using oneapi 2024.1.0. Also the code is using sin not sinf16.

0 Kudos
Viet_H_Intel
Moderator
976 Views

I still can't reproduce the error you see with 2024.1.0.

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math t5.c -O0 -V
Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2024.1.0 Build 20240308
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

$ cat t5.c
#include <mathimf.h>
#include <stdio.h>

int main()
{
_Float16 a;
a = sin(1.0);

printf("%f\n", (float) a);
}

What gcc version on your system?

 

0 Kudos
jboline
New Contributor I
971 Views

Version is: gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)

0 Kudos
Viet_H_Intel
Moderator
967 Views

Could be related to GCC version.

Mine is 11.4.0,

0 Kudos
jboline
New Contributor I
829 Views

Hmm I tried installing gcc 11 and using it, but I'm still getting the same error

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/gcc-toolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/gcc-toolset-11/root/usr --mandir=/opt/rh/gcc-toolset-11/root/usr/share/man --infodir=/opt/rh/gcc-toolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)

 

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math test.c -O0 -V
Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2024.1.0 Build 20240308
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

/opt/rh/gcc-toolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../bin/ld: /tmp/icx-7ad0bac4ea/test-f2614d.o: in function `main':
test.c:(.text+0x16): undefined reference to `__truncdfhf2'

0 Kudos
Viet_H_Intel
Moderator
824 Views

Can you try:  

icx -march=znver2 -ffp-eval-method=source -fno-fast-math test.c -O0 --gcc-install-dir=/opt/rh/gcc-toolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11

0 Kudos
jboline
New Contributor I
754 Views

No luck, I get the same error message

0 Kudos
jboline
New Contributor I
751 Views

What do you get for "icx -v"? I am wondering if my target string could be messing things up:

 

$ icx -v
Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.1.0.20240308)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2024.1/bin/compiler
Configuration file: /opt/intel/oneapi/compiler/2024.1/bin/compiler/../icx.cfg
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/11
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

0 Kudos
Viet_H_Intel
Moderator
748 Views

Not sure what happens with your system.

It worked for me with --gcc-install-dir flag.

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math t5.c -Wno-implicit-function-declaration -O0
/usr/bin/ld: /tmp/icx-d4bfb2a574/t5-9cbced.o: in function `main':
t5.c:(.text+0x16): undefined reference to `__truncdfhf2'
icx: error: linker command failed with exit code 1 (use -v to see invocation)
$ gcc -v
gcc version 8.1.0 (GCC)

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math t5.c -Wno-implicit-function-declaration -O0 --gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/11

$ cat t5.c
#include <mathimf.h>
#include <stdio.h>

int main()
{
_Float16 a;
a = sin(1.0);

printf("%f\n", (float) a);
}

 

$ icx -v
Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.1.0.20240308)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /installed-dir/compiler/2024.1/bin/compiler
Configuration file: /installed-dir/compiler/2024.1/bin/compiler/../icx.cfg
Found candidate GCC installation: /installed-dir/gcc-8.1.0/lib/gcc/x86_64-pc-linux-gnu/8.1.0
Selected GCC installation: /installed-dir/gcc-8.1.0/lib/gcc/x86_64-pc-linux-gnu/8.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

0 Kudos
Viet_H_Intel
Moderator
746 Views

Can you try gcc11.4.0, instead of 11.2.1?

0 Kudos
jboline
New Contributor I
703 Views

Trying on rhel 9.4 it doesn't work either

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math test.c -Wno-implicit-function-declaration -O0 --gcc-install-dir=/usr/lib/gcc/x86_64-redhat-linux/11
/usr/bin/ld: /tmp/icx-556f0b3013/test-755a4c.o: in function `main':
test.c:(.text+0x16): undefined reference to `__truncdfhf2'
icx: error: linker command failed with exit code 1 (use -v to see invocation)

 

GCC version is 11.4.1

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-host-pie --enable-host-bind-now --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --enable-initfini-array --without-isl --enable-multilib --with-linker-hash-style=gnu --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_64=x86-64-v2 --with-arch_32=x86-64 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.1 20231218 (Red Hat 11.4.1-3) (GCC)

0 Kudos
jboline
New Contributor I
656 Views

Here is some more info from the compilation

$ icx -march=znver2 -ffp-eval-method=source -fno-fast-math -Wno-implicit-function-declaration -O0 --gcc-install-dir=/usr/lib/gcc/x86_64-redhat-linux/11/ test.c -v
Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.1.0.20240308)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2024.1/bin/compiler
Configuration file: /opt/intel/oneapi/compiler/2024.1/bin/compiler/../icx.cfg
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/opt/intel/oneapi/compiler/2024.1/bin/compiler/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model static -fveclib=SVML -mframe-pointer=all -fmath-errno -ffp-contract=fast -fno-rounding-math -ffp-eval-method=source -mconstructor-aliases -funwind-tables=2 -target-cpu znver2 -mllvm -x86-enable-unaligned-vector-move=true -debugger-tuning=gdb -fdebug-compilation-dir=/local/home/1152177/fp16/test -v -fcoverage-compilation-dir=/local/home/1152177/fp16/test -fclang-abi-compat=17 -resource-dir /opt/intel/oneapi/compiler/2024.1/lib/clang/18 -I/opt/intel/oneapi/2024.1/include/dal -I/opt/intel/oneapi/2024.1/opt/oclfpga/include -c-isystem /opt/intel/oneapi/2024.1/include -cxx-isystem /opt/intel/oneapi/2024.1/include -internal-isystem /opt/intel/oneapi/compiler/2024.1/bin/compiler/../../opt/compiler/include -internal-isystem /opt/intel/oneapi/compiler/2024.1/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-implicit-function-declaration -ferror-limit 19 -fheinous-gnu-extensions -fgnuc-version=4.2.1 -fcolor-diagnostics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -fintel-compatibility -fintel-libirc-allowed -mllvm -disable-hir-generate-mkl-call -mllvm -loopopt=1 -floopopt-pipeline=light -mllvm -intel-abi-compatible=true -o /tmp/icx-80e2593b37/test-da8a95.o -x c test.c
clang -cc1 version 18.0.0 based upon LLVM 18.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/intel/oneapi/2024.1/include/dal
/opt/intel/oneapi/2024.1/opt/oclfpga/include
/opt/intel/oneapi/2024.1/include
/opt/intel/oneapi/compiler/2024.1/bin/compiler/../../opt/compiler/include
/opt/intel/oneapi/compiler/2024.1/lib/clang/18/include
/usr/include
End of search list.
"/usr/bin/ld" --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/11/crtbegin.o -L/opt/intel/oneapi/compiler/2024.1/bin/compiler/../../lib -L/opt/intel/oneapi/compiler/2024.1/bin/compiler/../../lib -L/opt/intel/oneapi/compiler/2024.1/lib/clang/18/lib/x86_64-unknown-linux-gnu -L/opt/intel/oneapi/compiler/2024.1/bin/compiler/../../lib -L/usr/lib/gcc/x86_64-redhat-linux/11 -L/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/11/../../.. -L/opt/intel/oneapi/compiler/2024.1/bin/compiler/../../lib -L/opt/intel/oneapi/compiler/2024.1/bin/compiler/../../opt/compiler/lib -L/lib -L/usr/lib -L/opt/intel/oneapi/2024.1/lib /tmp/icx-80e2593b37/test-da8a95.o -Bstatic -lsvml -Bdynamic -Bstatic -lirng -Bdynamic -Bstatic -limf -Bdynamic -lm -lgcc --as-needed -lgcc_s --no-as-needed -Bstatic -lirc -Bdynamic -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed -Bstatic -lirc_s -Bdynamic /usr/lib/gcc/x86_64-redhat-linux/11/crtend.o /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/crtn.o
/usr/bin/ld: /tmp/icx-80e2593b37/test-da8a95.o: in function `main':
test.c:(.text+0x16): undefined reference to `__truncdfhf2'
icx: error: linker command failed with exit code 1 (use -v to see invocation)

0 Kudos
Viet_H_Intel
Moderator
650 Views

Can you send the output of:

 

icx -march=znver2 -ffp-eval-method=source -fno-fast-math -Wno-implicit-function-declaration -O0 -# test.c >& output.out

0 Kudos
jboline
New Contributor I
649 Views

Ok, I actually got it to work. For some reason I need to add the flag "-rtlib=compiler-rt", but I also must use oneapi version 2025 else I get errors about libclang_rt.builtins-x86_64.a missing:

/usr/bin/ld: cannot find /opt/intel/oneapi/compiler/2024.1/lib/clang/18/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
/usr/bin/ld: cannot find /opt/intel/oneapi/compiler/2024.1/lib/clang/18/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory

 

It seems oneapi version 2025 added libclang_rt.builtins because I see libclang_rt.builtins.a in the install directory while it is missing for 2024

0 Kudos
Reply