Building the Compiler-RT Builtins for the New X86 half float ABI on Windows

Hi Folks,

I am currently trying to upgrade a JIT project of ours to LLVM15 and I am struggling to figure out a way to upgrade to handle the Float16 ABI.

Historically we have represented half as a storage format, similar to LLVM14 and before. In our runtime on Windows we would supply our own __extendhfsf2, __gnu_d2h_ieee, etc. With the switch to LLVM15 this no longer works, as would be expected due to the ABI change. Thus I was hoping to lean on compiler-rt to supply the builtins.

I can get the builtin lib using the defines below.

However when I dumpbin the lib the functions I need are External.

SECT4 notype () External | __extendhfsf2

Am I just doing something silly or is my workflow fundamentally flawed?
Is there a workflow I can employ to get the half builtins that will work with the new API and Windows?

Any hints are greatly appreciated


Note Originally I didn’t think the RUNTIME_“target”_BLAHBLAH note for the -D from (How to compile C++ files under compiler-rt with -stdlib=libc++? - #12 by RVP) didn’t pertain to this example. But I honestly didn’t try, running that experiment now just to confirm.

Just as a sanity check I tried

__extendhfsf2 and family are still external.

How about the other functions? Is only __extendhfsf2 external?
Did you build compiler-rt with the new built clang or an old compiler?
IIRC, compiler-rt will detect if _Float16 is supported by compiler before enabling such functions.

Warn: I’m not expert of compiler-rt, I might be wrong or misunderstand something :slight_smile:

Thank you for the response!

Per your questions all the __gnu_X2Y_ieee() functions are External too. I built clang and compiler-rt as part of the same project so they both should be the same version of 15. Also CMake did detect _Float16 as part of the build (at least in the experiment where I used x86_64-pc-windows, I don’t recall if x86_64-pc-windows-msvc found it or not honestly) :
– Performing Test COMPILER_RT_HAS_FLOAT16
– Performing Test COMPILER_RT_HAS_FLOAT16 - Success
– Performing Test COMPILER_RT_HAS_BFLOAT16
– Performing Test COMPILER_RT_HAS_BFLOAT16 - Success