[compiler-rt] [compiler-rt] Define `__STDC_FORMAT_MACROS` to ensure `PRId64` is available (PR #102980)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 14:17:56 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Mosè Giordano (giordano)
<details>
<summary>Changes</summary>
In https://github.com/JuliaPackaging/Yggdrasil/pull/9246#issuecomment-2284894139 we ran into
```
[20:54:03] In file included from /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.cpp:9:
[20:54:03] /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.h: In member function ‘void scudo::TimingManager::printImpl(scudo::ScopedString&, scudo::u32, scudo::u32)’:
[20:54:03] /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.h:182:21: error: expected ‘)’ before ‘PRId64’
[20:54:03] Str.append("%14" PRId64 ".%" PRId64 "(ns) %-11s", Integral, Fraction, " ");
[20:54:03] ~ ^~~~~~~
[20:54:03] )
[20:54:03] /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.h:182:16: warning: conversion lacks type at end of format [-Wformat=]
[20:54:03] Str.append("%14" PRId64 ".%" PRId64 "(ns) %-11s", Integral, Fraction, " ");
[20:54:03] ^~~~~
[20:54:03] /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.h:182:16: warning: too many arguments for format [-Wformat-extra-args]
[20:54:03] /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.h:186:23: error: expected ‘)’ before ‘PRId64’
[20:54:03] Str.append("%s (%" PRId64 ")\n", Timers[HandleId].Name, Occurrence);
[20:54:03] ~ ^~~~~~~
[20:54:03] )
[20:54:03] /workspace/srcdir/compiler-rt-17.0.6.src/lib/scudo/standalone/timing.h:186:16: warning: spurious trailing ‘%’ in format [-Wformat=]
[20:54:03] Str.append("%s (%" PRId64 ")\n", Timers[HandleId].Name, Occurrence);
[20:54:03] ^~~~~~~
```
when compiling compiler-rt with GCC 8. This was resolved by defining `__STDC_FORMAT_MACROS`.
---
Full diff: https://github.com/llvm/llvm-project/pull/102980.diff
1 Files Affected:
- (modified) compiler-rt/lib/scudo/standalone/timing.h (+2)
``````````diff
diff --git a/compiler-rt/lib/scudo/standalone/timing.h b/compiler-rt/lib/scudo/standalone/timing.h
index de741edbff5fff..e125d6bdf558e7 100644
--- a/compiler-rt/lib/scudo/standalone/timing.h
+++ b/compiler-rt/lib/scudo/standalone/timing.h
@@ -14,6 +14,8 @@
#include "string_utils.h"
#include "thread_annotations.h"
+// Ensure PRId64 macro is available
+#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <string.h>
``````````
</details>
https://github.com/llvm/llvm-project/pull/102980
More information about the llvm-commits
mailing list