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 <areber@redhat.com>
This commit is contained in:
Adrian Reber 2026-06-05 13:47:11 +00:00 committed by Andrei Vagin
parent 7283ac52ae
commit cba1c94b60
2 changed files with 17 additions and 0 deletions

View file

@ -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.)

View file

@ -156,6 +156,18 @@ int main(void)
}
endef
define FEATURE_TEST_DRM_COLOR_CTM_3X4
#include <drm_mode.h>
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