History

lib/bitmap: workaround const_eval test build failure

When building with Clang, and when KASAN and GCOV_PROFILE_ALL are both enabled, the test fails to build [1]: >> lib/test_bitmap.c:920:2: error: call to '__compiletime_assert_239' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(res) BUILD_BUG_ON(!__builtin_constant_p(res)); ^ include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON' BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^ include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^ include/linux/compiler_types.h:352:2: note: expanded from macro 'compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ include/linux/compiler_types.h:340:2: note: expanded from macro '_compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) ^ include/linux/compiler_types.h:333:4: note: expanded from macro '__compiletime_assert' prefix ## suffix(); \ ^ <scratch space>:185:1: note: expanded from here __compiletime_assert_239 Originally it was attributed to s390, which now looks seemingly wrong. The issue is not related to bitmap code itself, but it breaks build for a given configuration. Disabling the const_eval test under that config may potentially hide other bugs. Instead, workaround it by disabling GCOV for the test_bitmap unless the compiler will get fixed. [1] https://github.com/ClangBuiltLinux/linux/issues/1874

Yury Norov committed 3 years ago

Commit 2356d191 parent dcb60f92 files · +10 −4Browse files

Unified · Split

2 files
  1. lib/Makefile +6 −0
  2. lib/test_bitmap.c +4 −4
lib/Makefile+6−0
@@ -82,7 +82,13 @@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o · 81 unmodified lines
82obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o82obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
83obj-$(CONFIG_TEST_PRINTF) += test_printf.o83obj-$(CONFIG_TEST_PRINTF) += test_printf.o
84obj-$(CONFIG_TEST_SCANF) += test_scanf.o84obj-$(CONFIG_TEST_SCANF) += test_scanf.o
85
85obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o86obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
87ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy)
88# FIXME: Clang breaks test_bitmap_const_eval when KASAN and GCOV are enabled
89GCOV_PROFILE_test_bitmap.o := n
90endif
91
86obj-$(CONFIG_TEST_UUID) += test_uuid.o92obj-$(CONFIG_TEST_UUID) += test_uuid.o
87obj-$(CONFIG_TEST_XARRAY) += test_xarray.o93obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
88obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o94obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o
lib/test_bitmap.c+4−4
@@ -1161,6 +1161,10 @@ static void __init test_bitmap_print_buf(void) · 1160 unmodified lines
1161 }1161 }
1162}1162}
1163 1163
1164/*
1165 * FIXME: Clang breaks compile-time evaluations when KASAN and GCOV are enabled.
1166 * To workaround it, GCOV is force-disabled in Makefile for this configuration.
1167 */
1164static void __init test_bitmap_const_eval(void)1168static void __init test_bitmap_const_eval(void)
1165{1169{
1166 DECLARE_BITMAP(bitmap, BITS_PER_LONG);1170 DECLARE_BITMAP(bitmap, BITS_PER_LONG);
@@ -1186,11 +1190,7 @@ static void __init test_bitmap_const_eval(void) · 19 unmodified lines
1186 * the compiler is fixed.1190 * the compiler is fixed.
1187 */1191 */
1188 bitmap_clear(bitmap, 0, BITS_PER_LONG);1192 bitmap_clear(bitmap, 0, BITS_PER_LONG);
1189#if defined(__s390__) && defined(__clang__)
1190 if (!const_test_bit(7, bitmap))
1191#else
1192 if (!test_bit(7, bitmap))1193 if (!test_bit(7, bitmap))
1193#endif
1194 bitmap_set(bitmap, 5, 2);1194 bitmap_set(bitmap, 5, 2);
1195 1195
1196 /* Equals to `unsigned long bitopvar = BIT(20)` */1196 /* Equals to `unsigned long bitopvar = BIT(20)` */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t