Skip to content

Commit

Permalink
[libc] Fix the wrapper headers for 'toupper' and 'tolower'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhuber6 committed Nov 14, 2023
1 parent f313852 commit f3d5758
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions clang/lib/Headers/llvm_libc_wrappers/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down

0 comments on commit f3d5758

Please sign in to comment.