-
Notifications
You must be signed in to change notification settings - Fork 229
Description
When building swaylock with the gdk-pixbuf feature disabled (-Dgdk-pixbuf=disabled), the build fails due to unused or undefined variables in the code, particularly in comm.c.
It seems the build does not properly exclude code paths that depend on gdk-pixbuf or related features when the feature is turned off. This results in variables like struct sigaction sa being defined but unused, or undeclared identifiers like SIG_IGN and SIGUSR1 being referenced when their headers aren't included.
Steps to reproduce
-
Clone the repo and checkout the latest tagged release (or
master). -
Run the Meson setup with these options:
meson setup build -Dgdk-pixbuf=disabled ...
-
Run:
meson compile -C build
Error output
Click to expand
$ arch-meson build --buildtype=release --auto-features=disabled -Dstrip=true -Db_lto=true -Db_lto_mode=default -Db_ndebug=true -Dpam=enabled -Dgdk-pixbuf=disabled -Dman-pages=enabled -Dzsh-completions=false -Dbash-completions=true -Dfish-completions=false+ exec meson setup --prefix /usr --libexecdir lib --sbindir bin --buildtype plain --auto-features enabled --wrap-mode nodownload -D b_pie=true -D python.bytecompile=1 build --buildtype=release --auto-features=disabled -Dstrip=true -Db_lto=true -Db_lto_mode=default -Db_ndebug=true -Dpam=enabled -Dgdk-pixbuf=disabled -Dman-pages=enabled -Dzsh-completions=false -Dbash-completions=true -Dfish-completions=false
The Meson build system
Version: 1.9.1
Source dir: /home/c/web-dev/pkgbuilds-wayland/swaylock-pure/swaylock-1.8.3
Build dir: /home/c/web-dev/pkgbuilds-wayland/swaylock-pure/swaylock-1.8.3/build
Build type: native build
Project name: swaylock
Project version: 1.8.3
C compiler for the host machine: cc (gcc 15.2.1 "cc (GCC) 15.2.1 20250813")
C linker for the host machine: cc ld.bfd 2.45.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-unused-parameter: YES
Compiler for C supports arguments -Wno-unused-result: YES
Compiler for C supports arguments -Wundef: YES
Compiler for C supports arguments -Wvla: YES
Found pkg-config: YES (/usr/bin/pkg-config) 2.5.1
Run-time dependency wayland-client found: YES 1.24.0
Run-time dependency wayland-protocols found: YES 1.45
Build-time dependency wayland-scanner found: YES 1.24.0
Run-time dependency xkbcommon found: YES 1.11.0
Run-time dependency cairo found: YES 1.18.4
Dependency gdk-pixbuf-2.0 skipped: feature gdk-pixbuf disabled
Library pam found: YES
Library crypt found: YES
Library m found: YES
Library rt found: YES
Program git found: YES (/usr/bin/git)
Program scdoc found: YES (/usr/bin/scdoc)
Program /usr/bin/wayland-scanner found: YES (/usr/bin/wayland-scanner)
Configuring config.h using configuration
Run-time dependency bash-completion found: YES 2.16.0
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency fish found: NO (tried pkgconfig and cmake)
Build targets in project: 2
swaylock 1.8.3
User defined options
auto_features : disabled
b_lto : true
b_lto_mode : default
b_ndebug : true
b_pie : true
bash-completions : true
buildtype : release
fish-completions : false
gdk-pixbuf : disabled
libexecdir : lib
man-pages : enabled
pam : enabled
prefix : /usr
python.bytecompile: 1
sbindir : bin
strip : true
wrap_mode : nodownload
zsh-completions : false
Found ninja-1.12.1 at /usr/bin/ninja$ meson compile -C build/
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/c/web-dev/pkgbuilds-wayland/swaylock-pure/swaylock-1.8.3/build
ninja: Entering directory `/home/c/web-dev/pkgbuilds-wayland/swaylock-pure/swaylock-1.8.3/build'
[9/18] Compiling C object swaylock.p/comm.c.o
FAILED: swaylock.p/comm.c.o
cc -Iswaylock.p -I. -I.. -Iinclude -I../include -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/pixman-1 -flto=auto -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -D_POSIX_C_SOURCE=200809L -Wno-unused-parameter -Wno-unused-result -Wundef -Wvla -fPIE -DWITH_GZFILEOP -MD -MQ swaylock.p/comm.c.o -MF swaylock.p/comm.c.o.d -o swaylock.p/comm.c.o -c ../comm.c
../comm.c: In function ‘spawn_comm_child’:
../comm.c:99:24: error: variable ‘sa’ has initializer but incomplete type
99 | struct sigaction sa = {
| ^~~~~~~~~
../comm.c:100:26: error: ‘struct sigaction’ has no member named ‘sa_handler’
100 | .sa_handler = SIG_IGN,
| ^~~~~~~~~~
../comm.c:100:39: error: ‘SIG_IGN’ undeclared (first use in this function)
100 | .sa_handler = SIG_IGN,
| ^~~~~~~
../comm.c:100:39: note: each undeclared identifier is reported only once for each function it appears in
../comm.c:100:39: error: excess elements in struct initializer [-Werror]
../comm.c:100:39: note: (near initialization for ‘sa’)
../comm.c:99:34: error: storage size of ‘sa’ isn’t known
99 | struct sigaction sa = {
| ^~
../comm.c:102:17: error: implicit declaration of function ‘sigaction’ [-Wimplicit-function-declaration]
102 | sigaction(SIGUSR1, &sa, NULL);
| ^~~~~~~~~
../comm.c:102:27: error: ‘SIGUSR1’ undeclared (first use in this function)
102 | sigaction(SIGUSR1, &sa, NULL);
| ^~~~~~~
../comm.c:99:34: error: unused variable ‘sa’ [-Werror=unused-variable]
99 | struct sigaction sa = {
| ^~
cc1: all warnings being treated as errors
[17/18] Compiling C object swaylock.p/main.c.o
ninja: build stopped: subcommand failed.Suggested fix
A possible fix would be to wrap the usage of struct sigaction, SIGUSR1, and related functions/macros in #ifdefs or conditionally include the required headers (e.g., <signal.h>) only if that part of the code is enabled. Alternatively, adjust the build files to exclude entire compilation units that rely on gdk-pixbuf if the feature is disabled.