Skip to content

Use a temp directory for CMake build - #3254

Open
fheinecke wants to merge 4 commits into
NVIDIA:mainfrom
fheinecke:fred/cmake-build-isolation-1
Open

Use a temp directory for CMake build#3254
fheinecke wants to merge 4 commits into
NVIDIA:mainfrom
fheinecke:fred/cmake-build-isolation-1

Conversation

@fheinecke

Copy link
Copy Markdown
Collaborator

Description

CMake currently always uses ./build/cmake as a build directory when NVTE_CMAKE_BUILD_DIR is not set. This causes a couple of issues:

  • Builds can collide with each other
  • Generated files can become stale and require cleaning prior to every build
  • Build files are not cleaned up upon success nor failure

This creates a temporary directory and cleans it up afterwards. Note: this makes it harder to inspect the build directory, because it will now be cleaned up after every run. For this use case I would recommend setting `NVTE_CMAKE_BUILD_DIR="${PWD}/build/cmake" to retain the current behavior. As a result of moving to a temp directory, object files will now not be reused between builds as well.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • CMake extension builds are now isolated

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: Fred Heinecke <fheinecke@nvidia.com>
@fheinecke

Copy link
Copy Markdown
Collaborator Author

/te-ci

@fheinecke

Copy link
Copy Markdown
Collaborator Author

The failing job is a scheduling timeout for a GPU-specific runner that was having some issues next week. Going to assume that it's unrelated.

@fheinecke

Copy link
Copy Markdown
Collaborator Author

/te-ci

@fheinecke
fheinecke marked this pull request as ready for review August 3, 2026 22:04
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR isolates non-editable CMake extension builds in automatically cleaned temporary directories while retaining persistent incremental builds for editable installs or when NVTE_CMAKE_BUILD_DIR is configured.

  • Creates unique CMake build directories beneath setuptools’ build-temp directory.
  • Cleans temporary CMake state after successful or failed builds.
  • Preserves build/cmake for in-place builds and explicit build-directory overrides.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
build_tools/build_ext.py Selects persistent or temporary CMake build directories based on environment and editable-build state, with scoped automatic cleanup.

Reviews (2): Last reviewed commit: "Add fallback to exisiting build dir beha..." | Re-trigger Greptile

@ptrendx

ptrendx commented Aug 4, 2026

Copy link
Copy Markdown
Member

Hmm, this has a potential of being a little disruptive (especially considering that the time needed to build TE is quite long). Could there maybe be some middle ground where e.g. the -e builds (develop and in-place) could use the in-place build directory and the regular installation would use the temp instead?

…nstall

Signed-off-by: Fred Heinecke <fheinecke@nvidia.com>
@fheinecke

Copy link
Copy Markdown
Collaborator Author

Good catch - added

@fheinecke

Copy link
Copy Markdown
Collaborator Author

/te-ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants