Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EGL/GLES missing pkgconfig to facilitate building #857

Closed
psyke83 opened this issue Aug 20, 2017 · 13 comments
Closed

EGL/GLES missing pkgconfig to facilitate building #857

psyke83 opened this issue Aug 20, 2017 · 13 comments

Comments

@psyke83
Copy link

psyke83 commented Aug 20, 2017

Hi,

On Debian stretch, the libraspberrypi0 and libraspberrypi-dev packages now use renamed Broadcom libraries for GLES/EGL/OpenVG, but the packages don't include the requisite pkg-config files (which are present in the repository) to enable successful configuration.

Would you be able to package https://github.com/raspberrypi/firmware/tree/master/hardfp/opt/vc/lib/pkgconfig/*.pc in future deb packages? Installing to /opt/vc/lib/pkgconfig will not be sufficient, as pkg-config looks for configuration in /usr/lib/pkgconfig, /usr/share/pkgconfig, /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig.

The PKG_CONFIG_PATH
environment variable will still need to be set to /opt/vc/lib/pkgconfig, but the dummy .pc files using the original names (egl.pc, gl.pc, vg.pc) in their current state would cause problems. I've open a PR for that: raspberrypi/userland#418

Here's an example on an issue that's arisen due to the stretch upgrade: libretro/RetroArch#5351

@psyke83
Copy link
Author

psyke83 commented Aug 20, 2017

I've sent a PR related to this issue: raspberrypi/userland#418

If you merge the PR above and include /opt/vc/lib/pkgconfig/* in libraspberrypi-dev, it will be possible to build against the Broadcom libraries by setting PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig. This will also override the generic glesv2, egl and vg pkgconfig in /usr/lib/*/pkgconfig, ensuring that the new library names are always used for linking.

@XECDesign
Copy link
Contributor

Thanks. This will be added in the next apt firmware release.

@XECDesign
Copy link
Contributor

Looking at your PR, I see you want to include glesv2.pc, although in the apt release of the firmware, I was only going to go for brcm*.pc versions.

@psyke83
Copy link
Author

psyke83 commented Aug 21, 2017

Let me explain the intent of the PR more clearly.

On jessie, I'm running libraspberrypi0 1.20170703-1, which contains both the originally-named libraries alongside the renamed versions:

pi@retropie:~ $ dpkg -S GLESv2.so
libraspberrypi0: /opt/vc/lib/libGLESv2.so
libraspberrypi0: /opt/vc/lib/libbrcmGLESv2.so

This is fine with the existing pkgconfig:
pi@retropie:~ $ PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig pkg-config --libs glesv2
-L/opt/vc/lib -lGLESv2 -lbcm_host -lvcos -lvchiq_arm -pthread
pi@retropie:~ $ PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig pkg-config --libs brcmglesv2
-L/opt/vc/lib -lbrcmGLESv2 -lbcm_host -lvcos -lvchiq_arm -pthread

However, on stretch with firmware 1.20170811:

pi@retropie:~ $ dpkg -S GLESv2.so
libraspberrypi0: /opt/vc/lib/libbrcmGLESv2.so

The system will no longer be able to link GLESv2 via /opt/vc/lib due to the original library now being removed.

However, with my PR:
pi@retropie:~ $ PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig pkg-config --libs glesv2
-L/opt/vc/lib -lbrcmGLESv2 -lbcm_host -lvcos -lvchiq_arm -pthread
pi@retropie:~ $ PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig pkg-config --libs brcmglesv2
-L/opt/vc/lib -lbrcmGLESv2 -lbcm_host -lvcos -lvchiq_arm -pthread

This facilitates compatibility with software that runs on multiple platforms so that glesv2, egl and vg can continued to be specified in automake configurations. Even on RPI, such software will continue to link against mesa libraries by default, when the PKG_CONFIG_PATH is unset.

@XECDesign
Copy link
Contributor

If there is going to be a distinction between glesv2 to refer to mesa's lib and brcmglesv2 to refer to the broadcom lib, why muddy the water with something like PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig pkg-config --libs glesv2? This seems like an opportunity to draw a clear distinction between the two.

@psyke83
Copy link
Author

psyke83 commented Aug 22, 2017

If that's your position, I can understand. But surely you agree that the existing glesv2, egl and vg .pc files are broken with the Raspbian packages? I can rework the PR to delete the files if you want, or simply close it, if you intend to manually omit those files from the deb packages.

