openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.85k stars 2.55k forks source link

[actions] rpi changes #7928

Closed dimitre closed 2 months ago

dimitre commented 2 months ago

This PR intends to fix RPI github actions [hopefully] modernizing and fixing cross compiling issues it replaces compilers installed via ci.openframeworks.cc with apt installable ones (and cached via github actions)

Status:

Errors - all fixed: ~~Using armv6l actions it doesnt find , it is not installable via firmware.zip anymore. Maybe it is possible to install via apt packages, have to research more about this one.

aarch64 alladdonsexample linking errors:

/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: warning: liblapack.so.3, needed by /home/runner/work/openFrameworks/openFrameworks/scripts/ci/linuxrpi/raspbian/usr/lib/aarch64-linux-gnu/libopencv_core.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: warning: libblas.so.3, needed by /home/runner/work/openFrameworks/openFrameworks/scripts/ci/linuxrpi/raspbian/usr/lib/aarch64-linux-gnu/libopencv_core.so, not found (try using -rpath or -rpath-link)
/home/runner/work/openFrameworks/openFrameworks/scripts/ci/linuxrpi/raspbian/usr/lib/aarch64-linux-gnu/libm.a(s_sin.o): in function `__sin':
(.text+0x10): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__stack_chk_guard@@GLIBC_2.17' defined in .data.rel.ro section in /home/runner/work/openFrameworks/openFrameworks/scripts/ci/linuxrpi/raspbian/lib/ld-linux-aarch64.so.1
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: (.text+0x10): warning: too many GOT entries for -fpic, please recompile with -fPIC
collect2: error: ld returned 1 exit status

~~

dimitre commented 2 months ago

Hello @ofTheo @danoli3 @artificiel can you help with some ideas for this one?

artificiel commented 2 months ago

not in a Pi position right now but for bcm_host.h if these changes have implications that go "way back", a few years ago it became necessary to install libraspberrypi-dev and maybe raspberrypi-kernel-headers to get things in general to compile.

dimitre commented 2 months ago

Thanks. for what I've seen there are some headers in this repo / folder https://github.com/raspberrypi/userland host_applications/linux/libs/bcm_host/include

ofTheo commented 2 months ago

@dimitre - I'll have a look! I think I tried doing things without firmware.zip and ran into the same issues with bcm_host.h

artificiel commented 2 months ago

for liblaplack (CV dependency), is liblapack-dev already in there?

depending on how deep you want to dig maybe it's simpler to keep the old pre-packaged toolchain for armv6 and your updated approach from aarch64?

dimitre commented 2 months ago

I suggest we drop armv6l architecture since aarch64 will run in most RPI versions including Pi Zero 2 Pi 3 Pi 4 Pi 5

artificiel commented 2 months ago

+1 for dropping armv6l, but it brings back the idea of having a table of "which version of OF supports which old(er) platforms". it has to be simple to identify and download the binary dist of common legacy systems.

(and/or keeping the old actions in place for armv6 until they really stop working? — as I understand, this issue is an attempt at modernizing the toolchain, presumably to tackle the performance issues with the graphics in Pi4/5, but did the previous setup work as expected for armv6? I remember some fiddling was required around that custom "downloaded" toolchain to get C++17 support on said armv6 actions; if we made it there, it may keep working for a while? and yes move to up-to-date for aarch64).

dimitre commented 2 months ago

now armv6l uses EGL approach which is considered ancient and deprecated. The good news is Linux 6.8 kernel now has video drivers for RPI 5, so things will be easier and more performant.

armv6l is almost working, it is only a fact of downloading and linking correctly bcm_host.h. it is using default toolchains installable with apt-get which turns things easier, faster (github cdn) and less costs for openframeworks.cc server.

dimitre commented 2 months ago

@danoli3 can help us making opencv work with or without lib Lapack and Blas. I've seen in apothecary one parameter like -DWITH_LAPACK=OFF \ but this is for other platforms, in Linux we use apt installed ones, I suppose they are built with Lapack and Blas by default the other option is install them and link them correctly

ofTheo commented 2 months ago

@dimitre what if you add this line to the addon_config.mk for linuxaarch64


linuxaarch64:
    ADDON_PKG_CONFIG_LIBRARIES = opencv4
    ADDON_LIBS_EXCLUDE = libs/opencv/%
    ADDON_INCLUDES_EXCLUDE = libs/opencv
    ADDON_INCLUDES_EXCLUDE += libs/opencv/%
    ADDON_LDFLAGS =  -lblas -llapack  <--- add this line 
dimitre commented 2 months ago

Thanks! Added, let's see how it goes

dimitre commented 2 months ago

Still failing, but I think if we can pass two paths also it can hopefully complete. This two libraries have individual folders like:

/usr/lib/arch64-linux-gnu/blas
/usr/lib/arch64-linux-gnu/lapack

and

/usr/lib/arm-linux-gnueabihf/blas
/usr/lib/arm-linux-gnueabihf/lapack

@ofTheo any ideas of what lines to add in addon_config.mk ?

dimitre commented 2 months ago

bcm_host.h solved and other fixes. it is finishing compilation here locally, still issues on allAddons, only a matter of passing the correct library paths I think

dimitre commented 2 months ago

Great! everything good with allAddons in all platforms. I'll be tidying up for merging. any objections?

ofTheo commented 2 months ago

congrats @dimitre !! ooof - that was a gnarly one.