Skip to content

Commit 1556bb5

Browse files
committed
Fix builds for clang 21
1 parent adeae23 commit 1556bb5

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

build/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ mlir-*)
357357
elif [[ $MAJOR -eq 12 ]]; then
358358
PATCHES_TO_APPLY+=("${ROOT}/patches/ce-debug-clang-12.patch")
359359
LLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly"
360+
elif [[ $MAJOR -le 21 ]]; then
361+
PATCHES_TO_APPLY+=("${ROOT}/patches/ce-debug-clang-13.patch")
362+
LLVM_EXPERIMENTAL_TARGETS_TO_BUILD="M68K;WebAssembly"
360363
else
361364
PATCHES_TO_APPLY+=("${ROOT}/patches/ce-debug-clang-trunk.patch")
362365
LLVM_EXPERIMENTAL_TARGETS_TO_BUILD="M68k;WebAssembly"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
commit 445c6dd4845daf2fbc5e8e8b9bac6a39cd90a470
2+
Author: partouf <[email protected]>
3+
Date: Sat Dec 10 14:07:08 2022 +0100
4+
5+
change dbgs() in case of --debug-to-stdout
6+
7+
diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp
8+
index 98a9ac4722b5..a04aabe67627 100644
9+
--- a/llvm/lib/Support/Debug.cpp
10+
+++ b/llvm/lib/Support/Debug.cpp
11+
@@ -78,6 +78,11 @@ void setCurrentDebugTypes(const char **Types, unsigned Count) {
12+
}
13+
} // namespace llvm
14+
15+
+cl::opt<bool> LogDebugToStdOut(
16+
+ "debug-to-stdout",
17+
+ llvm::cl::desc("Log debugging to stdout instead of stderr"),
18+
+ cl::init(false), cl::Hidden);
19+
+
20+
// All Debug.h functionality is a no-op in NDEBUG mode.
21+
#ifndef NDEBUG
22+
23+
@@ -161,23 +166,27 @@ static void debug_user_sig_handler(void *Cookie) {
24+
25+
/// dbgs - Return a circular-buffered debug stream.
26+
raw_ostream &llvm::dbgs() {
27+
- // Do one-time initialization in a thread-safe way.
28+
- static struct dbgstream {
29+
- circular_raw_ostream strm;
30+
-
31+
- dbgstream()
32+
- : strm(errs(), "*** Debug Log Output ***\n",
33+
- (!EnableDebugBuffering || !DebugFlag) ? 0 : *DebugBufferSize) {
34+
- if (EnableDebugBuffering && DebugFlag && *DebugBufferSize != 0)
35+
- // TODO: Add a handler for SIGUSER1-type signals so the user can
36+
- // force a debug dump.
37+
- sys::AddSignalHandler(&debug_user_sig_handler, nullptr);
38+
- // Otherwise we've already set the debug stream buffer size to
39+
- // zero, disabling buffering so it will output directly to errs().
40+
- }
41+
- } thestrm;
42+
-
43+
- return thestrm.strm;
44+
+ if (LogDebugToStdOut) {
45+
+ return outs();
46+
+ } else {
47+
+ // Do one-time initialization in a thread-safe way.
48+
+ static struct dbgstream {
49+
+ circular_raw_ostream strm;
50+
+
51+
+ dbgstream()
52+
+ : strm(errs(), "*** Debug Log Output ***\n",
53+
+ (!EnableDebugBuffering || !DebugFlag) ? 0 : *DebugBufferSize) {
54+
+ if (EnableDebugBuffering && DebugFlag && *DebugBufferSize != 0)
55+
+ // TODO: Add a handler for SIGUSER1-type signals so the user can
56+
+ // force a debug dump.
57+
+ sys::AddSignalHandler(&debug_user_sig_handler, nullptr);
58+
+ // Otherwise we've already set the debug stream buffer size to
59+
+ // zero, disabling buffering so it will output directly to errs().
60+
+ }
61+
+ } thestrm;
62+
+
63+
+ return thestrm.strm;
64+
+ }
65+
}
66+
67+
#else
68+
@@ -185,7 +194,11 @@ raw_ostream &llvm::dbgs() {
69+
namespace llvm {
70+
/// dbgs - Return errs().
71+
raw_ostream &dbgs() {
72+
- return errs();
73+
+ if (LogDebugToStdOut) {
74+
+ return outs();
75+
+ } else {
76+
+ return errs();
77+
+ }
78+
}
79+
}
80+
void llvm::initDebugOptions() {}

0 commit comments

Comments
 (0)