Skip to content

BUG: Avoid re-extracting the ITK build cache for module dependencies - #307

Open
axel-grc wants to merge 1 commit into
InsightSoftwareConsortium:release-5.4from
axel-grc:fix-tar-exdev-symlink-r54
Open

BUG: Avoid re-extracting the ITK build cache for module dependencies#307
axel-grc wants to merge 1 commit into
InsightSoftwareConsortium:release-5.4from
axel-grc:fix-tar-exdev-symlink-r54

Conversation

@axel-grc

@axel-grc axel-grc commented Sep 1, 2026

Copy link
Copy Markdown

When building a module that depends on another ITK module (e.g. RTK depends on ITKCudaCommon), the ITK build cache is downloaded and extracted once in the parent directory. build-module-deps.sh then symlinks the module directory to that cache (ITKPythonPackage -> ../ITKPythonPackage) and used to re-run the full download-and-extract flow inside the module directory.

Re-extracting in the module directory was problematic for two reasons:

  • Redundant: the same cache was just extracted in the parent directory with the same arguments, and the module directory writes through the symlink into that same shared tree.

  • Recent GNU tar (openat2 jailification, e.g. Ubuntu tar 1.35+dfsg-4ubuntu0.2+) fails with 'Invalid cross-device link' (EXDEV) when extracting members under ITKPythonPackage/ because the symlink escapes the extraction root.

The module dependency build also registers the module (e.g. CudaCommon) into the shared ITK build tree (ITK_DIR) it builds against, so the registration must land in the tree the parent build reuses afterwards. Building against a module-local copy instead of the shared tree breaks serial module dependencies.

Fix: when the parent already holds the extracted cache, build the module directly against the shared tree with
dockcross-manylinux-build-module-wheels.sh, without re-extracting it. When no cache is available (standalone use of build-module-deps.sh), keep the full download-and-extract-and-build path.

When building a module that depends on another ITK module (e.g. RTK
depends on ITKCudaCommon), the ITK build cache is downloaded and
extracted once in the parent directory. build-module-deps.sh then
symlinks the module directory to that cache (ITKPythonPackage ->
../ITKPythonPackage) and used to re-run the full download-and-extract
flow inside the module directory.

Re-extracting in the module directory was problematic for two reasons:

- Redundant: the same cache was just extracted in the parent directory
  with the same arguments, and the module directory writes through the
  symlink into that same shared tree.

- Recent GNU tar (openat2 jailification, e.g. Ubuntu tar
  1.35+dfsg-4ubuntu0.2+) fails with 'Invalid cross-device link' (EXDEV)
  when extracting members under ITKPythonPackage/ because the symlink
  escapes the extraction root.

The module dependency build also registers the module (e.g. CudaCommon)
into the shared ITK build tree (ITK_DIR) it builds against, so the
registration must land in the tree the parent build reuses afterwards.
Building against a module-local copy instead of the shared tree breaks
serial module dependencies.

Fix: when the parent already holds the extracted cache, build the module
directly against the shared tree with
dockcross-manylinux-build-module-wheels.sh, without re-extracting it.
When no cache is available (standalone use of build-module-deps.sh),
keep the full download-and-extract-and-build path.

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good on a glance. It would be good if someone else reviewed too. Does it make sense to apply this patch to main?

@axel-grc

axel-grc commented Sep 1, 2026

Copy link
Copy Markdown
Author

Looks good on a glance. It would be good if someone else reviewed too. Does it make sense to apply this patch to main?

We need this fix for RTK next release which will be based on release 5.4, but I think we can apply this to main as well.

@SimonRit

SimonRit commented Sep 2, 2026

Copy link
Copy Markdown

Thanks @axel-grc. I have the feeling that the problem this PR addresses has been fixed, I guess by an update of the GitHub runner. See failing workflow with runner 2.336 and successful workflow with runner 2.336. Do you confirm? The problem is I don't see anything in the runner release log that explains it.
The PR is still beneficial IMO as it avoids unnecessarily untaring one file.

@axel-grc

axel-grc commented Sep 2, 2026

Copy link
Copy Markdown
Author

Thanks @axel-grc. I have the feeling that the problem this PR addresses has been fixed, I guess by an update of the GitHub runner. See failing workflow with runner 2.336 and successful workflow with runner 2.336. Do you confirm? The problem is I don't see anything in the runner release log that explains it. The PR is still beneficial IMO as it avoids unnecessarily untaring one file.

Even with runner 2.337, the tar error is still there, so the fix is required.

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.

3 participants