ITK
ITK copied to clipboard
Syntax error in input(3) of itkVectorContainer.i
Description
I want to build insighttoolkit for openSUSE Tumbleweed on s390x and x86. It is failing with the following error message:
[ 1239s] /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/itkVectorContainer.i:177: Error: Syntax error in input(3).
[ 1239s] ninja: build stopped: subcommand failed.
Steps to Reproduce
%cmake \
-DITK_INSTALL_LIBRARY_DIR:PATH=%{_lib}/ \
-DITK_INSTALL_INCLUDE_DIR:PATH=include/%{name}/ \
-DITK_INSTALL_PACKAGE_DIR:PATH=%{_lib}/cmake/%{name}/ \
-DITK_INSTALL_RUNTIME_DIR:PATH=%{_bindir} \
-DITK_INSTALL_DOC_DIR=share/doc/packages/%{name}/ \
-DBUILD_EXAMPLES:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DBUILD_TESTING:BOOL=OFF \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
-DITK_USE_FFTWD:BOOL=ON \
-DITK_USE_FFTWF:BOOL=ON \
-DITK_USE_SYSTEM_LIBRARIES:BOOL=ON \
-DITK_USE_SYSTEM_CASTXML:BOOL=ON \
-DITK_USE_SYSTEM_GDCM:BOOL=ON \
%if %{without system_eigen}
-DITK_USE_SYSTEM_EIGEN:BOOL=OFF \
%endif
-DITK_USE_SYSTEM_SWIG:BOOL=ON \
-DITK_USE_SYSTEM_VXL:BOOL=OFF \
-DVXL_BUILD_CORE_NUMERICS:BOOL=OFF \
-DVCL_INCLUDE_CXX_0X:BOOL=ON \
-DITK_FORBID_DOWNLOADS=ON \
-DITK_WRAP_PYTHON:BOOL=ON
Expected behavior
You can build ITK without any syntax error.
Actual behavior
Build of the openSUSE package is failing because of a syntax error.
Reproducibility
100% on s390x and x86
Versions
5.2.1
Environment
openSUSE Tumbleweed architecture: s390x or x86 cpp-12-2.2 cmake-3.23.2-2.1 gcc-12-2.2 gtk2-devel-2.24.33-2.5
Additional Information
(see build log: https://build.opensuse.org/public/build/Application:Geo/openSUSE_Factory_zSystems/s390x/insighttoolkit/_log )
Does the error persist when you use master
instead of 5.2.1
?
I have tested the master branch in my home repo now. It does not come so far because of this new error message:
[ 146s] + ninja -v -j6
[ 146s] ninja: error: 'Wrapping/Modules/ITKCommon/castxml', needed by 'Wrapping/castxml_inputs/itkFixedArray.xml', missing and no known rule to make it
That is happening for all architectures. Logs at: https://build.opensuse.org/package/show/home:AdaLovelace:branches:openSUSE:Factory:zSystems/insighttoolkit
I went through the documentation. There is no hint, how to handle it. It seems, that the module should be created during the compilation.
It is worthwhile to start a clean build (build in a new directory, to avoid possible interference of files from the previous build).
I got the same errors when building itk for ArchLinux with gcc 12.1.0, see the complete build log here
class itkVectorContainerUCD : public itkObject, private std::vector< double > {
public:
static itkVectorContainerUCD_Pointer New();
virtual itkLightObject_Pointer CreateAnother() const;
itkVectorContainerUCD_Pointer Clone() const;
virtual char const * GetNameOfClass() const;
std::vector< double > & CastToSTLContainer();
std::vector< double > const & CastToSTLConstContainer() const;
?unknown? ElementAt(unsigned char arg0);
?unknown? ElementAt(unsigned char arg0) const;
?unknown? CreateElementAt(unsigned char arg0);
double GetElement(unsigned char arg0) const;
void SetElement(unsigned char arg0, double arg1);
void InsertElement(unsigned char arg0, double arg1);
bool IndexExists(unsigned char arg0) const;
bool GetElementIfIndexExists(unsigned char arg0, double * arg1) const;
void CreateIndex(unsigned char arg0);
void DeleteIndex(unsigned char arg0);
unsigned char Size() const;
void Reserve(unsigned char arg0);
void Squeeze();
void Initialize();
~itkVectorContainerUCD();
private:
protected:
itkVectorContainerUCD();
itkVectorContainerUCD(unsigned long n);
itkVectorContainerUCD(unsigned long n, double const & x);
itkVectorContainerUCD(itkVectorContainerUCD const & r);
};
see also the complete itkVectorContainer.i
It built cleanly for me with gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1)
.
For you, it chokes at ?unknown? ElementAt(unsigned char arg0);
, which is invalid C++ syntax.
The corresponding part of itkVectorContainer.i
looks like this for me:
class itkVectorContainerUCD : public itkObject, private std::vector< double > {
public:
static itkVectorContainerUCD_Pointer New();
virtual itkLightObject_Pointer CreateAnother() const;
itkVectorContainerUCD_Pointer Clone() const;
virtual char const * GetNameOfClass() const;
std::vector< double > & CastToSTLContainer();
std::vector< double > const & CastToSTLConstContainer() const;
double & ElementAt(unsigned char arg0);
double const & ElementAt(unsigned char arg0) const;
double & CreateElementAt(unsigned char arg0);
double GetElement(unsigned char arg0) const;
void SetElement(unsigned char arg0, double arg1);
void InsertElement(unsigned char arg0, double arg1);
bool IndexExists(unsigned char arg0) const;
bool GetElementIfIndexExists(unsigned char arg0, double * arg1) const;
void CreateIndex(unsigned char arg0);
void DeleteIndex(unsigned char arg0);
unsigned char Size() const;
void Reserve(unsigned char arg0);
void Squeeze();
void Initialize();
~itkVectorContainerUCD();
private:
protected:
itkVectorContainerUCD();
itkVectorContainerUCD(unsigned long n);
itkVectorContainerUCD(unsigned long n, double const & x);
itkVectorContainerUCD(itkVectorContainerUCD const & r);
};
It might be due to different versions of SWIG, CastXML or maybe even CMake. On my box: cmake version 3.23.2, SWG and CastXML bundled with ITK.
ArchLinux environment: swig 4.0.2 cmake 3.23.2
I'll try using different castxml release, the failed one uses castxml 0.4.5.
openSUSE is using also CastXML-devel-0.4.5-1.2 and swig-4.0.2-6.3 . I found this page about the changelog of the ongoing release: https://pyup.io/changelogs/itk/ I compare the new features and their requirements with our build environment.
/usr/include/wchar.h:155:24: error: use of undeclared identifier '__builtin_free'; did you mean '__builtin_frexp'?
__attribute_malloc__ __attr_dealloc_free;
^
/usr/include/sys/cdefs.h:691:46: note: expanded from macro '__attr_dealloc_free'
# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
^
/usr/include/wchar.h:155:24: note: '__builtin_frexp' declared here
/usr/include/sys/cdefs.h:691:46: note: expanded from macro '__attr_dealloc_free'
# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
^
In file included from /build/itk/src/build/Wrapping/ITKCommonBase.cxx:1:
In file included from /build/itk/src/ITK-5.2.1/Modules/Core/Common/include/itkCommand.h:21:
In file included from /build/itk/src/ITK-5.2.1/Modules/Core/Common/include/itkObject.h:31:
In file included from /build/itk/src/ITK-5.2.1/Modules/Core/Common/include/itkLightObject.h:21:
In file included from /build/itk/src/ITK-5.2.1/Modules/Core/Common/include/itkMacro.h:47:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/string:40:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/char_traits.h:39:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/postypes.h:40:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/cwchar:44:
/usr/include/wchar.h:155:24: error: '__malloc__' attribute takes no arguments
__attribute_malloc__ __attr_dealloc_free;
^
/usr/include/sys/cdefs.h:691:30: note: expanded from macro '__attr_dealloc_free'
# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
^
/usr/include/sys/cdefs.h:690:21: note: expanded from macro '__attr_dealloc'
__attribute__ ((__malloc__ (dealloc, argno)))
building with -DITK_USE_SYSTEM_CASTXML:BOOL=ON
still not working. check the complete error log itk.bundled-castxml.txt
On my computer, itkMacro.h:47 has following content #include <string>
. That does not compile for you? That might be architecture-specific weirdness. That might come from misdetecting compiler. Check content of vcl_compiler_detection.h
in itk-build-dir\Modules\ThirdParty\VNL\src\vxl\vcl\
.
I could build itk master branch with this PKGBUILD, with -DITK_USE_SYSTEM_CASTXML=OFF
, -DCMAKE_CXX_FLAGS='-fno-sized-deallocation'
as menthioned in #3452. I'm ok to wait for release 5.3.
https://github.com/InsightSoftwareConsortium/ITK/issues/3506#issuecomment-1200167635
I found a similar issue https://github.com/CastXML/CastXML/issues/208. It seems related to GCC version. I could build it with clang 14.0.6.
I could build itk master branch with this PKGBUILD, with
-DITK_USE_SYSTEM_CASTXML=OFF
,-DCMAKE_CXX_FLAGS='-fno-sized-deallocation'
as menthioned in #3452. I'm ok to wait for release 5.3.
These options have helped me for coming further. The build is failing because of this error message now:
[ 463s] In file included from /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkImageRegion.h:33,
[ 463s] from /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkImage.h:21,
[ 463s] from /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Transform/include/itkBSplineBaseTransform.h:23,
[ 463s] from /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Transform/include/itkBSplineTransform.h:21,
[ 463s] from /home/abuild/rpmbuild/BUILD/ITK-master/Modules/IO/TransformFactory/src/itkTransformFactoryBaseRegister.hxx:44,
[ 463s] from /home/abuild/rpmbuild/BUILD/ITK-master/Modules/IO/TransformFactory/src/itkTransformFactoryBaseRegisterDoubleParameters.cxx:18:
[ 463s] In member function 'constexpr const itk::Size<VDimension>::value_type& itk::Size<VDimension>::operator[](size_type) const [with unsigned int VDimension = 2]',
[ 463s] inlined from 'itk::Neighborhood<TPixel, VDimension, TAllocator>::SizeValueType itk::Neighborhood<TPixel, VDimension, TAllocator>::GetSize(DimensionValueType) const [with TPixel = double; unsigned int VDimension = 2; TAllocator = itk::NeighborhoodAllocator<double>]' at /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkNeighborhood.h:147:18,
[ 463s] inlined from 'void itk::NeighborhoodOperator<TPixel, VDimension, TAllocator>::FillCenteredDirectional(const CoefficientVector&) [with TPixel = double; unsigned int VDimension = 2; TAllocator = itk::NeighborhoodAllocator<double>]' at /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkNeighborhoodOperator.hxx:112:43:
[ 463s] /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkSize.h:343:85: warning: array subscript 2 is above array bounds of 'const itk::Size<2>::SizeValueType [2]' {aka 'const long unsigned int [2]'} [-Warray-bounds]
[ 463s] 343 | constexpr const_reference operator[](size_type pos) const { return m_InternalArray[pos]; }
[ 463s] | ~~~~~~~~~~~~~~~^
[ 463s] /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkSize.h: In member function 'void itk::NeighborhoodOperator<TPixel, VDimension, TAllocator>::FillCenteredDirectional(const CoefficientVector&) [with TPixel = double; unsigned int VDimension = 2; TAllocator = itk::NeighborhoodAllocator<double>]':
[ 463s] /home/abuild/rpmbuild/BUILD/ITK-master/Modules/Core/Common/include/itkSize.h:229:40: note: while referencing 'itk::Size<2>::m_InternalArray'
[ 463s] 229 | alignas(SizeValueType) SizeValueType m_InternalArray[VDimension];
[ 463s] | ^~~~~~~~~~~~~~~
What source file/test is being compiled? And this looks like a warning, not an error message.
In the first step, I also thought it would only be a warning. But this warning exists multiple times. If a warning is happening in an endless loop, then the build is not successful: Here is the full build log.
In the first step, I also thought it would only be a warning. But this warning exists multiple times. If a warning is happening in an endless loop, then the build is not successful: Here is the full build log.
It seems the build server fail to download castxml,
[ 419s] CMake Error at castxml-stamp/download-castxml.cmake:170 (message):
- You could check also this PKGBUILD I used for building itk master for ArchLinux. It works as expected, and here is the full build log.
- You could check this PKGBUILD I used for building itk 5.2.1 for ArchLinux with clang 14.0.6. It works as expected, and check the complete build log here.
It seems this issue can be caused by castxml being built with llvm 14. If built with llvm 13, I don't have the issue.
ITK git master
now has https://github.com/InsightSoftwareConsortium/ITK/pull/3541 -- as suggested by @hubutui this may help with this issue.
@thewtex Passed -fno-sized-deallocation
(just used your patch from PR#3541) but we get the same error:
[ 566s] FAILED: Wrapping/Modules/ITKCommon/itkVectorContainerPython.cpp Wrapping/Generators/Python/itk/itkVectorContainerPython.py /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Modules/ITKCommon/itkVectorContainerPython.cpp /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Generators/Python/itk/itkVectorContainerPython.py
[ 566s] cd /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/python && /usr/bin/swig -c++ -python -O -features autodoc=2 -py3 -doxygen -Werror -w302 -w303 -w312 -w314 -w361 -w362 -w350 -w383 -w384 -w389 -w394 -w395 -w467 -w508 -w509 -o /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Modules/ITKCommon/itkVectorContainerPython.cpp -I/usr/share/swig/4.0.2/python -I/usr/share/swig/4.0.2 -I/home/abuild/rpmbuild/BUILD/ITK-5.2.1/Wrapping/Generators -I/home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/python -I/home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs -outdir /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Generators/Python/itk /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/itkVectorContainer.i
[ 566s] /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/itkVectorContainer.i:177: Error: Syntax error in input(3).
Full log attached here _log.zip
ITK-5.2.1
@badshah400 thanks for testing. Is it possible to test Git master
?
@thewtex Git master does not build due to something else:
[ 78s] -- Build files have been written to: /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build
[ 79s] + ninja -v -j8
[ 79s] ninja: error: 'Wrapping/Modules/ITKCommon/castxml', needed by 'Wrapping/castxml_inputs/itkFixedArray.xml', missing and no known rule to make it
[ 79s] error: Bad exit status from /var/tmp/rpm-tmp.KL7ywe (%build)
Odd considering I am using -DITK_USE_SYSTEM_CASTXML:BOOL=ON
.
Ditto with v5.3.0rc04; trying to figure out the last commit that proceeds with the build at all.
Need to revert commit ee989dc89afa3487bf0ec1e730e0bdb8ebea38a2 to get it building at all without the previous error. After reverting this commit, git master (as commit b9005b83b315cdf61a345037c49dfd84f7bde386) still fails to build with the originally reported problem:
[ 590s] /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/ITKCommonBase.i:1042: Error: Syntax error in input(3).
[ 593s] /home/abuild/rpmbuild/BUILD/ITK-5.2.1/build/Wrapping/Typedefs/ITKCommonBase.i:1042: Error: Syntax error in input(3).
[ 595s] error: Bad exit status from /var/tmp/rpm-tmp.42ma7B (%build)
@hjmjohnson what was the use case where https://github.com/InsightSoftwareConsortium/ITK/commit/ee989dc89afa3487bf0ec1e730e0bdb8ebea38a2 was needed?
#3729 addresses the ITK_USE_SYSTEM_CASTXML
build. I get a successful local build with:
CC=gcc-12 CXX=g++-12 cmake -DITK_WRAP_PYTHON=1 -DITK_USE_SYSTEM_CASTXML=1 ~/src/ITK
gcc-12.1.0
hmmm, I just test with gcc 12.2.0, castxml 0.4.6, still the same error.
make[2]: Entering directory '/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build'
[ 75%] Generating ITKCommonBasePython.cpp, ../../Generators/Python/itk/ITKCommonBasePython.py
cd /home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Typedefs/python && /home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Generators/SwigInterface/swig/bin/swig -c++ -python -O -features autodoc=2 -py3 -doxygen -Werror -w302 -w303 -w312 -w314 -w361 -w362 -w350 -w383 -w384 -w389 -w394 -w395 -w467 -w508 -w509 -o /home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Modules/ITKCommon/ITKCommonBasePython.cpp -I/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Generators/SwigInterface/swig/share/swig/4.0.2/python -I/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Generators/SwigInterface/swig/share/swig/4.0.2 -I/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/itk-src/Wrapping/Generators -I/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Typedefs/python -I/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Typedefs -outdir /home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Generators/Python/itk /home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Typedefs/ITKCommonBase.i
/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Typedefs/ITKCommonBase.i:1042: Error: Syntax error in input(3).
make[2]: *** [Wrapping/Modules/ITKCommon/CMakeFiles/ITKCommonPython.dir/build.make:441: Wrapping/Modules/ITKCommon/ITKCommonBasePython.cpp] Error 1
make[2]: Leaving directory '/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build'
make[1]: *** [CMakeFiles/Makefile2:39410: Wrapping/Modules/ITKCommon/CMakeFiles/ITKCommonPython.dir/all] Error 2
make[1]: Leaving directory '/home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build'
make: *** [Makefile:166: all] Error 2
and /home/hubutui/Projects/archlinuxcn-repo/archlinuxcn/itk-git/build/Wrapping/Typedefs/ITKCommonBase.i:1042
:
static ?unknown? progressFloatToFixed(float f);
castxml is build with https://github.com/archlinuxcn/repo/blob/0005465a68caad0d44bbafb572b09b8ef326ec91/archlinuxcn/castxml/PKGBUILD#L24-L34
According to: https://github.com/InsightSoftwareConsortium/ITK/blob/85d3745371e7eda6ccff5b5266849bda308a6a65/Modules/Core/Common/include/itkProcessObject.h#L913-L926 We should get
static unsigned int progressFloatToFixed(float f);
for build/Wrapping/Typedefs/ITKCommonBase.i:1042
.
Maybe we need a manual typemaps as the swig doc mentioned?
BTW, I'm using swig 4.0.2. What's your swig version? @thewtex
@hubutui interesting, I used the swig version vendored with ITK, also 4.0.2. castxml 0.4.4 (ubuntu 22.04 package).
I have no idea how the file build/Wrapping/Typedefs/ITKCommonBase.i
is generated. Maybe there is something wrong when it's generated.
@dzenanz mentioned:
It might be due to different versions of SWIG, CastXML or maybe even CMake. On my box: cmake version 3.23.2, SWG and CastXML bundled with ITK.
My env:
cmake 3.24.3
swig 4.0.2
castxml: 0.4.6
gcc 12.0.2
python 3.10.8
According to the upstream swig doc, swig 4.1.0 add support for python 3.9-3.10. swig 4.0.2 in ArchLinux is patched, see also the PKGBUILD ArchLinux used for building swig. I also build swig 4.1.0 pkg for ArchLinux and and build itk with it, but still the same error.
@hubutui does the build succeed with the swig vendored with ITK?
Does this patch help at all? https://github.com/InsightSoftwareConsortium/ITK/pull/3736
@thewtex Yes, this patch https://github.com/InsightSoftwareConsortium/ITK/pull/3736 fix the issue. I could now build itk with system's swig and castxml. @skriesch Hi, you could if this patch work on openSUSE.