Skip to content

Conversation

@fweig
Copy link
Contributor

@fweig fweig commented Jul 23, 2025

Fixes #122453.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Jul 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 23, 2025

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: Felix Weiglhofer (fweig)

Changes

Fixes #122453.


Full diff: https://github.com/llvm/llvm-project/pull/150210.diff

1 Files Affected:

  • (modified) clang/lib/Headers/opencl-c-base.h (+9-1)
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

@llvmbot
Copy link
Member

llvmbot commented Jul 23, 2025

@llvm/pr-subscribers-backend-x86

Author: Felix Weiglhofer (fweig)

Changes

Fixes #122453.


Full diff: https://github.com/llvm/llvm-project/pull/150210.diff

1 Files Affected:

  • (modified) clang/lib/Headers/opencl-c-base.h (+9-1)
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

@svenvh svenvh added OpenCL and removed backend:X86 labels Jul 28, 2025
@github-actions
Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

@github-actions
Copy link

github-actions bot commented Jul 28, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@fweig
Copy link
Contributor Author

fweig commented Jul 28, 2025

Updated PR:

  • Fixed formatting
  • Used public email for commit author

@fweig
Copy link
Contributor Author

fweig commented Jul 28, 2025

@svenvh, could this fix be backported to the 20.x branch? It might be a while until our OpenCL runtime (PoCL) supports newer Clang versions.

@svenvh
Copy link
Member

svenvh commented Jul 28, 2025

@svenvh, could this fix be backported to the 20.x branch? It might be a while until our OpenCL runtime (PoCL) supports newer Clang versions.

Correct me if I'm wrong, but I believe release/20.x is now closed and no more 20.x releases are being planned.
We can backport it to 21.x if that helps (but that won't help 20.x based environments).

@fweig
Copy link
Contributor Author

fweig commented Jul 28, 2025

Correct me if I'm wrong, but I believe release/20.x is now closed and no more 20.x releases are being planned. We can backport it to 21.x if that helps (but that won't help 20.x based environments).

Thanks for the info. I'm not very familiar with LLVM release policies. Backport to 21.x would help too. We'll have to live with patching until we can switch to LLVM >=21...

@svenvh svenvh merged commit a22d010 into llvm:main Jul 28, 2025
10 checks passed
@github-actions
Copy link

@fweig Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@svenvh
Copy link
Member

svenvh commented Jul 28, 2025

