Kodi Community Forum

Full Version: Final tweaking needed to build popcornmix's Leia_pi4 fork
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
In order to provide @popcornmix 's leia_pi4 fork for Arch ARM, I need to make two modifications.  Arch ARM builds packages in a clean-chroot (a buildroot) that is a subdirectory/fakeroot containing all dependencies for the build.

Not doing both steps causes build failures:
1) Manually copy /opt/vc/lib/pkgconfig/{bcm_host.pc,mmal.pc,vcsm.pc} to $srcdir/pkgconfig/ and prefix my cmake command with: export PKG_CONFIG_PATH=$srcdir/pkgconfig

2) Manually rename or delete the following directories in buildroot (provided by the raspberrypi-firmware package): /opt/vc/include/{EGL,GLES,GLES2}

I can do step 1 in the PKGBUILD no problem, but I cannot do step 2 since those directories are not under the control of the buildroot user (ie they are root:root).  Step 2 is needed to avoid this build error.

My strategy to circumvent is to simply copy the contents of /buildroot/opt/vc to the build space and then modify that copy, deleting the offending directories.  For that to work, I need to redirect cmake to use it rather than the native location.

Native location (all owned by root:root): /buildroot/opt/vc
Needed location (all owned by myuser:mygroup): $srcdir/opt

Is there a variable or variables I can export or CMAKE switches I can use that would allow me to redefine so the build will uses the new location?

My best guess at a workaround is to define each of the VARS the code wants like this:
Code:
# untar firmware package to $srcdir/opt
# now delete the 3 offending dirs thus leaving everything else intact
# but kodi build expects everything to be in /opt and it is now in $srcdir/opt
rm -rf $srcdir/opt/vc/include/{EGL,GLES,GLES2}

cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=/usr/lib \
-DMMAL_INCLUDE_DIR="$srcdir/opt/vc/include" \
-DMMAL_LIBRARY="$srcdir/opt/vc/include/lib" \
-DMMALCORE_LIBRARY="$srcdir/opt/vc/include/lib" \
-DMMALUTIL_LIBRARY="$srcdir/opt/vc/include/lib" \
-DMMALCLIENT_LIBRARY="$srcdir/opt/vc/include/lib" \
-DMMALCOMPONENT_LIBRARY="$srcdir/opt/vc/include/lib" \
-DVCSM_LIBRARY="$srcdir/opt/vc/include/interface/vcsm" \
-DBCM_LIBRARY="$srcdir/opt/vc/include/lib" \
-DCONTAINER_LIBRARY="$srcdir/opt/vc/include/lib" \
-DVCHIQ_LIBRARY="$srcdir/opt/vc/include/interface/vchiq_arm" \
-DVCOS_LIBRARY="$srcdir/opt/vc/include/interface/vcos" \
-DVCHOSTIF_LIBRARY="$srcdir/opt/vc/include/interface/vmcs_host" \
-DVCILCS_LIBRARY="$srcdir/opt/vc/include/interface/vmcs_host" \
...

