From cba1c94b602cfe221f4a96d9c1b768feee33b5a8 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Fri, 5 Jun 2026 13:47:11 +0000 Subject: [PATCH] build: detect drm_color_ctm_3x4 in system libdrm headers The amdgpu plugin's local amdgpu_drm.h defines struct drm_color_ctm_3x4 guarded by #ifndef HAVE_DRM_COLOR_CTM_3X4, but HAVE_DRM_COLOR_CTM_3X4 was never defined by the build system. On systems where libdrm headers already provide this struct (e.g. Alpine with libdrm 2.4.131), clang rejects the redefinition as a hard error, while gcc silently accepts identical struct redefinitions as an extension. Add a feature test that checks whether struct drm_color_ctm_3x4 is available in the system drm_mode.h and pass -DHAVE_DRM_COLOR_CTM_3X4 when it is, so the local fallback definition is skipped. Assisted-by: Claude Code (claude-opus-4-6):2025-09-03 Signed-off-by: Adrian Reber --- Makefile.config | 5 +++++ scripts/feature-tests.mak | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Makefile.config b/Makefile.config index 5cf4b8216..d338f852a 100644 --- a/Makefile.config +++ b/Makefile.config @@ -26,6 +26,11 @@ endif ifeq ($(call pkg-config-check,libdrm),y) export CONFIG_AMDGPU := y + LIBDRM_CFLAGS := $(shell $(PKG_CONFIG) --cflags libdrm) + ifeq ($(call try-cc,$(FEATURE_TEST_DRM_COLOR_CTM_3X4),,$(LIBDRM_CFLAGS)),true) + export CONFIG_HAS_DRM_COLOR_CTM_3X4 := y + FEATURE_DEFINES += -DHAVE_DRM_COLOR_CTM_3X4 + endif $(info Note: Building with amdgpu_plugin.) else $(info Note: Building without amdgpu_plugin.) diff --git a/scripts/feature-tests.mak b/scripts/feature-tests.mak index ea5b88647..c447bb445 100644 --- a/scripts/feature-tests.mak +++ b/scripts/feature-tests.mak @@ -156,6 +156,18 @@ int main(void) } endef +define FEATURE_TEST_DRM_COLOR_CTM_3X4 + +#include + +int main(void) +{ + struct drm_color_ctm_3x4 ctm = {}; + + return (int)ctm.matrix[0]; +} +endef + define FEATURE_TEST_NO_LIBC_RSEQ_DEFS #ifdef __has_include