/cherry-pick a22d010

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 28, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-5 while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/24352

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
84.959 [233/8/5934] Linking CXX executable bin/diagtool
85.582 [232/8/5935] Linking CXX executable bin/lld
89.259 [231/8/5936] Linking CXX shared library lib/libLTO.dylib
89.882 [230/8/5937] Linking CXX executable bin/llvm-lto
90.337 [229/8/5938] Linking CXX executable tools/lld/unittests/AsLibELF/LLDAsLibELFTests
90.456 [228/8/5939] Linking CXX executable bin/clang-diff
90.745 [227/8/5940] Linking CXX executable bin/clang-offload-packager
91.365 [226/8/5941] Linking CXX executable bin/clang-offload-bundler
92.742 [225/8/5942] Linking CXX executable tools/lld/unittests/AsLibAll/LLDAsLibAllTests
93.371 [224/8/5943] Linking CXX executable bin/clang-repl
FAILED: [code=1] bin/clang-repl 
: && /opt/homebrew/opt/ccache/libexec/clang++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-no_warn_duplicate_libraries -rdynamic tools/clang/tools/clang-repl/CMakeFiles/clang-repl.dir/ClangRepl.cpp.o -o bin/clang-repl  -Wl,-rpath,@loader_path/../lib  lib/libLLVMAArch64CodeGen.a  lib/libLLVMAArch64AsmParser.a  lib/libLLVMAArch64Desc.a  lib/libLLVMAArch64Disassembler.a  lib/libLLVMAArch64Info.a  lib/libLLVMAArch64Utils.a  lib/libLLVMCore.a  lib/libLLVMLineEditor.a  lib/libLLVMOption.a  lib/libLLVMOrcJIT.a  lib/libLLVMOrcShared.a  lib/libLLVMSupport.a  lib/libLLVMTargetParser.a  lib/libclangAST.a  lib/libclangBasic.a  lib/libclangFrontend.a  lib/libclangInterpreter.a  /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/lib/libedit.tbd  lib/libLLVMAArch64CodeGen.a  lib/libLLVMAsmPrinter.a  lib/libLLVMAArch64AsmParser.a  lib/libLLVMAArch64Disassembler.a  lib/libLLVMAArch64Desc.a  lib/libLLVMMCDisassembler.a  lib/libLLVMAArch64Info.a  lib/libLLVMAArch64Utils.a  lib/libclangFrontendTool.a  lib/libclangCodeGen.a  lib/libLLVMCoverage.a  lib/libLLVMFrontendDriver.a  lib/libLLVMLTO.a  lib/libLLVMExtensions.a  lib/libclangExtractAPI.a  lib/libclangInstallAPI.a  lib/libLLVMTextAPIBinaryReader.a  lib/libclangRewriteFrontend.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangIndex.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libclangParse.a  lib/libclangSerialization.a  lib/libclangSema.a  lib/libclangAPINotes.a  lib/libclangEdit.a  lib/libclangAnalysis.a  lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libLLVMFrontendHLSL.a  lib/libclangSupport.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangToolingCore.a  lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libLLVMOrcDebugging.a  lib/libLLVMOrcJIT.a  lib/libLLVMPasses.a  lib/libLLVMCFGuard.a  lib/libLLVMGlobalISel.a  lib/libLLVMSelectionDAG.a  lib/libLLVMCodeGen.a  lib/libLLVMCGData.a  lib/libLLVMCodeGenTypes.a  lib/libLLVMObjCARCOpts.a  lib/libLLVMCoroutines.a  lib/libLLVMHipStdPar.a  lib/libLLVMipo.a  lib/libLLVMVectorize.a  lib/libLLVMSandboxIR.a  lib/libLLVMBitWriter.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMScalarOpts.a  lib/libLLVMFrontendOffloading.a  lib/libLLVMObjectYAML.a  lib/libLLVMFrontendAtomic.a  lib/libLLVMFrontendDirective.a  lib/libLLVMAggressiveInstCombine.a  lib/libLLVMInstCombine.a  lib/libLLVMLinker.a  lib/libLLVMIRPrinter.a  lib/libLLVMInstrumentation.a  lib/libLLVMTransformUtils.a  lib/libLLVMExecutionEngine.a  lib/libLLVMTarget.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoGSYM.a  lib/libLLVMDebugInfoPDB.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMDebugInfoBTF.a  lib/libLLVMWindowsDriver.a  lib/libLLVMRuntimeDyld.a  lib/libLLVMJITLink.a  lib/libLLVMOption.a  lib/libLLVMOrcTargetProcess.a  lib/libLLVMOrcShared.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMObject.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMTextAPI.a  lib/libLLVMIRReader.a  lib/libLLVMBitReader.a  lib/libLLVMAsmParser.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMDebugInfoDWARFLowLevel.a  lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  lib/libLLVMDemangle.a  -lm  /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/lib/libz.tbd  /opt/homebrew/lib/libzstd.dylib && :
ld: write() failed, errno=28
clang: error: linker command failed with exit code 1 (use -v to see invocation)
94.382 [224/7/5944] Linking CXX executable bin/clang-linker-wrapper
99.734 [224/6/5945] Linking CXX executable bin/clang-nvlink-wrapper
100.244 [224/5/5946] Linking CXX executable bin/clang-sycl-linker
100.572 [224/4/5947] Linking CXX executable bin/clang-import-test
101.970 [224/3/5948] Linking CXX executable bin/clang-scan-deps
102.326 [224/2/5949] Linking CXX executable bin/clang-installapi
102.869 [224/1/5950] Linking CXX executable bin/c-index-test
ninja: build stopped: subcommand failed.

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2025

/pull-request #150960

@llvmbot llvmbot moved this from Needs Triage to Done in LLVM Release Status Jul 28, 2025
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 29, 2025
@svenvh
Copy link
Member

svenvh commented Jul 29, 2025

Backport to 21.x would help too

This has now been backported to the release/21.x branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category OpenCL

Projects

Development

Successfully merging this pull request may close these issues.

OpenCL C++: printf becomes mangled c++ symbol, not working with e.g. pocl and llvm-spirv

4 participants