cross compiling gstreamer: sysroot + prefix and introspection?

Nicolas Dufresne nicolas at ndufresne.ca
Thu Nov 21 16:58:10 UTC 2019


Le jeudi 21 novembre 2019 à 17:01 +0100, Milian Wolff a écrit :
> Hey all,
> 
> I tried to cross compile gstreamer and have succeeded, but it doesn't feel 
> right. I have tried the following with the latest 1.16.1 tarballs:
> 
> issue #1: instrospection not possible when cross compiling
> 
> ```
> cd gstreamer-1.16.1
> ./configure --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --
> build=x86_64-linux --with-sysroot=/path/to/sdk/sysroots/cortexa7t2hf-neon-
> vfpv4-poky-linux-gnueabi --prefix=/usr
> ...
> make
> ...
> Traceback (most recent call last):
>   File "/usr/bin/g-ir-scanner", line 100, in <module>
>     sys.exit(scanner_main(sys.argv))
>   File "/usr/lib/gobject-introspection/giscanner/scannermain.py", line 579, in 
> scanner_main
>     shlibs = create_binary(transformer, options, args)
>   File "/usr/lib/gobject-introspection/giscanner/scannermain.py", line 419, in 
> create_binary
>     shlibs = resolve_shlibs(options, binary, options.libraries)
>   File "/usr/lib/gobject-introspection/giscanner/shlibs.py", line 168, in 
> resolve_shlibs
>     _resolve_non_libtool(options, binary, non_libtool))
>   File "/usr/lib/gobject-introspection/giscanner/shlibs.py", line 104, in 
> _resolve_non_libtool
>     output = subprocess.check_output(args)
>   File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
>     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
>   File "/usr/lib/python3.8/subprocess.py", line 512, in run
>     raise CalledProcessError(retcode, process.args,
> subprocess.CalledProcessError: Command '['/bin/sh', '../libtool', '--
> mode=execute', 'ldd', '/path/to/gstreamer-1.16.1/gst/tmp-introspectj0a4bz61/
> Gst-1.0']' returned non-zero exit status 1.
> make[4]: *** [Makefile:2281: Gst-1.0.gir] Error 1
> ```
> 
> How is introspection supposed to work in a cross compiled environment? ldd 
> doesn't work then, as it relies on "executing" the .so with the 
> LD_TRACE_LOADED_OBJECTS=1 env var set.

It does not really work. Some people managed to make it work with
binfmt + qemu-user, but it remains a bit hacky. If you want to make
this work, best is to use Yocto. It's painful, but to my knowledge its
currently the only reliable integration. Plus, they have wrapper to
spam you when the compilers tries to use header files from your host.
Yocto already has GStreamer 1.16.1 iirc.

> 
> I then figured out I can disable that via `--enable-introspection=yes` - 
> should this be made the default when `--with-sysroot` is passed?
> 
> issue #2: installation prefix path not taking sysroot into account?
> 
> When I then compile without introspection, it all works but then in the end if 
> I do `make install` I get e.g.:
> 
> ```
> /usr/bin/install: cannot remove '/usr/lib/pkgconfig/gstreamer-1.0.pc': 
> Permission denied
> ```
> 
> Shouldn't the prefix be prefixed with the sysroot? What's worse, I cannot even 
> run `make DESTDIR=path/to/sysroot install` as I then end up with:
> 
> ```
> libtool: warning: relinking 'libgstbase-1.0.la'
> libtool: install: (cd /home/milian/projects/kdab/smi/gstreamer-1.16.1/libs/
> gst/base; /bin/sh "/home/milian/projects/kdab/smi/gstreamer-1.16.1/libtool"  
> --silent --tag CC --mode=relink arm-poky-linux-gnueabi-gcc -march=armv7ve -
> mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/ssd/
> milian/projects/kdab/smi/sdk/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-
> gnueabi -I../../../libs -I../../.. -I../../../libs -I../../.. -pthread
> ...
> /path/to/sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/
> gcc/arm-poky-linux-gnueabi/8.2.0/ld: warning: library search path "/usr/lib" 
> is unsafe for cross-compilation
> /usr/lib/libgcc_s.so.1: file not recognized: file format not recognized
> collect2: error: ld returned 1 exit status
> libtool:   error: error: relink 'libgstbase-1.0.la' with the above command 
> before installing it
> ```
> 
> The only way I could make it work was by passing the sysroot-prefixed path 
> directly to `--prefix`, but that's unexpected to me.
> 
> To make things worse, when I then build e.g. `gst-plugins-base` I end up with:
> 
> ```
> cc1: warning: /path/to/sdk/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-
> gnueabi/path/to/sdk/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/
> include/gstreamer-1.0: No such file or directory [-Wmissing-include-dirs]
> cc1: warning: /path/to/sdk/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-
> gnueabi/path/to/sdk/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/
> include/gstreamer-1.0: No such file or directory [-Wmissing-include-dirs]
> gstvorbistag.c:37:10: fatal error: gst/gsttagsetter.h: No such file or 
> directory
>  #include <gst/gsttagsetter.h>
>           ^~~~~~~~~~~~~~~~~~~~
> ```
> 
> Note that it duplicates the path here! as if it then takes the prefix and the 
> sysroot into account? I could workaround this by adding a symlink but that 
> really just feels even worse.
> 
> I feel like I'm doing something fundamentally wrong - could someone explain 
> the "correct" way of handling cross compiling gstreamer for me?
> 
> Thanks!
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20191121/58a3a7a4/attachment.sig>


More information about the gstreamer-devel mailing list