Skip to content

Conversation

@mgehre-amd
Copy link
Contributor

@mgehre-amd mgehre-amd commented Jan 8, 2026

hip_prof_gen.py writes the generated hip_prof_str.h to both the build directory and the source directory. The hip_prof_str.h in the source directory (which is also an input to hip_prof_gen.py) thus gets its mtime updated. Ninja sees the source file as 'newer' than the build output and triggers a rebuild on every invocation.
This is particularly problematic in TheRock, where this can triggers rebuilds of downstream components.

Fix: Only write to the source file if content actually changed, avoiding unnecessary mtime updates that trigger rebuilds.

Test Plan

Reproducer (before fix):

  cd build/core/clr/build
  rm -f hipamd/include/hip/amd_detail/hip_prof_str.h
  ninja gen-prof-api-str-header
  ninja gen-prof-api-str-header -d explain
  # Output shows rebuild even though nothing changed:
  # ninja explain: recorded mtime of .../hip_prof_str.h older than
  #   most recent input .../hip_prof_str.h (807560042 vs 826560006)

Test Result

No rebuild happens

Submission Checklist

hip_prof_gen.py writes the generated hip_prof_str.h to both the build
directory and the source directory. Since the source file is written
after the build output, it has a newer mtime (~19ns later). Ninja sees
the source file as 'newer' than the build output and triggers a rebuild
on every invocation.

Reproducer (before fix):
  cd build/core/clr/build
  rm -f hipamd/include/hip/amd_detail/hip_prof_str.h
  ninja gen-prof-api-str-header
  ninja gen-prof-api-str-header -d explain
  # Output shows rebuild even though nothing changed:
  # ninja explain: recorded mtime of .../hip_prof_str.h older than
  #   most recent input .../hip_prof_str.h (807560042 vs 826560006)

Fix: Only write to the source file if content actually changed,
avoiding unnecessary mtime updates that trigger rebuilds.
@mgehre-amd mgehre-amd requested a review from mangupta January 12, 2026 18:18
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.

3 participants