diff --git a/openmp/libomptarget/DeviceRTL/include/Debug.h b/openmp/libomptarget/DeviceRTL/include/Debug.h --- a/openmp/libomptarget/DeviceRTL/include/Debug.h +++ b/openmp/libomptarget/DeviceRTL/include/Debug.h @@ -25,9 +25,24 @@ ///} -// TODO: We need to allow actual printf. -#define PRINTF(fmt, ...) (void)fmt; +/// Print +/// TODO: For now we have to use macros to guard the code because Clang lowers +/// `printf` to different function calls on NVPTX and AMDGCN platforms, and it +/// doesn't work for AMDGCN. After it can work on AMDGCN, we will remove the +/// macro. +/// { + +#ifndef __AMDGCN__ +extern "C" { +int printf(const char *format, ...); +} + +#define PRINTF(fmt, ...) (void)printf(fmt, __VA_ARGS__); #define PRINT(str) PRINTF("%s", str) +#else +#define PRINTF(fmt, ...) +#define PRINT(str) +#endif ///}