File: clang-21-compat.patch

package info (click to toggle)
hipify 7.0.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 10,336 kB
  • sloc: cpp: 31,275; perl: 17,300; sh: 167; ruby: 23; python: 10; makefile: 9; ansic: 4
file content (39 lines) | stat: -rw-r--r-- 2,031 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 6b6e9f1a81b1a0f74d85583743ce45ba7f037819 Mon Sep 17 00:00:00 2001
From: Evgeny Mankov <evgeny.mankov@gmail.com>
Date: Thu, 29 May 2025 23:18:57 +0200
Subject: [PATCH] [HIPIFY][clang][compatibility][fix] clang `21.0.0git`
 compatibility fix

[Root Cause]
+ [LLVM][#139584](https://github.com/llvm/llvm-project/pull/139584)[clang] Remove intrusive reference count from `DiagnosticOptions`

[IMP]
+ `LLVM < 21` is also supported, but `LLVM 21` should be newer than [671cd5acb49f9fae274f66cd71464d4afed914e3](https://github.com/llvm/llvm-project/pull/139584/commits/671cd5acb49f9fae274f66cd71464d4afed914e3) (2025-05-20) to build `hipify-clang` correctly

[Note]
+ Unfortunately, the class `DiagnosticsEngine` has assignment operator and copy ctor both marked as `delete`, thus the compatibility patch can't be implemented as a separate function in the `llcompat` namespace

Applied-Upstream: https://github.com/ROCm/HIPIFY/commit/6b6e9f1a81b1a0f74d85583743ce45ba7f037819
Forwarded: not-needed
---
 src/main.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

--- a/src/main.cpp
+++ b/src/main.cpp
@@ -81,9 +81,15 @@
 
 void sortInputFiles(int argc, const char **argv, std::vector<std::string> &files) {
   if (files.size() < 2) return;
+#if LLVM_VERSION_MAJOR >= 21
+  clang::DiagnosticOptions diagOpts;
+  clang::TextDiagnosticPrinter diagClient(llvm::errs(), diagOpts);
+  clang::DiagnosticsEngine Diagnostics(IntrusiveRefCntPtr<clang::DiagnosticIDs>(new clang::DiagnosticIDs()), diagOpts, &diagClient, false);
+#else
   IntrusiveRefCntPtr<clang::DiagnosticOptions> diagOpts(new clang::DiagnosticOptions());
   clang::TextDiagnosticPrinter diagClient(llvm::errs(), &*diagOpts);
   clang::DiagnosticsEngine Diagnostics(IntrusiveRefCntPtr<clang::DiagnosticIDs>(new clang::DiagnosticIDs()), &*diagOpts, &diagClient, false);
+#endif
   std::unique_ptr<clang::driver::Driver> driver(new clang::driver::Driver("", "nvptx64-nvidia-cuda", Diagnostics));
   std::vector<const char*> Args(argv, argv + argc);
   cleanupHipifyOptions(Args);