The packaging of the pkgconfig will inform projects on how to proceed on building against the Broadcom libs. With my PR, one could build software against the VC4 driver or Broadcom libraries by specifying the PKG_CONFIG_PATH, without having to change existing build configuration.

It doesn't seem optimal to encourage the current practice of people manually detecting RPI by the existence of files in /opt/vc and then manually linking -lbcm_host -lvcos -lvchiq_arm -GLESv2 (now brcmGLESv2).

@XECDesign
Copy link
Contributor

What in the git repos is up to @pelwell and @popcornmix, but I think the apt package will ship with the brcm*.pc only, unless there's a reason to include the other ones. I may of course be missing something.

@psyke83
Copy link
Author

psyke83 commented Aug 22, 2017

That's not as optimal as I would've hoped, but definitely would be appreciated.

Just to clarify, though, you don't mean literally "brcm*.pc"? Those configurations all depend on bcm_host.pc at the minimum, so it's probably best to include everything except egl.pc, glesv2.pc and vg.pc.

@diogomsantos
Copy link

diogomsantos commented Aug 23, 2017

I have been compilling/making Kodi packages and also had problems because of this.

The libraspberrypi0 definitly needs to include the pkg-config files missing, although since now it only includes the broadcom firmware files, makes more sense to include only the respective ones (brcmEGL, brcmGLESv2, etc) and include the pkg-config of the open-source/mesa driver in the respective packages.

Also notice that rpi-update how it is now, includes the pkg-config files but also creates /opt/vc/lib/libEGL.so, libGLESv2, etc which it shouldn't because it can cause linking problems at compile time, mainly because they don't exist in the new Raspbian Stretch Pixel image (which makes sense in your point of view since Raspbian Stretch Pixel image only ships with the broadcom drivers). This should be only in /usr/lib/arm-linux-gnueabih/*, and created only by the mesa packages.

@XECDesign
Copy link
Contributor

Any problem with this approach?
RPi-Distro@2440d33

@psyke83
Copy link
Author

psyke83 commented Aug 24, 2017

This looks good - thank you! Would it not be prudent to do the same for the armel packages? I use a Pi 3, so it doesn't matter to me, but it's probably a good idea to keep things consistent for both ABI types.

@XECDesign
Copy link
Contributor

The armel parts of the package are a bit vestigial. We don't maintain, build or use anything related to armel, at least as far as the apt repo goes.

@psyke83
Copy link
Author

psyke83 commented Aug 25, 2017

Ah, I didn't scroll far enough down to see the recent armel packages were not present. Thanks for the assistance on this matter - I think the issue can be closed now.

@psyke83 psyke83 closed this as completed Aug 25, 2017
psyke83 added a commit to psyke83/userland that referenced this issue Oct 22, 2019
When building software targeting Pi, it's common practice to use
the pkgconfig to assist building by specifying PKG_CONFIG_PATH.

Unfortunately, the presence of the legacy pkgconfig that conflict with
Mesa's libraries will cause issues for users that build against the
firmware pkgconfig, but wish to target Mesa. (Pi 4B or earlier revisions
using the f/kms overlay).

Although a possible workaround may be to omit the custom PKG_CONFIG_PATH
of the firmware pkgconfig during build, there are plausible use cases in
which to target a software build against Mesa whilst also leveraging
the non GL-specific firmware libraries (e.g. MMAL for hardware codec support
that works on the FKMS overlay, or BCM_HOST for basic board detection).

Note: this conflict is already resolved via the Raspbian packages by deliberately
omitting the conflicting .pc files during the packaging stage; see raspberrypi/firmware#857
pelwell pushed a commit to raspberrypi/userland that referenced this issue Oct 24, 2019
When building software targeting Pi, it's common practice to use
the pkgconfig to assist building by specifying PKG_CONFIG_PATH.

Unfortunately, the presence of the legacy pkgconfig that conflict with
Mesa's libraries will cause issues for users that build against the
firmware pkgconfig, but wish to target Mesa. (Pi 4B or earlier revisions
using the f/kms overlay).

Although a possible workaround may be to omit the custom PKG_CONFIG_PATH
of the firmware pkgconfig during build, there are plausible use cases in
which to target a software build against Mesa whilst also leveraging
the non GL-specific firmware libraries (e.g. MMAL for hardware codec support
that works on the FKMS overlay, or BCM_HOST for basic board detection).

Note: this conflict is already resolved via the Raspbian packages by deliberately
omitting the conflicting .pc files during the packaging stage; see raspberrypi/firmware#857
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants