Yggdrasil icon indicating copy to clipboard operation
Yggdrasil copied to clipboard

add recipe for EGL

Open simeonschaub opened this issue 4 years ago • 34 comments

simeonschaub avatar Jun 20 '21 08:06 simeonschaub

It's unfortunate that Libglvnd provides a library with the same name. This will likely cause a warning if a user loads both packages

Will it just cause a warning or could it also lead to the wrong library being used?

Any idea what this means?

[08:56:32] /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.1.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /opt/x86_64-linux-musl/lib/libLLVM-11.so when searching for -lLLVM-11
[08:56:32] /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lLLVM-11
``

simeonschaub avatar Jun 20 '21 09:06 simeonschaub

Will it just cause a warning or could it also lead to the wrong library being used?

Whatever happens when two packages export the same variable. Warning + you must qualify the variable with its module?

giordano avatar Jun 20 '21 09:06 giordano

Ah, I thought it was something specific to BB. I don't think it should matter too much then, since I think this warning is only shown in interactive usage, not when it's done in a package. Packages only need to remember to qualify the module.

simeonschaub avatar Jun 20 '21 09:06 simeonschaub

Now that I think of it, you can't dlopen two libraries with the same soname, the first one will win

giordano avatar Jun 20 '21 10:06 giordano

Would you be okay with merging a fixed-up version of this with a more obscure name for now? I think we can probably separate out some of the components into separate jlls, but I looked into it a bit and the interdependencies and dealing with the right driver components didn't seem very straightforward.

simeonschaub avatar Jun 21 '21 12:06 simeonschaub

For the name, yes, I don't think calling this Mesa is an option at all at this point, so we have to stick to something like this. I'm a bit worried about the clash with libglvnd, that's a real concern at runtime. Have you seen how Linux distributions go about this? Maybe the mark the two packages as conflicting?

giordano avatar Jun 21 '21 22:06 giordano

Have you seen how Linux distributions go about this? Maybe the mark the two packages as conflicting?

It looks like Debian declares libegl as a dependency for libglvnd, so I assume that libglvnd can probably be made to use the libegl provided here. Of course that would also mean that libglvnd always depends on wayland. Arch actually seems to have a circular dependency between the two, so not sure what's going on there. I can try to make this recipe more minimal and split the components up a bit more, so we can maybe have them as separate jlls.

simeonschaub avatar Jun 21 '21 22:06 simeonschaub

Oh, no wait! I think libegl actually comes from libglvnd in Debian? https://tracker.debian.org/pkg/libglvnd

simeonschaub avatar Jun 21 '21 22:06 simeonschaub

Yes, that's what I was looking at now: they just split the libglvnd source into multiple binary packages. But as far as I can see the package you're building here isn't involved

giordano avatar Jun 21 '21 22:06 giordano

It appears that the package they build out of this source has libEGL_mesa.so, not libEGL.so: https://packages.debian.org/sid/amd64/libegl-mesa0/filelist

giordano avatar Jun 21 '21 23:06 giordano

egl-lib-suffix sounds relevant

giordano avatar Jun 21 '21 23:06 giordano

Also, in Debian they build with glvnd=true (option in meson_options.txt), I don't know if that's useful for us

giordano avatar Jun 21 '21 23:06 giordano

So the way that things work between Mesa and Libglvnd is the following:

  • If building Mesa without -Dglvnd, libEGL.so is produced and will be directly opened by the client
  • If building Mesa with -Dglvnd, libEGL_mesa.so is produced. The client will open Libglvnd's libEGL.so, which will forward calls to libEGL_mesa.so

Basically, if you're going to link Libglvnd into a process, then Mesa better have been built with -Dglvnd. Otherwise you'll end up with two libEGL.so libraries, which will just not work correctly.

jpsamaroo avatar Jul 10 '21 17:07 jpsamaroo

Pinging @Wimmerer who's also interested in Mesa

giordano avatar Jul 16 '21 23:07 giordano

I think we should probably name this Mesa_EGL_jll, and (if possible) patch GLFW_jll to use an environment variable (or similar) to select between loading Libglvnd_jll and Mesa_EGL_jll. This is one of those cases where, without us building all of the graphics libs, we need to support differences in OS configurations manually.

jpsamaroo avatar Dec 14 '21 01:12 jpsamaroo

It's been a while since I last messed up a git history this badly... ;)

simeonschaub avatar Feb 23 '22 04:02 simeonschaub

Do we need to install wayland-dev? I figured that we could just use Wayland_jll to provide headers.

jpsamaroo avatar Feb 23 '22 14:02 jpsamaroo

Looks like this is now having troubles with the LLVM dependencies. I'm not sure how to work around that. I also don't want to lick any cookies here, so if you want to take this over that's perfectly fine by me.

simeonschaub avatar Feb 23 '22 17:02 simeonschaub

Is there a reason why you don't apk add meson and mkdir build; cd build anymore?

jpsamaroo avatar Feb 23 '22 17:02 jpsamaroo

That was a workaround to get a newer meson version, but I can still try adding that back

simeonschaub avatar Feb 23 '22 17:02 simeonschaub

Yeah, I double-checked locally that this doesn't make a difference

simeonschaub avatar Feb 23 '22 17:02 simeonschaub

I get different errors locally, relating to using an old version of Wayland_protocols_jll. I'll work on this locally and see how far I can get.

jpsamaroo avatar Feb 23 '22 18:02 jpsamaroo

Just a quick update: I've got a local build that works great with GLFW! I've been able to run a CImGui demo as well, proving that it actually works. I'm in the process of working out the last bug before pushing changes (which are somewhat extensive, but we also now enable a lot more mesa functionality).

jpsamaroo avatar Feb 25 '22 17:02 jpsamaroo

Not sure what's up with the static_assert failure.

Aside: Do we need/want this built on glibc?

jpsamaroo avatar Feb 25 '22 20:02 jpsamaroo

Alternatively: this is now building the full set of userspace graphics drivers. Do we instead want to move this to Mesa_jll? That would imply that we would be shipping the entire userspace graphics stack (minus the compositor), and would be able to do away with Libglvnd.

jpsamaroo avatar Feb 25 '22 21:02 jpsamaroo

Aside: Do we need/want this built on glibc?

Would be nice at least. Not everyone's using Alpine you know... :sweat_smile:

Do we instead want to move this to Mesa_jll?

I don't really care either way. Perhaps @giordano has some thoughts?

simeonschaub avatar Feb 25 '22 22:02 simeonschaub

Not everyone's using Alpine you know...

Oops, sorry, I had assumed this was to fix issues on musl-based distros!

jpsamaroo avatar Feb 25 '22 22:02 jpsamaroo

My initial motivation for this was actually because I had the silly idea to build a window manager entirely using BinaryBuilder...

simeonschaub avatar Feb 25 '22 22:02 simeonschaub

Awesome!

@giordano I'm :+1: to merging this. I can send another PR for the augmented platform support for supporting multiple LLVM versions.

jpsamaroo avatar Feb 25 '22 23:02 jpsamaroo

@jpsamaroo bump :slightly_smiling_face: There are a couple of questions above

giordano avatar Mar 01 '22 01:03 giordano