Skip to content

Commit 429f6bb

Browse files
committed
09: the modules are named for whoever owns the interface
import khronos.egl / import freedesktop.wayland.{client,server}. A module name is global and permanent in a way a package name is not, so it names the INTERFACE's owner: freedesktop owns the wayland protocol, Khronos owns EGL and libglvnd merely implements it. That is why freedesktop.egl the PACKAGE exports khronos.egl the MODULE, and the mismatch is deliberate. The closure listing was re-measured rather than edited: libEGL.so.1 and libGLdispatch.so.0 now come from this build too, where before they came from compat-x-egl and the xim:libglvnd payload. Also records that the same program was built and run from scratch inside `xlings subos use … --sandbox --gpu`, where /usr is still the host's and its libEGL/libgbm/libdrm/libwayland are all present and reachable -- and lost anyway. "Nothing from the host" is a claim about what WINS, not about what exists, and only the second version of that claim matches a user's machine.
1 parent d68ded6 commit 429f6bb

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

‎examples/09-graphics-stack/README.md‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ answer: the whole chain, done the recommended way, declaring dependencies.
5353
[target.'cfg(linux)'.dependencies.compat]
5454
libdrm = "2.4.134"
5555
libgbm = "25.0.7"
56-
egl = "1.7.0"
5756

