build(rocr): Fix debug builds with clang#8896
Conversation
When creating debuild build with clang, we have build failures introduced by 99a0be1 "rocr/coredump: Extend list of required memory ranges for lightweight cores": .../libamdhsacode/lnx/amd_core_dump.cpp:315:46: warning: flag '#' results in undefined behavior with 'p' conversion specifier [-Wformat] 315 | debug_print("Added aql_queue_t range: %#p - %#p (size: %zu)\n", | ~^~ .../core/util/utils.h:161:21: note: expanded from macro 'debug_print' 161 | fprintf(stderr, fmt, ##__VA_ARGS__); \ | ^~~ .../libamdhsacode/lnx/amd_core_dump.cpp:315:52: warning: flag '#' results in undefined behavior with 'p' conversion specifier [-Wformat] 315 | debug_print("Added aql_queue_t range: %#p - %#p (size: %zu)\n", | ~^~ .../core/util/utils.h:161:21: note: expanded from macro 'debug_print' 161 | fprintf(stderr, fmt, ##__VA_ARGS__); \ | ^~~ .../libamdhsacode/lnx/amd_core_dump.cpp:325:21: error: arithmetic on a pointer to void 324 | static_cast<void*>(aql_queue->amd_queue_.hsa_queue.base_address) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 325 | + aql_queue->amd_queue_.hsa_queue.size * sizeof(hsa_kernel_dispatch_packet_t), | ^ .../core/util/utils.h:161:28: note: expanded from macro 'debug_print' 161 | fprintf(stderr, fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~ .../libamdhsacode/lnx/amd_core_dump.cpp:339:65: error: arithmetic on a pointer to void 339 | static_cast<void*>(queue_info.SaveAreaHeader) + queue_info.SaveAreaSizeInBytes, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ .../core/util/utils.h:161:28: note: expanded from macro 'debug_print' 161 | fprintf(stderr, fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~ 2 warnings and 2 errors generated. This issue does not affect release build, and is not raised by GCC on debug builds either. This patch fixes those build issues.
❌ PR Check — Action Required
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
lamb-j
left a comment
There was a problem hiding this comment.
Fixes the issues hit with the Compiler SPIRV CI, thanks!
cfreeamd
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @cfreeamd)
amd_core_dump.cpp looks correct. All three debug_print conversions replace the non-standard %#p flag and the illegal void* arithmetic (static_cast<void*>(...) + N) with reinterpret_cast<uint64_t>(...) + PRIx64; the end-address arithmetic in each case matches the adjacent filter.add_range() call. (Minor: worth a glance that <cinttypes> is included for PRIx64, though CI passing implies it is.)
Note that uint64_t was already widely used in this file, this patch does not add any new include requirement, just leverage what is already there. |
Motivation
When creating debuild build with clang, we have build failures introduced by 99a0be1 "rocr/coredump: Extend list of required memory ranges for lightweight cores":
This issue does not affect release build, and is not raised by GCC on debug builds either.
This patch fixes those build issues.
Technical Details
Do not use
+onvoid *pointers. Instead, convert thevoid *into auint64_t, and then do math on this. Also adjust the printf format to support uint64_t.Issue Tracking
Test Plan
Produce a debug build.
Test Result
PASS.
Submission Checklist