The build gets going but dies here:
Code:
...
CC libavcodec/roqvideodec.o
CC libavcodec/roqvideoenc.o
CC libavcodec/rpi_ctrl_ffmpeg.o
src/libavcodec/rpi_ctrl_ffmpeg.c:28:10: fatal error: interface/vcsm/user-vcsm.h: No such file or directory
#include <interface/vcsm/user-vcsm.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
src/libavcodec/rpi_ctrl_ffmpeg.c:28:10: fatal error: interface/vcsm/user-vcsm.h: No such file or directory
#include <interface/vcsm/user-vcsm.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[6]: *** [/build/kodi-rbp4/src/kodi-build/build/ffmpeg/src/ffmpeg/ffbuild/common.mak:60: libavcodec/rpi_ctrl_ffmpeg.o] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [CMakeFiles/ffmpeg.dir/build.make:112: ffmpeg-prefix/src/ffmpeg-stamp/ffmpeg-build] Error 2
make[4]: *** [CMakeFiles/Makefile2:76: CMakeFiles/ffmpeg.dir/all] Error 2
make[3]: *** [Makefile:130: all] Error 2
make[2]: *** [CMakeFiles/ffmpeg.dir/build.make:114: build/ffmpeg/src/ffmpeg-stamp/ffmpeg-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:1308: CMakeFiles/ffmpeg.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Some of the VARS I defined there are dropped it seems:
Code:
-- Configuring done
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vchiq_arm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcos". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcsm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vmcs_host". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vmcs_host". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vchiq_arm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcos". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcsm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vchiq_arm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcos". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcsm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vmcs_host". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vmcs_host". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vchiq_arm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcos". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "kodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcsm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vchiq_arm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcos". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcsm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vmcs_host". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vmcs_host". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vchiq_arm". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcos". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "libkodi" requests linking to directory "/build/kodi-rbp4/src/opt/vc/include/interface/vcsm". Targets may link only to libraries. CMake is dropping the item.
-- Generating done

I'm not sure how to proceed. Link to entire build log. Your insights are welcomed and thank you again for all the time you have put into this.
-D*_LIBRARY stuff should refer to the DSO itself, eg /path/to/libwhatever.so.1.2 not the directory.
I'm not sure if include dirs are passed from cmake to ffmpeg in-tree build Makefile/Cmakelist.txt (eg -DMMAL_INCLUDE_DIR), I guess they are not.
@asavah

About the -D*_LIBRARY stuff, when I read cmake/modules/FindMMAL.cmake and then look for the corresponding files:
Code:
#!/bin/bash
for i in mmal.h libmmal libmmal_core libmmal_util libmmal_vc_client libmmal_components libbcm_host libvchiq_arm libvchostif libvcilcs libvcos libvcsm libcontainers; do
  echo
  echo   looking for $i
  find /opt -type f | grep $i
done

I get:
Code:
looking for mmal.h
/opt/vc/include/interface/mmal/mmal.h

looking for libmmal
/opt/vc/lib/libmmal_vc_client.so
/opt/vc/lib/libmmal_util.so
/opt/vc/lib/libmmal.so
/opt/vc/lib/libmmal_core.so
/opt/vc/lib/libmmal_components.so

looking for libmmal_core
/opt/vc/lib/libmmal_core.so

looking for libmmal_util
/opt/vc/lib/libmmal_util.so

looking for libmmal_vc_client
/opt/vc/lib/libmmal_vc_client.so

looking for libmmal_components
/opt/vc/lib/libmmal_components.so

looking for libbcm_host
/opt/vc/lib/libbcm_host.so

looking for libvchiq_arm
/opt/vc/lib/libvchiq_arm.so

looking for libvchostif
/opt/vc/lib/libvchostif.a

looking for libvcilcs
/opt/vc/lib/libvcilcs.a

looking for libvcos
/opt/vc/lib/libvcos.so

looking for libvcsm
/opt/vc/lib/libvcsm.so

looking for libcontainers
/opt/vc/lib/libcontainers.so


So it seems that the following are not *.so files:
mmal.h (corresponding to MMAL_INCLUDE_DIR)
libvchostif.a (corresponding to VCHOSTIF_LIBRARY)
libvcilcs.a (corresponding to VCILCS_LIBRARY)

All others are under /opt/vc/lib so I modified the cmake line as so:
Code:
_rootopt="$srcdir/opt/vc"
  _libdir="$_rootopt/lib"

  cmake -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DMMAL_INCLUDE_DIR="$_rootopt/include" \
    -DMMAL_LIBRARY="$_libdir" \
    -DMMALCORE_LIBRARY="$_libdir" \
    -DMMALUTIL_LIBRARY="$_libdir" \
    -DMMALCLIENT_LIBRARY="$_libdir" \
    -DMMALCOMPONENT_LIBRARY="$_libdir" \
    -DBCM_LIBRARY="$_libdir" \
    -DVCHOSTIF_LIBRARY="$_libdir" \
    -DVCOS_LIBRARY="$_libdir" \
    -DVCHIQ_LIBRARY="$_libdir" \
    -DVCSM_LIBRARY="$_libdir" \
    -DCONTAINER_LIBRARY="$_libdir" \
    -DVCILCS_LIBRARY="$_libdir" \
...


This still causes build errors/dropped items (since they are not libraries).  Is the solution to modify tools/depends/target/ffmpeg/CMakeLists.txt hardcoding the expected paths therein?
Yep, I was not 100% correct here when I said DSO, I should have said just "library", in case of static libraries ofcourse those will be *.a files.

> Is the solution to modify tools/depends/target/ffmpeg/CMakeLists.txt hardcoding the expected paths therein

https://github.com/popcornmix/xbmc/blob/...ts.txt#L22 the paths there are already hardcoded, make that line matches your actual paths.
(2019-07-25, 22:42)asavah Wrote: [ -> ]Yep, I was not 100% correct here when I said DSO, I should have said just "library", in case of static libraries ofcourse those will be *.a files.

Nice, progress! The build made it MUCH further now that I added this patch.

The build still fails, this time in the linking step it looks like ...complete build log.

Small piece:
Code:
[100%] Linking CXX static library network_upnp.a
[100%] Built target legacy_interface
[100%] Built target network_upnp
Scanning dependencies of target libkodi
[100%] Linking CXX static library libkodi.a
[100%] Built target libkodi
Scanning dependencies of target kodi
[100%] Building CXX object CMakeFiles/kodi.dir/xbmc/platform/posix/main.cpp.o
[100%] Linking CXX executable kodi-gbm
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_init: error: undefined reference to 'bcm_host_init'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_init: error: undefined reference to 'vcsm_init'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_init: error: undefined reference to 'vcsm_malloc_cache'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_init: error: undefined reference to 'vcsm_vc_hdl_from_hdl'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_init: error: undefined reference to 'vcsm_lock'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_free: error: undefined reference to 'vcsm_unlock_ptr'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_free: error: undefined reference to 'vcsm_free'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_free: error: undefined reference to 'vcsm_exit'
/build/kodi-rbp4/src/kodi-build/build/lib/libavcodec.a(rpi_ctrl_ffmpeg.o):rpi_ctrl_ffmpeg.c:function rpi_ctrl_ffmpeg_free: error: undefined reference to 'bcm_host_deinit'
...
Totally expected.

Try adding 
string(CONCAT CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " -L/path/to/dir/where/your/firmware/libs/are")

Just above this line https://github.com/popcornmix/xbmc/blob/...ts.txt#L34
@asavah - Thanks for that.  I added that line (see this patch inspired by your advice) but still got errors on Linking CXX ...

Full build log appears the same.  Linked here.
You still have a truckload of
Quote:WARNING: Target "kodi-test" requests linking to directory "/build/kodi-rbp4/src/opt/vc/lib". Targets may link only to libraries. CMake is dropping the item.
Final binary won't link until this is solved.
You've made quite a mess there with that /build/blah prefix, the buildsystem does not expect this path to rpi specific stuff.
@asavah - Yes, I see them.  If I remove the extra lines, cmake fails early I think due to cmake/modules/FindMMAL.cmake

For example, here is the output from cmake when I remove just one of those lines (in this case the -DVCILCS_LIBRARY="/build/kodi-rbp4/src/kodi-build/opt/vc/lib"):
Code:
...
-- Found EGL: /usr/lib/libEGL.so (found version "19.1.3") 
-- Found GBM: /usr/lib/libgbm.so (found version "19.1.3") 
-- Performing Test GBM_HAS_BO_MAP
-- Performing Test GBM_HAS_BO_MAP - Success
-- Performing Test GBM_HAS_MODIFIERS
-- Performing Test GBM_HAS_MODIFIERS - Success
-- Found LibDRM: /usr/lib/libdrm.so (found version "2.4.99") 
-- Found LibInput: /usr/lib/libinput.so (found version "1.13.4") 
-- Found Xkbcommon: /usr/lib/libxkbcommon.so (found version "0.8.4") 
CMake Error at /usr/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find MMAL (missing: VCILCS_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindMMAL.cmake:29 (find_package_handle_standard_args)
  cmake/scripts/common/Macros.cmake:366 (find_package)
  cmake/scripts/common/Macros.cmake:380 (find_package_with_ver)
  CMakeLists.txt:172 (core_require_dep)


-- Configuring incomplete, errors occurred!
See also "/build/kodi-rbp4/src/kodi-build/CMakeFiles/CMakeOutput.log".
See also "/build/kodi-rbp4/src/kodi-build/CMakeFiles/CMakeError.log".

If those lines are indeed the problem, is there a way we can modify that file to simply not look for them and to pass the needed paths on via hard coding them into it?  I am just not knowledgeable with this cmake file to know how to do that or if it is a sound strategy.

EDIT: I make this patch which I think defines these without having cmake do it but that did not help.  Still got the "Targets may link only to libraries" messages and linking errors.  Build log.  I am not sure how to proceed.
As I've already said *_LIBRARY= are files or symlinks to files and not directories, either .so or .a.
-DVCILCS_LIBRARY="/build/kodi-rbp4/src/kodi-build/opt/vc/lib" is wrong
It should be
-DVCILCS_LIBRARY="/build/kodi-rbp4/src/kodi-build/opt/vc/lib/libvcilcs.a"
and so on.
@asavah - AH!  I understand now.  Thank you very much for your help.  I believe this is 100%.

https://github.com/graysky2/PKGBUILDs/bl...4/PKGBUILD
(2019-07-27, 04:10)graysky Wrote: [ -> ]I believe this is 100%.

Yay!  Cool
(2019-07-27, 04:10)graysky Wrote: [ -> ]@asavah - AH!  I understand now.  Thank you very much for your help.  I believe this is 100%.

https://github.com/graysky2/PKGBUILDs/bl...4/PKGBUILD

Thanks for all the work on this guys! Smile
Agreed, this and the other 2 threads I started on this topic represent a strong team effort with lots of credit going to both @popcornmix and @asavah.  The product of this work is a kodi-rbp4 package with hardware decoding available for Arch ARM.  I submitted PR#1720 earlier today which if accepted will add it to the official repos.

Thanks again, guys!
Nice job. Can you check https://github.com/raspberrypi/linux/pull/3111 as that may require updated udev rules once the change appears in arch kernel.
Pages: 1 2 3