Linking `libsfwbar.so` fails: undefined reference to `shm_unlink`
savchenko opened this issue · comments
$ ninja -C build
ninja: Entering directory `build'
[76/87] Linking target libsfwbar.so
FAILED: libsfwbar.so
cc -o libsfwbar.so libsfwbar.so.p/meson-generated_.._wlr-foreign-toplevel-management-unstable-v1.c.o libsfwbar.so.p/meson-generated_.._xdg-output-unstable-v1.c.o libsfwbar.so.p/meson-generated_.._wlr-layer-shell-unstable-v1.c.o libsfwbar.so.p/src_action.c.o libsfwbar.so.p/src_actionlib.c.o libsfwbar.so.p/src_bar.c.o libsfwbar.so.p/src_basewidget.c.o libsfwbar.so.p/src_button.c.o libsfwbar.so.p/src_cchart.c.o libsfwbar.so.p/src_chart.c.o libsfwbar.so.p/src_client.c.o libsfwbar.so.p/src_css.c.o libsfwbar.so.p/src_expr.c.o libsfwbar.so.p/src_exprlib.c.o libsfwbar.so.p/src_flowgrid.c.o libsfwbar.so.p/src_flowitem.c.o libsfwbar.so.p/src_grid.c.o libsfwbar.so.p/src_hypr_ipc.c.o libsfwbar.so.p/src_image.c.o libsfwbar.so.p/src_jpath.c.o libsfwbar.so.p/src_label.c.o libsfwbar.so.p/src_menu.c.o libsfwbar.so.p/src_misc.c.o libsfwbar.so.p/src_module.c.o libsfwbar.so.p/src_mpd.c.o libsfwbar.so.p/src_pager.c.o libsfwbar.so.p/src_pageritem.c.o libsfwbar.so.p/src_popup.c.o libsfwbar.so.p/src_scale.c.o libsfwbar.so.p/src_scaleimage.c.o libsfwbar.so.p/src_scanner.c.o libsfwbar.so.p/src_signal.c.o libsfwbar.so.p/src_sni.c.o libsfwbar.so.p/src_sniitem.c.o libsfwbar.so.p/src_snimenu.c.o libsfwbar.so.p/src_sway_ipc.c.o libsfwbar.so.p/src_switcher.c.o libsfwbar.so.p/src_switcheritem.c.o libsfwbar.so.p/src_taskbar.c.o libsfwbar.so.p/src_taskbaritem.c.o libsfwbar.so.p/src_taskbarpager.c.o libsfwbar.so.p/src_taskbarpopup.c.o libsfwbar.so.p/src_tray.c.o libsfwbar.so.p/src_trayitem.c.o libsfwbar.so.p/src_wayland.c.o libsfwbar.so.p/src_window.c.o libsfwbar.so.p/src_wintree.c.o libsfwbar.so.p/src_workspace.c.o libsfwbar.so.p/src_config_base.c.o libsfwbar.so.p/src_config_init.c.o libsfwbar.so.p/src_config_layout.c.o libsfwbar.so.p/src_config_placer.c.o libsfwbar.so.p/src_config_scanner.c.o libsfwbar.so.p/src_config_switcher.c.o libsfwbar.so.p/src_config_toplevel.c.o libsfwbar.so.p/src_wayland_foreign-toplevel.c.o libsfwbar.so.p/src_wayland_probe.c.o libsfwbar.so.p/src_wayland_xdg-output.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libsfwbar.so /usr/lib/x86_64-linux-gnu/libgtk-3.so /usr/lib/x86_64-linux-gnu/libgdk-3.so /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so /usr/lib/x86_64-linux-gnu/libpango-1.0.so /usr/lib/x86_64-linux-gnu/libharfbuzz.so /usr/lib/x86_64-linux-gnu/libatk-1.0.so /usr/lib/x86_64-linux-gnu/libcairo-gobject.so /usr/lib/x86_64-linux-gnu/libcairo.so /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so /usr/lib/x86_64-linux-gnu/libgio-2.0.so /usr/lib/x86_64-linux-gnu/libgobject-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so -Wl,--export-dynamic /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so -pthread /usr/lib/x86_64-linux-gnu/libgtk-layer-shell.so /usr/lib/x86_64-linux-gnu/libwayland-client.so /usr/lib/x86_64-linux-gnu/libjson-c.so -Wl,--end-group
/usr/bin/ld: libsfwbar.so.p/src_wayland_probe.c.o: in function `wayland_monitor_probe':
/home/user/.shares/user_code/sfwbar/build/../src/wayland/probe.c:100: undefined reference to `shm_open'
/usr/bin/ld: /home/user/.shares/user_code/sfwbar/build/../src/wayland/probe.c:102: undefined reference to `shm_unlink'
collect2: error: ld returned 1 exit status
[77/87] Compiling C object idleinhibit.so.p/modules_idleinhibit.c.o
ninja: build stopped: subcommand failed.
Ref. #136
This looks like a missing librt, needed on older glibc versions. I added it as an optional link time dependency. Can you check if the latest git works for you?
Thank you, this one compiles. However it doesn't seem to play nicely with Sway v1.5:
./sfwbar -f ~/.config/sfwbar/test.config
21:17:49.73 It appears your Wayland compositor does not support the Layer Shell protocol
21:17:49.73 It appears your Wayland compositor does not support the XDG Shell stable protocol
21:17:49.73 layer_surface_new: assertion 'gtk_wayland_get_layer_shell_global ()' failed
21:17:49.73 Falling back to XDG shell instead of Layer Shell (surface should appear but layer features will not work)
21:17:49.73 xdg_toplevel_surface_new: assertion 'gtk_wayland_get_xdg_wm_base_global ()' failed
21:17:49.73 Shell does not support XDG shell stable. Falling back to default GTK behavior
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 layer_surface_new: assertion 'gtk_wayland_get_layer_shell_global ()' failed
21:17:49.73 Falling back to XDG shell instead of Layer Shell (surface should appear but layer features will not work)
21:17:49.73 xdg_toplevel_surface_new: assertion 'gtk_wayland_get_xdg_wm_base_global ()' failed
21:17:49.73 Shell does not support XDG shell stable. Falling back to default GTK behavior
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
21:17:49.73 GtkWindow is not a layer surface. Make sure you called gtk_layer_init_for_window ()
Gdk-Message: 21:17:49.758: Error 22 (Invalid argument) dispatching to Wayland display.
I have libgtk-layer-shell0
v0.5.2-2 installed if that matters. Worth creating another issue and closing this one?
This is very different. It looks like gtk-layer-shell can't negotiate layer shell and xdg shell protocols with the compositor. Are other layer shell programs able to run in this session? I.e. swaybar or waybar?
Yes, I run waybar
v0.9.5 without any obvious problems.
Can you try running ldd
on sfwbar and waybar executables? I wonder a wrong library dependency gets pulled in somewhere.
I assume you're running both bars from the same session and not inside a container?
Attached:
Same session, no containers or other shenanigans. Relevant environment variables:
CLUTTER_BACKEND=wayland
ECORE_EVAS_ENGINE=wayland_egl
ELM_ENGINE=wayland_egl
I3SOCK=/home/user/.local/runtime/sway-ipc.1000.1782.sock
MOZ_ENABLE_WAYLAND=1
QT_WAYLAND_DISABLE_WINDOWDECORATION=1
SDL_VIDEODRIVER=wayland
SWAYSOCK=/home/user/.local/runtime/sway-ipc.1000.1782.sock
WAYLAND_DISPLAY=wayland-0
XDG_CURRENT_DESKTOP=sway
XDG_SESSION_DESKTOP=sway
XDG_SESSION_TYPE=wayland
Using c75388b, both waybar
and sfwbar
can run simultaneously.
ldd output looks fine. Can you try building sfwbar with the attached patch? This disables sfwbar's own wayland support and only relies on gtk/gtk-layer-shell.
Alas, this is not a fix yet. This patch disables all direct communication with the compositor over the wayland protocol. It helps pinpoint the cause of the issue, but it's not a fix. Let me try to narrow down the cause of this. I may need to ask you to try more patches, since unfortunately I can't reproduce this issue locally.
Can you please check the below patch? If I'm guessing correctly, it shouldn't block the layer shell protocol, but may still block the xdg output protocol. This isn't fix either I'm afraid, but hopefully it will bring us closer to identifying the culprit.
test1.txt
Actually, can you try the latest git version unpatched please? I think the issue may be caused by binding a layer shell version 2 or earlier.
f9502a1 works without patch applied:
./sfwbar
09:10:32.41 layer shell: 2
09:10:32.41 (../src/gtk-wayland.c:63):wl_registry_handle_global: runtime check failed: (zwlr_layer_shell_v1_interface.version == 3)
This patch disables all direct communication with the compositor over the wayland protocol
With the commit above I see highlight of the active workspace and window changing correctly.
Also, I can strace
while performing a particular action that triggers such communication if that is of any help.
I think this is fixed, to the extent it can be fixed. I removed the first line of the debug output layer shell: 2
, the second line comes from gtk-layer-shell. It warns you that your compositor only supports an older version of the layer shell protocol and some functionality may not work.
In practice, for sfwbar, we have to disable probing of a default output and on a multi-monitor setups. The bar may popup on a "first" monitor rather than the one you're working on. You can still assign it to a specific monitor using SetMonitor
.
Closing this for now as it seems to be resolved. Please feel free to reopen if you encounter this issue again.