ITK icon indicating copy to clipboard operation
ITK copied to clipboard

Python build fails on Mac

Open dzenanz opened this issue 3 months ago • 6 comments

XCode says:

PhaseScriptExecution Generate\ Wrapping/Generators/Python/itk/ITKCommonBasePython.py /Users/dzenan.zukic/Documents/ITK-py2/build/ITKCommonPython.build/Debug/Script-56F9B3CA7CE80BA1073137B7.sh (in target 'ITKCommonPython' from project 'ITK')
    cd /Users/dzenan.zukic/Documents/ITK-git
    /bin/sh -c /Users/dzenan.zukic/Documents/ITK-py2/build/ITKCommonPython.build/Debug/Script-56F9B3CA7CE80BA1073137B7.sh

/Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Typedefs/ITKCommonBase.i:946: Error: Syntax error in input(3).
Command PhaseScriptExecution failed with a nonzero exit code

The content of Script-56F9B3CA7CE80BA1073137B7.sh is:

#!/bin/sh
set -e
if test "$CONFIGURATION" = "Debug"; then :
  cd /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Typedefs/python
  /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Generators/SwigInterface/swigmacos-arm64-2024-03-26-master/bin/swig -c$
fi
if test "$CONFIGURATION" = "Release"; then :
  cd /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Typedefs/python
  /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Generators/SwigInterface/swigmacos-arm64-2024-03-26-master/bin/swig -c$
fi
if test "$CONFIGURATION" = "MinSizeRel"; then :
  cd /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Typedefs/python
  /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Generators/SwigInterface/swigmacos-arm64-2024-03-26-master/bin/swig -c$
fi
if test "$CONFIGURATION" = "RelWithDebInfo"; then :
  cd /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Typedefs/python
  /Users/dzenan.zukic/Documents/ITK-py2/Wrapping/Generators/SwigInterface/swigmacos-arm64-2024-03-26-master/bin/swig -c$
fi

This is also reported to the dashboard here. The build failures started on September 17th: https://open.cdash.org/builds/10685388

Looking at the git log around that time, nothing looks suspicious. There was an update of windows binaries for CastXML, as the closest thing to relevance.

dzenanz avatar Oct 02 '25 14:10 dzenanz

Wrapping/Typedefs/ITKCommonBase.i:946: Error: Syntax error in input(3).

This error occurs because that line is:

?unknown? GetNumberOfInputs() const;

Looking at Wrapping/castxml_inputs/ITKCommonBase.xml, the ?unknown? return type goes through a bunch of typedefs and eventually arrives at

<Unimplemented id="_3084" type_class="Decltype"/>

The actual type is in the macOS SDK's <cstddef> header, and is:

using size_t = decltype(sizeof(int));

CastXML has no problem with decltype() when using --castxml-output=1. However, ITK's invocation is still using --castxml-gccxml, which doesn't support decltype.

ITK really needs to port to the modern CastXML output.

bradking avatar Nov 18 '25 19:11 bradking

For reference, LLVM PR 114788 switched libc++'s <cstddef> to use decltype() to define size_t. Any build using libc++ 21 or later will have this problem, not just those that get it via the macOS SDK.

bradking avatar Nov 18 '25 19:11 bradking

And I assume we pass --castxml-gccxml because SWIG needs GCC-style XML? @thewtex is that right?

dzenanz avatar Nov 18 '25 20:11 dzenanz

And I assume we pass --castxml-gccxml because SWIG needs GCC-style XML? @thewtex is that right?

@dzenanz I am busy with other issues related to wheel generation and do not want to get further side tracked.

I think we pass the XML files through igenerator.py to generate the swig input files:

I am guessing we would need a replacement for import pygccxml

and update the python file.

hjmjohnson avatar Nov 18 '25 22:11 hjmjohnson

pygccxml should support it per:

https://github.com/CastXML/pygccxml/blob/26f63dc1f473114f836a43c309eaf5f65e5c5554/src/pygccxml/parser/source_reader.py#L159-L170

but our (vendored) pygccxml may need updates, fixes made, etc. In ITK, --castxml-gccxml is passed in our CMakeLists.txt

CC @iMichka

thewtex avatar Nov 19 '25 12:11 thewtex

@thewtex Thanks for the hints. I'll circle back to this in a week or so after other issues are resolved. If no one has attacked the issue by then, I'll take a swing at it.

I think the approach should be:

1: Update the ITK private pygccxml implementation with CastXML/pygccxml changes to get the correct behavior 2: continue using vendored pygccxml in igenerator.py 3: change --castxml-gccxml to --castxml-output=1

hjmjohnson avatar Nov 19 '25 15:11 hjmjohnson