diff --git a/clang/lib/Headers/llvm_libc_wrappers/ctype.h b/clang/lib/Headers/llvm_libc_wrappers/ctype.h index 084c5a97765a3..49c2af93471b0 100644 --- a/clang/lib/Headers/llvm_libc_wrappers/ctype.h +++ b/clang/lib/Headers/llvm_libc_wrappers/ctype.h @@ -13,8 +13,19 @@ #error "This file is for GPU offloading compilation only" #endif +// The GNU headers like to define 'toupper' and 'tolower' redundantly. This is +// necessary to prevent it from doing that and remapping our implementation. +#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(__GLIBC__) +#pragma push_macro("__USE_EXTERN_INLINES") +#undef __USE_EXTERN_INLINES +#endif + #include_next +#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(__GLIBC__) +#pragma pop_macro("__USE_EXTERN_INLINES") +#endif + #if __has_include() #if defined(__HIP__) || defined(__CUDA__)