Skip to content

Use system SDL2 on Linux instead of Conan#3058

Draft
tomjn wants to merge 1 commit into
beyond-all-reason:conanfrom
tomjn:conan-sdl-linux-system
Draft

Use system SDL2 on Linux instead of Conan#3058
tomjn wants to merge 1 commit into
beyond-all-reason:conanfrom
tomjn:conan-sdl-linux-system

Conversation

@tomjn

@tomjn tomjn commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Stacked on top of #2900 (the Conan migration). Targets the conan branch.

Problem

The conan-center SDL2 recipe hard-links Wayland/EGL into the binary instead of letting SDL dlopen() them at runtime — unlike X11, which the recipe already lets SDL load dynamically. Concretely the recipe ties SDL_WAYLAND_SHARED to the (static) conan wayland dependency and force-injects wayland/xkbcommon/egl into the consumer link line. The result is the runtime Wayland breakage reported in #2900 (segfaults unless EGL_PLATFORM=wayland is set).

This is Marek's sanctioned option 1: keep taking SDL2 from the system on Linux (where the distro libSDL2.so already follows SDL's portable "link glibc, dlopen the rest" model), and only use the Conan SDL2 on Windows where there's no system SDL2 to rely on.

An upstream fix for the recipe itself is tracked in conan-io/conan-center-index#30465 — if accepted, Linux could take SDL2 from Conan again and this workaround could be retired.

Changes

  • conanfile.py — require & configure sdl only on Windows
  • docker-build-v2/images/all-linux/Dockerfile — install libsdl2-dev
  • rts/build/cmake/FindSDL2.cmake — restored: use a Conan config package if present, otherwise locate the system SDL2 via pkg-config
  • find_package(SDL2 MODULE ...) at the call sites — needed because Conan's toolchain sets CMAKE_FIND_PACKAGE_PREFER_CONFIG ON and Ubuntu 18.04's sdl2-config.cmake (2.0.8) sets SDL2_LIBRARIES but defines no SDL2::SDL2 target; without MODULE the finder is bypassed and the target is never created

Verification

Built natively on arm64-linux (image + engine) and inspected the link signature:

  • conan graph info: SDL/Wayland/EGL gone from the Linux graph; sdl/2.32.10 still present for Windows
  • engine compiles (rc=0)
  • readelf -d spring: links libSDL2-2.0.so.0 (system, dynamic), libX11/libXcursor (the engine's own usage), and no libwayland* / libEGL direct entries — matching the current working release
  • spring-headless / spring-dedicated: no SDL (stub only)

Caveats

  • Runtime not exercised — only the link signature was verified (no display on the build host). It now matches the known-good release linkage; a live X11 + Wayland run would close the loop.
  • libstdc++.so.6 still appears as a NEEDED entry on spring; that's a pre-existing item on the conan branch, unrelated to this change.

Draft pending a runtime check and review.

The Conan SDL2 recipe hard-links Wayland/EGL into the binary instead of
letting SDL dlopen them at runtime (unlike X11), which breaks SDL's
portable Linux model and causes runtime failures under Wayland.

Take SDL2 from Conan only on Windows; on Linux link against the system
libSDL2 (libsdl2-dev), restoring the runtime-dlopen behaviour that
matches current releases.

- conanfile.py: require and configure sdl only on Windows
- all-linux Dockerfile: install libsdl2-dev
- restore FindSDL2.cmake: use a Conan config package if present, else
  locate the system SDL2 via pkg-config
- find_package(SDL2 MODULE ...) at the call sites so the finder runs
  even with Conan's CMAKE_FIND_PACKAGE_PREFER_CONFIG and the
  target-less system SDL 2.0.8 cmake config
@sprunk sprunk added the area: devops/gitops CI/CD pipelines, Docker builds, CMake build system, and repository infrastructure label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: devops/gitops CI/CD pipelines, Docker builds, CMake build system, and repository infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants