Author: Joseph Huber Date: 2023-11-14T11:52:43-06:00 New Revision: f3d57583b4942056a930b6f1e4101063637e9e98
URL: https://github.com/llvm/llvm-project/commit/f3d57583b4942056a930b6f1e4101063637e9e98 DIFF: https://github.com/llvm/llvm-project/commit/f3d57583b4942056a930b6f1e4101063637e9e98.diff LOG: [libc] Fix the wrapper headers for 'toupper' and 'tolower' Summary: The GNU headers like to reassign this function to a new function which the optimizer will pick up unless compiling with `O0`. This uses an external LUT which we don't have and fails to link. This patch makes sure that the GPU portion does not include these extra definitions and we only use the ones we support. It's hacky, but it's the only way to disable it. Added: Modified: clang/lib/Headers/llvm_libc_wrappers/ctype.h Removed: ################################################################################ diff --git a/clang/lib/Headers/llvm_libc_wrappers/ctype.h b/clang/lib/Headers/llvm_libc_wrappers/ctype.h index 084c5a97765a360..49c2af93471b0e7 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 <ctype.h> +#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(__GLIBC__) +#pragma pop_macro("__USE_EXTERN_INLINES") +#endif + #if __has_include(<llvm-libc-decls/ctype.h>) #if defined(__HIP__) || defined(__CUDA__) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits