lv2 / pugl

A minimal portable API for embeddable GUIs
https://gitlab.com/lv2/pugl/
ISC License
179 stars 34 forks source link

build: Linker error when X extensions are disabled during configure #123

Closed NexAdn closed 4 months ago

NexAdn commented 5 months ago

TL;DR Throws linker errors when building with any of -Dxcursor=disabled, -Dxrandr=disabled or -Dxsync=disabled.

System

Description

Linking against libX11 seems to be mandatory on Linux. However, commit 580584e896abfa9324e58c0fad39476cb4cc077c made building against libXcursor, libXrandr and libXext optional by allowing users to disable the associated features with -Dxcursor, -Dxrandr and -Dxsync, respectively. However, this does not work as expected (at least) on my Wayland machine, as I see the below output when trying to build with any of these options disabled. It does not matter which of these options is disabled. As long as one of these options is disabled, linker errors occur, failing to find symbols defined in the respective X library (i.e. XSync symbols missing with -Dxsync=disabled, XRR symbols missing with -Dxrandr=disabled and Xcursor symbols missing with -Dxcursor=disabled).

I guess this means that there is still code around somewhere in the codebase that uses those symbols even if the corresponding features are disabled.

Build log

❯ meson setup build -Dbuildtype=debug -Ddocs=disabled -Dtests=enabled -Dcairo=disabled -Dopengl=disabled -Dvulkan=disabled -Dxcursor=disabled -Dxrandr=disabled -Dxsync=disabled --wipe
The Meson build system
Version: 1.4.0
Source dir: /projects/pugl
Build dir: /projects/pugl/build
Build type: native build
Project name: pugl
Project version: 0.5.3
C compiler for the host machine: clang (clang 17.0.6 "clang version 17.0.6")
C linker for the host machine: clang ld.bfd 2.41
Host machine cpu family: x86_64
Host machine cpu: x86_64
C++ compiler for the host machine: clang++ (clang 17.0.6 "clang version 17.0.6")
C++ linker for the host machine: clang++ ld.bfd 2.41
Library dl found: YES
Library X11 found: YES
Library Xcursor skipped: feature xcursor disabled
Library Xrandr skipped: feature xrandr disabled
Library Xext skipped: feature xsync disabled
Compiler for C supports arguments -Wno-reserved-identifier: YES 
Library m found: YES
Found pkg-config: YES (/usr/bin/pkg-config) 2.2.0
Dependency GL skipped: feature opengl disabled
Dependency cairo skipped: feature cairo disabled
Dependency vulkan skipped: feature vulkan disabled
Build targets in project: 18
NOTICE: Future-deprecated features used:
 * 0.64.0: {'copy arg in configure_file'}

pugl 0.5.3

  Configuration
    Platform                     : x11
    Cursor support (XCursor)     : NO
    Refresh rate support (XRandR): NO
    Timer support (XSync)        : NO

  Backends
    Cairo                        : NO
    OpenGL                       : NO
    Stub                         : YES
    Vulkan                       : NO

  Components
    Tests                        : YES
    Examples                     : YES
    Documentation                : NO

  Directories
    Install prefix               : /usr/local
    Headers                      : /usr/local/include
    Libraries                    : /usr/local/lib64
    Executables                  : /usr/local/bin

  User defined options
    buildtype                    : debug
    cairo                        : disabled
    docs                         : disabled
    opengl                       : disabled
    tests                        : enabled
    vulkan                       : disabled
    xcursor                      : disabled
    xrandr                       : disabled
    xsync                        : disabled

Found ninja-1.11.1 at /usr/bin/ninja
❯ ninja -C build
ninja: Entering directory `build'
[20/40] Linking target libpugl_x11-0.so.0.5.3
FAILED: libpugl_x11-0.so.0.5.3 
clang  -o libpugl_x11-0.so.0.5.3 libpugl_x11-0.so.0.5.3.p/src_common.c.o libpugl_x11-0.so.0.5.3.p/src_internal.c.o libpugl_x11-0.so.0.5.3.p/src_x11.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,-soname,libpugl_x11-0.so.0 -Wl,--start-group -lX11 -lm -Wl,--end-group
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: libpugl_x11-0.so.0.5.3.p/src_x11.c.o: in function `initXSync':
/projects/pugl/build/../src/x11.c:127:(.text+0x5e4): undefined reference to `XSyncQueryExtension'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:128:(.text+0x601): undefined reference to `XSyncInitialize'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:129:(.text+0x61a): undefined reference to `XSyncListSystemCounters'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:138:(.text+0x6ac): undefined reference to `XSyncFreeSystemCounterList'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: libpugl_x11-0.so.0.5.3.p/src_x11.c.o: in function `puglRealize':
/projects/pugl/build/../src/x11.c:649:(.text+0x1046): undefined reference to `XRRQueryExtension'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:651:(.text+0x1062): undefined reference to `XRRGetScreenInfo'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:652:(.text+0x1075): undefined reference to `XRRConfigCurrentRate'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:655:(.text+0x109c): undefined reference to `XRRFreeScreenConfigInfo'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: libpugl_x11-0.so.0.5.3.p/src_x11.c.o: in function `puglStartTimer':
/projects/pugl/build/../src/x11.c:1386:(.text+0x212d): undefined reference to `XSyncIntToValue'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:1394:(.text+0x21d2): undefined reference to `XSyncCreateAlarm'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:1401:(.text+0x22a1): undefined reference to `XSyncDestroyAlarm'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: libpugl_x11-0.so.0.5.3.p/src_x11.c.o: in function `puglStopTimer':
/projects/pugl/build/../src/x11.c:1434:(.text+0x249b): undefined reference to `XSyncDestroyAlarm'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: libpugl_x11-0.so.0.5.3.p/src_x11.c.o: in function `defineCursorName':
/projects/pugl/build/../src/x11.c:473:(.text+0x41ea): undefined reference to `XcursorGetTheme'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:480:(.text+0x420d): undefined reference to `XcursorGetDefaultSize'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:481:(.text+0x4220): undefined reference to `XcursorLibraryLoadImage'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:487:(.text+0x4248): undefined reference to `XcursorImageLoadCursor'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /projects/pugl/build/../src/x11.c:488:(.text+0x4255): undefined reference to `XcursorImageDestroy'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[21/40] Compiling C++ object test/test_inline_cpp.p/test_inline_cpp.cpp.o
ninja: build stopped: subcommand failed.
drobilla commented 4 months ago

Fixed in 55245b9, thanks.