g-ir-scanner seem to require emulation or execusion
I'm trying to cross compile an application that makes use of g-ir-scanner in the build phase.
On platforms that support emulation, things can be made to work.
However, if using a OSX x86-64bit build platform, for a OSX arm host, I don't think that Mac supports emulation.
Eventually, in the build process we seem to hit an error like
env PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$SRC_DIR/build/meson-uninstalled $PREFIX/bin/g-ir-scanner --quiet --no-libtool --namespace=Vips --nsversion=8.0 --warn-all --output libvips/Vips-8.0.gir --c-include=vips/vips.h -I$SRC_DIR/libvips -I$SRC_DIR/build/libvips -I$SRC_DIR/. -I$SRC_DIR/build/. -I$SRC_DIR/libvips/include/vips/.. -I$SRC_DIR/build/libvips/include/vips/.. --filelist=$SRC_DIR/build/libvips/libvips.42.dylib.p/Vips_8.0_gir_filelist --include=GObject-2.0 --symbol-prefix=vips --identifier-prefix=Vips --cflags-begin -DG_DISABLE_CAST_CHECKS -DG_DISABLE_CHECKS -DG_DISABLE_ASSERT -I$SRC_DIR/. -I$SRC_DIR/build/. -I$SRC_DIR/libvips/include/vips/.. -I$SRC_DIR/build/libvips/include/vips/.. -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include -I$PREFIX/include -I$PREFIX/include/libgsf-1 -I$PREFIX/include/libxml2 -I$PREFIX/include/libpng16 -I$PREFIX/include/pango-1.0 -I$PREFIX/include/harfbuzz -I$PREFIX/include/fribidi -I$PREFIX/include/cairo -I$PREFIX/include/pixman-1 -I$PREFIX/include/freetype2 -I$PREFIX/include/librsvg-2.0 -I$PREFIX/include/gdk-pixbuf-2.0 -I$PREFIX/include/openjpeg-2.5 -I$PREFIX/include/orc-0.4 -DHAVE_CONFIG_H=1 -I$PREFIX/include/gobject-introspection-1.0 --cflags-end --add-include-path=$PREFIX/share/gir-1.0 -L$SRC_DIR/build/libvips --library vips -L$PREFIX/lib -L$PREFIX/lib --extra-library=glib-2.0 --extra-library=intl --extra-library=gio-2.0 --extra-library=gobject-2.0 --extra-library=gmodule-2.0 --extra-library=expat --extra-library=m --extra-library=z --extra-library=gsf-1 --extra-library=xml2 --extra-library=fftw3 --extra-library=cfitsio --extra-library=exif --extra-library=jpeg --extra-library=png16 --extra-library=webp --extra-library=webpmux --extra-library=webpdemux --extra-library=pangocairo-1.0 --extra-library=pango-1.0 --extra-library=harfbuzz --extra-library=cairo --extra-library=pangoft2-1.0 --extra-library=fontconfig --extra-library=freetype --extra-library=tiff --extra-library=rsvg-2 --extra-library=gdk_pixbuf-2.0 --extra-library=matio --extra-library=hdf5 --extra-library=lcms2 --extra-library=openjp2 --extra-library=orc-0.4 --extra-library=girepository-1.0 --sources-top-dirs $SRC_DIR/ --sources-top-dirs $SRC_DIR/build/
Traceback (most recent call last):
File "$PREFIX/bin/g-ir-scanner", line 99, in <module>
sys.exit(scanner_main(sys.argv))
^^^^^^^^^^^^^^^^^^^^^^
File "$BUILD_PREFIX/lib/gobject-introspection/giscanner/scannermain.py", line 609, in scanner_main
shlibs = create_binary(transformer, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$BUILD_PREFIX/lib/gobject-introspection/giscanner/scannermain.py", line 447, in create_binary
gdump_parser.parse()
File "$BUILD_PREFIX/lib/gobject-introspection/giscanner/gdumpparser.py", line 109, in parse
tree = self._execute_binary_get_tree()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$BUILD_PREFIX/lib/gobject-introspection/giscanner/gdumpparser.py", line 171, in _execute_binary_get_tree
subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
File "$BUILD_PREFIX/lib/python3.11/subprocess.py", line 408, in check_call
retcode = call(*popenargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$BUILD_PREFIX/lib/python3.11/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$BUILD_PREFIX/lib/python3.11/subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "$BUILD_PREFIX/lib/python3.11/subprocess.py", line 1901, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 86] Bad CPU type in executable: '$SRC_DIR/build/tmp-introspectvorxco17/Vips-8.0'
Sifting through your code, it is not obvious how I would get past this point without emulation in a straightforward way.
Other packages at conda-forge go through a two step process:
- First build the host native package.
- Use the introspected outputs in the cross compiled package.
This is less than ideal since we have to effectively copy our recipe twice...
I've attached a full of a build on Azure log in case you wanted to inspect things.
Is there anything we can do to enable "true" cross compilation with g-ir tools?
Thank you for your help
xref: https://github.com/conda-forge/libvips-feedstock/pull/72 libvips_osx_arm_cross.txt