g-ir-scanner crashes when attempting to run ldd in a cross-compilation environment
The standard approach for using g-ir-scanner in a cross-compilation environment is to set up qemu and binfmt-misc so that foreign binaries can be directly run on the host system. g-ir-scanner tries to run ldd on the binaries, which will fail under such conditions, exiting with a non-zero exit code.
Prior to a41abe18, g-ir-scanner used
subprocess.Popen to parse the output and did not check the exit code. When ldd failed, this was not fatal to g-ir-scanner.
However, that commit changed it to use
subprocess.check_output instead, which raises an exception if the subprocess has a non-zero exit code. That exception is not caught, causing g-ir-scanner to crash out with an unhelpful backtrace, and preventing cross-compilation from working in situations where it worked before.
Traceback (most recent call last): File "/usr/bin/g-ir-scanner", line 99, in <module> sys.exit(scanner_main(sys.argv)) File "/usr/lib/x86_64-linux-gnu/gobject-introspection/giscanner/scannermain.py", line 574, in scanner_main shlibs = create_binary(transformer, options, args) File "/usr/lib/x86_64-linux-gnu/gobject-introspection/giscanner/scannermain.py", line 419, in create_binary shlibs = resolve_shlibs(options, binary, options.libraries) File "/usr/lib/x86_64-linux-gnu/gobject-introspection/giscanner/shlibs.py", line 168, in resolve_shlibs _resolve_non_libtool(options, binary, non_libtool)) File "/usr/lib/x86_64-linux-gnu/gobject-introspection/giscanner/shlibs.py", line 104, in _resolve_non_libtool output = subprocess.check_output(args) File "/usr/lib/python3.7/subprocess.py", line 395, in check_output **kwargs).stdout File "/usr/lib/python3.7/subprocess.py", line 487, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['/bin/bash', '../libtool', '--mode=execute', 'ldd', '/home/rpi-ramdisk/rpi-ramdisk/packages/gstreamer/gstreamer/gst/tmp-introspectjqhicxoe/Gst-1.0']' returned non-zero exit status 1.