drm/i915: Ensure _print_param() builds with Clang
authorJani Nikula <jani.nikula@intel.com>
Tue, 16 Oct 2018 12:29:37 +0000 (15:29 +0300)
committerJani Nikula <jani.nikula@intel.com>
Wed, 17 Oct 2018 06:55:21 +0000 (09:55 +0300)
commit7b3e51dd439bead71d9e4504d89a32a8496ac0aa
treedf8baa3f474dc96de2c37c8e5f5460d3d0c28970
parent046c9bca3d829d1f67e4667ffeac099564a683a4
drm/i915: Ensure _print_param() builds with Clang

When building the kernel with Clang with defconfig and CONFIG_64BIT
disabled, vmlinux fails to link because of the BUILD_BUG in
_print_param.

ld: drivers/gpu/drm/i915/i915_params.o: in function `i915_params_dump':
i915_params.c:(.text+0x56): undefined reference to
`__compiletime_assert_191'

This function is semantically invalid unless the code is first inlined
then constant folded, which doesn't work for Clang because semantic
analysis happens before optimization/inlining.

[The above written by Nathan Chancellor <natechancellor@gmail.com>]

Use WARN_ONCE() instead of BUILD_BUG() to avoid the problem. The
WARN_ONCE() should get optimized away unless there's a type that's not
handled by _print_param().

References: https://github.com/ClangBuiltLinux/linux/issues/191
References: http://mid.mail-archive.com/20181009171401.14980-1-natechancellor@gmail.com
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181016122938.18757-1-jani.nikula@intel.com
drivers/gpu/drm/i915/i915_params.c