fix(wayland): constant-initialised statics in Device, for clang 23.1 on aarch64-musl

With the touch positions in an inline static std::unordered_map and the
text input's strings in inline static std::strings, clang 23.1 crashed
compiling Device.cpp for aarch64-alpine-linux-musl against that sysroot's
libc++ 22 — in LazyCallGraph at -O3, in the ThinLTO bitcode writer at -O0
(a dangling global); the native build was fine. The fingers now live in a
constant-initialised array of slots and the strings in function-local
statics of the implementation unit; nothing else changes.
This commit is contained in:
Jorijn van der Graaf 2026-10-18 02:06:03 +02:00
commit cc04d4e121
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 80 additions and 23 deletions

View file

@ -62,8 +62,17 @@ export namespace Crafter {
inline static std::vector<Window*> windows;
inline static wl_pointer* wlPointer;
inline static wl_touch* wlTouch = nullptr;
inline static Window* touchWindow = nullptr; // the window under the fingers
inline static std::unordered_map<std::int32_t, std::pair<float, float>> touchPositions; // per finger, physical px
inline static Window* touchWindow = nullptr; // the window under the fingers
// The fingers down, by the compositor's id, in physical pixels. Plain
// data: the statics here are constant-initialised on purpose.
struct TouchSlot {
std::int32_t id;
float x;
float y;
bool used;
};
inline static std::array<TouchSlot, 10> touchSlots{};
static void ForgetTouches();
// wl_data_device_manager + wl_data_device drive copy/paste. Bound
// lazily in handle_global; the data device is created once both
// the manager and the seat are present (registry binding order
@ -83,9 +92,6 @@ export namespace Crafter {
inline static zwp_text_input_manager_v3* textInputManager = nullptr;
inline static zwp_text_input_v3* textInput = nullptr;
inline static Window* textInputWindow = nullptr;
inline static std::string textInputPreedit;
inline static std::string textInputShownPreedit; // what the window was last told
inline static std::string textInputCommit;
inline static std::uint32_t textInputDeleteBefore = 0;
inline static std::uint32_t textInputDeleteAfter = 0;
inline static bool textInputHasPreedit = false;