[compiler-rt] [compiler-rt] Fix ubsan_minimal compilation error for GPU targets (PR #214392)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 20:51:06 PDT 2026


jinge90 wrote:

Hi, @jhuber6 
I accidentally spoiled https://github.com/llvm/llvm-project/pull/214143, so have to create a new PR. I moved your previous question here:

"I'm assuming this just implicitly assumes you have the libc for GPU on the system. I'm surprised this works without those headers."

In fact, these 2 headers are useless for GPU. ubsan_minial uses abort (stdlib.h) and strlen (string.h) in source code but these 2 functions are only used for non-GPU targets.
For strlen: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp#L24
It is used im 'message' function but this function has several versions, 'strlen' is used only when !KERNEL_USE && !(SANITIZER_AMDGPU || SANITIZER_NVPTX || SANITIZER_SPIRV) is true.
For abort, ubsan_minimal doesn't use it for GPU but used 'trap' builtin instead.

If we dump IR for ubsam_minimal on Linux, there will be no 'strlen' or 'abort' in it.

Thanks very much. 


https://github.com/llvm/llvm-project/pull/214392


More information about the llvm-commits mailing list