kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
22.14k stars 908 forks source link

glfw/wl_init.c:640:18: error: variable has incomplete type struct ucred #7346

Closed nivit closed 1 month ago

nivit commented 1 month ago

Describe the bug Kitty v. 0.34.0 doesn't build under FreeBSD-14.0-RELEASE. It fails with the following error:

[30/119] Compiling kitty/disk-cache.c ...
glfw/wl_init.c:640:18: error: variable has incomplete type struct ucred
    struct ucred ucred;
                 ^
glfw/wl_init.c:640:12: note: forward declaration of struct ucred
    struct ucred ucred;
           ^
glfw/wl_init.c:641:21: error: invalid application of sizeof to an incomplete type struct ucred
    socklen_t len = sizeof(struct ucred); 
                    ^     ~~~~~~~~~~~~~~
glfw/wl_init.c:640:12: note: forward declaration of struct ucred
    struct ucred ucred;
           ^
glfw/wl_init.c:642:36: error: use of undeclared identifier SO_PEERCRED
    if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1) {
                                   ^
3 errors generated.
 done
Compiling [wayland] glfw/wl_init.c ...
cc -MMD -DNDEBUG -DHAS_COPY_FILE_RANGE -DEPOLL_SHIM_DISABLE_WRAPPER_MACROS -I/usr/local/include/libepoll-shim -D_GLFW_WAYLAND -D_GLFW_BUILD_DLL -Wextra -Wfloat-conversion -Wno-missing-field-initializers -Wall -Wstrict-prototypes -std=c11 -pedantic-errors -Werror -
O3 -fwrapv -fstack-protector-strong -pipe -fvisibility=hidden -fno-plt -fPIC -O2 -pipe -Wno-error=invalid-utf8 -Winvalid-utf8 -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -flto -I/usr/local/include -fcf-protection=full -fPIC -pthread -I/usr/local/include -I/usr/local/
include/libepoll-shim -I/usr/local/include -I/usr/local/include/libepoll-shim -I/usr/local/include -I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -c glfw/wl_init.c -o build/glfw-wayland-glfw-wl_init.c.o
*** Error code 1  

Stop.

Full log

Enviroment

FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
kovidgoyal commented 1 month ago

I dont use BSDs, somebody that knows how to get socket peer credentials on them needs to port that function to them.

nivit commented 1 month ago

Thanks for the answer. Maybe a solution such as that adopted by Heimdal Project here?

kovidgoyal commented 1 month ago

That does not get PID only UID/GID. In any case have already committed code to do it, no idea if it actually works.