5857
[target.'cfg(linux)'.dependencies.freedesktop]
58+
egl = "1.7.0"
5959
wayland = "1.26.0"
6060
wayland-server = "1.26.0"
6161
```
@@ -85,37 +85,53 @@ BIN=target/x86_64-linux-gnu/*/bin/graphics-stack
8585

8686
```
8787
<project>/bin/libdrm.so.2 <- built by this build
88+
<project>/bin/libEGL.so.1 <- built by this build
89+
<project>/bin/libGLdispatch.so.0 <- built by this build
8890
<project>/bin/libwayland-client.so.0 <- built by this build
8991
<project>/bin/libwayland-server.so.0 <- built by this build
9092
<project>/bin/libffi.so.8 <- built by this build
9193
compat-x-libgbm/25.0.7/…/libgbm.so.1
92-
compat-x-egl/1.7.0/…/libEGL.so.1
9394
xim-x-expat/2.6.2/lib/libexpat.so.1
9495
xim-x-gcc/16.1.0/lib64/libgcc_s.so.1
9596
xim-x-gcc/16.1.0/lib64/libstdc++.so.6
9697
xim-x-glibc/2.44/lib64/libc.so.6
9798
xim-x-glibc/2.44/lib64/libm.so.6
98-
xim-x-libglvnd/1.7.0.1/lib/libGLdispatch.so.0
9999
```
100100

101-
Nothing is under `/usr/lib` or `/lib64`. Two things there are worth reading
101+
Nothing is under `/usr/lib` or `/lib64`. Three things there are worth reading
102102
closely.
103103

104-
**The first four lines.** They are this project's own build output, not the
104+
**The first six lines.** They are this project's own build output, not the
105105
ecosystem's copies — including `libdrm.so.2`, even though Mesa's `libgbm.so.1`
106106
has a DT_NEEDED on that soname and an absolute RUNPATH into the payload. The
107107
consumer links them directly, so they are mapped first, and Mesa binds to them:
108108
the `gbm_bo_create` above ran through this libdrm.
109109

110+
**`libEGL.so.1` and `libGLdispatch.so.0` are on that list.** The ecosystem's
111+
`xim:libglvnd` carries both under the same sonames, and it is installed on this
112+
machine — but only one library per soname is ever mapped and nothing warns
113+
about the loser, so "EGL worked" is not evidence that *this* EGL worked. The
114+
index's test member pins it from the other direction with `dladdr`, and this
115+
example prints `EGL 1.5, vendor Mesa Project` through the build above.
116+
110117
**`libffi` and `libGLdispatch`.** Nothing in `mcpp.toml` names either.
111118
`libffi.so.8` is what `libwayland-client` dispatches protocol messages through,
112119
`libGLdispatch` is what libEGL's vendor dispatch needs — the cascade a directly
113120
linked library pulls behind it, which is exactly what a host `-L/usr/lib`
114121
cannot resolve from inside a private loader.
115122

123+
**Verified with the host present, not absent.** The same program was built and
124+
run from scratch inside `xlings subos use … --sandbox --gpu`, in a synthetic
125+
home where none of this machine's checkouts or caches reach — and where `/usr`
126+
is still the host's, so `/usr/lib/x86_64-linux-gnu/libEGL.so.1`,
127+
`libgbm.so.1`, `libdrm.so.2` and `libwayland-client.so.0` are all present and
128+
reachable. Every graphics library still resolved to the project's own output or
129+
the ecosystem payload. "Nothing from the host" is a claim about what *wins*,
130+
not about what exists.
131+
116132
## The packages
117133

118-
Three are built from source and two bind the ecosystem's Mesa, and the split is
134+
Four are built from source and one binds the ecosystem's Mesa, and the split is
119135
not arbitrary. A library is built from source when upstream ships it as a
120136
**separable unit**; it is bound when it is an internal build target of a project
121137
the ecosystem already owns, where building it would mean forking that project.
@@ -124,9 +140,9 @@ the ecosystem already owns, where building it would mean forking that project.
124140
|---|---|---|
125141
| `compat.libdrm` | source | `drmModeGetResources`, `drmModeAddFB2`, `drmModeSetCrtc` — the KMS side |
126142
| `compat.libgbm` | binds `xim:mesa` | `gbm_create_device`, `gbm_bo_create` — buffers out of a DRM device |
127-
| `freedesktop.egl` | source | `eglGetPlatformDisplay(EGL_PLATFORM_GBM_KHR, …)` — rendering onto them, and `import egl;` |
128-
| `freedesktop.wayland` | source | `libwayland-client.so.0`, and `import wayland.client;` |
129-
| `freedesktop.wayland-server` | source | `libwayland-server.so.0`, and `import wayland.server;` |
143+
| `freedesktop.egl` | source | `eglGetPlatformDisplay(EGL_PLATFORM_GBM_KHR, …)` — rendering onto them, and `import khronos.egl;` |
144+
| `freedesktop.wayland` | source | `libwayland-client.so.0`, and `import freedesktop.wayland.client;` |
145+
| `freedesktop.wayland-server` | source | `libwayland-server.so.0`, and `import freedesktop.wayland.server;` |
130146

131147
**Four of the five are source builds.** GBM is the only binding, and the
132148
paragraphs below are about why the line falls where it does.
@@ -207,7 +223,7 @@ package's sources — so one package cannot emit two libraries with disjoint
207223
contents. A client-only program drops the second line and links only
208224
`libwayland-client.so.0`.
209225

210-
Both also ship a C++23 module wrapper. `import wayland.client;` in place of
226+
Both also ship a C++23 module wrapper. `import freedesktop.wayland.client;` in place of
211227
`#include <wayland-client.h>` changes nothing else — every exported name is
212228
upstream's, spelled upstream's way — so this file could switch one line at a
213229
time. It uses the headers here because that is what a ported project looks like

‎examples/09-graphics-stack/mcpp.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[indices]
2+
freedesktop = { path = "/home/speak/workspace/github/mcpplibs/mcpp-index" }
3+
14
[package]
25
name = "graphics-stack"
36
version = "0.1.0"
@@ -35,7 +38,7 @@ libgbm = "25.0.7" # Mesa's GBM: buffer allocation out of a DRM device
3538
#
3639
# All three ship a C++23 module wrapper too. This example uses the headers, and
3740
# for a reason worth knowing: `EGL_PLATFORM_GBM_KHR` and friends are MACROS, and
38-
# no module can export a macro — so `import egl;` replaces the declarations but
41+
# no module can export a macro — so `import khronos.egl;` replaces the declarations but
3942
# never the `#include <EGL/eglext.h>` that the constants come from.
4043
[target.'cfg(linux)'.dependencies.freedesktop]
4144
wayland = "1.26.0"

0 commit comments

Comments
 (0)