[clang] opencl: Ensure printf symbol is not mangled. (PR #150210)
Felix Weiglhofer via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 23 04:24:59 PDT 2025
https://github.com/fweig created https://github.com/llvm/llvm-project/pull/150210
Fixes #122453.
>From 6762eed20ceb733a240b81a4379c8c3890d4907d Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <9267733+fweig at users.noreply.github.com>
Date: Mon, 21 Jul 2025 11:31:36 +0200
Subject: [PATCH] opencl: Ensure printf symbol is not mangled.
---
clang/lib/Headers/opencl-c-base.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
index 2b7f5043e09e4..49987a044e253 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -697,7 +697,15 @@ template <typename _Tp> struct __remove_address_space<__constant _Tp> {
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
-int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
+#ifdef __OPENCL_CPP_VERSION__
+#define CLINKAGE extern "C"
+#else
+#define CLINKAGE
+#endif
+
+CLINKAGE int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
+
+#undef CLINKAGE
#endif
#ifdef cl_intel_device_side_avc_motion_estimation
More information about the cfe-commits
mailing list