Hi everyone, I’m new here. I am interested in supporting llvm data type bfloat16 as i know from here
I tried to get bundle version of llvm and subprojects via this source, but got an error with linker
/usr/bin/ld: /tmp/check_compiler-6f7408.o: in function `intend(__bf16)':
check_compiler.cpp:(.text+0x14): undefined reference to `__truncsfbf2'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
source code of check_compiler.cpp is pretty simple
#include <cmath>
#include <stdio.h>
#include <immintrin.h>
#include <x86intrin.h>
__bf16 intend(__bf16 x) {
return x;
}
int main() {
__bf16 kek;
kek = intend(kek);
float t;
// float r = _mm_cvtsbh_ss(kek);
}
and works just like a COMPILER_RT_HAS_x86_64_BFLOAT16 Test from compiler-rt.
Then i tried to build llvm, clang and compiler-rt from work tree (git sources) with ninja with this commands:
sudo cmake -Wno-dev -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_LLD=ON -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 -DLLVM_ENABLE_RUNTIMES=compiler-rt -DLLVM_ENABLE_LIBCXX=ON -DCLANG_DEFAULT_CXX_STDLIB=libc++ -DCMAKE_BUILD_TYPE=Release -G Ninja ../llvm
sudo ninja -j10
sudo ninja -j10 install
It logs successful test proceed
Performing C SOURCE FILE Test COMPILER_RT_HAS_x86_64_BFLOAT16 succeeded with the following output:
Change Dir: /home/shaprunovk/clickhouse/llvm/llvm-project/build-llvm/runtimes/builtins-bins/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_c0111 && [1/2] Building C object CMakeFiles/cmTC_c0111.dir/src.c.o
[2/2] Linking C static library libcmTC_c0111.a
Source file was:
__bf16 foo(__bf16 x) { return x; }
and installed static library contains truncdfbf2.c and truncsfbf2.c
-- Up-to-date: /usr/local/lib/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a
But i still can’t compile check_compiler.cpp both with clang++-16 and clang++-17 builded from tree, is there any header i need to include to work with __bf16 or what am I doing wrong?