Skip to content

build(hipfile): fix HIPFILE_WARN_UNSAFE_BUFFER_OPS and default it to OFF - #12939

Merged
derobins merged 3 commits into
developfrom
users/derobins/safe_buffers
Oct 7, 2026
Merged

derobins merged 3 commits into
developfrom
users/derobins/safe_buffers

Conversation

@derobins

@derobins derobins commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Fixing incidental findings while updating hipFile CMake

Technical Details

The option added -Wunsafe-buffer-usage and
-fsafe-buffer-usage-suggestions to a warning-flags variable that nothing used, so the flags never reached the compiler.

The flags are now added in hipfile_set_compiler_flags() for C++ sources compiled with Clang. HIP sources are excluded since kernels use raw pointers by necessity, and the flags are skipped with IWYU, like the other warning flags.

With the flags actually applied, the build produces a few hundred warnings, which would break the -Werror CI builds. The option now defaults to OFF until those are fixed.

Issue Tracking

JIRA ID: AIHIPFILE-296

Test Plan

CI passes

Test Result

Success

Submission Checklist

The option added -Wunsafe-buffer-usage and
-fsafe-buffer-usage-suggestions to a warning-flags variable that
nothing used, so the flags never reached the compiler.

The flags are now added in hipfile_set_compiler_flags() for C++
sources compiled with Clang. HIP sources are excluded since kernels
use raw pointers by necessity, and the flags are skipped with IWYU,
like the other warning flags.

With the flags actually applied, the build produces a few hundred
warnings, which would break the -Werror CI builds. The option now
defaults to OFF until those are fixed.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:57
@derobins
derobins requested review from a team as code owners October 6, 2026 17:57
@therock-pr-bot

therock-pr-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass PR does not contain code files — Unit Test auto-passed
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Isolated CMake generation confirmed correct flag handling, and no blocking issues remain.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes hipFile’s optional unsafe-buffer warnings so the flags reach eligible compiler invocations.

Changes:

  • Applies warning flags to Clang C++ sources, excluding HIP and IWYU builds.
  • Defaults the option to OFF and documents the behavior.
File Description
projects/​hipfile/​cmake/​HipFileCompilerOptions.cmake Applies conditional compiler flags.
projects/​hipfile/​cmake/​HipFileClangSafeBuffers.cmake Disables warnings by default and retains compiler validation.
projects/​hipfile/​CHANGELOG.md Documents the fix and default change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@spolifroni-amd spolifroni-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minior change to that first one, but otherwise fine.

Comment thread projects/hipfile/CHANGELOG.md Resolved
Co-authored-by: spolifroni-amd <Sandra.Polifroni@amd.com>
Comment thread projects/hipfile/CHANGELOG.md Resolved
Co-authored-by: spolifroni-amd <Sandra.Polifroni@amd.com>
@derobins
derobins merged commit 3eeb3b8 into develop Oct 7, 2026
254 of 262 checks passed
@derobins
derobins deleted the users/derobins/safe_buffers branch October 7, 2026 14:11
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

anujshuk-amd pushed a commit that referenced this pull request Oct 12, 2026
…OFF (#12939)

## Motivation

Fixing incidental findings while updating hipFile CMake

## Technical Details

The option added -Wunsafe-buffer-usage and
-fsafe-buffer-usage-suggestions to a warning-flags variable that nothing
used, so the flags never reached the compiler.

The flags are now added in hipfile_set_compiler_flags() for C++ sources
compiled with Clang. HIP sources are excluded since kernels use raw
pointers by necessity, and the flags are skipped with IWYU, like the
other warning flags.

With the flags actually applied, the build produces a few hundred
warnings, which would break the -Werror CI builds. The option now
defaults to OFF until those are fixed.

## Issue Tracking

JIRA ID: AIHIPFILE-296

## Test Plan

CI passes

## Test Result

Success

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.

---------

Co-authored-by: spolifroni-amd <Sandra.Polifroni@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants