linux - Linux 内核构建编译器断言错误

我在构建内核时遇到问题。这是我在终端中输入的内容。

$ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.5.16.tar.xz
$ xz -d linux-5.5.16.tar.xz
$ tar xvf linux-5.5.16.tar
$ apt update
$ apt install build-essential libncurses5 libncurses5-dev bin86 kernel-package libssh-dev bison flex libelf-dev
$ cd linux-5.5.16/
$ cp /boot/config-5.15.0-30-generic ./.config
$ make menuconfig
$ make -j6
$ make modules

并且发生了下面的错误代码。

./include/linux/compiler.h:350:45: error: call to ‘__compiletime_assert_653’ declared with attribute error: BUILD_BUG_ON failed: (((0x0ffULL) + (1ULL << (__builtin_ffsll(0x0ffULL) - 1))) & (((0x0ffULL) + (1ULL << (__builtin_ffsll(0x0ffULL) - 1))) - 1)) != 0
  350 |         _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
      |                                             ^
./include/linux/compiler.h:331:25: note: in definition of macro ‘__compiletime_assert’
  331 |                         prefix ## suffix();                             \
      |                         ^~~~~~
./include/linux/compiler.h:350:9: note: in expansion of macro ‘_compiletime_assert’
  350 |         _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
      |         ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
   39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
      |                                     ^~~~~~~~~~~~~~~~~~
./include/linux/bitfield.h:49:17: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
   49 |                 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?           \
      |                 ^~~~~~~~~~~~~~~~
./include/linux/bitfield.h:67:17: note: in expansion of macro ‘__BF_FIELD_CHECK’
   67 |                 __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_FIT: ");     \
      |                 ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/bpf/jit.c:653:13: note: in expansion of macro ‘FIELD_FIT’
  653 |         if (FIELD_FIT(UR_REG_IMM_MAX, imm))
      |             ^~~~~~~~~
make[5]: *** [scripts/Makefile.build:266: drivers/net/ethernet/netronome/nfp/bpf/jit.o] Error 1
make[4]: *** [scripts/Makefile.build:503: drivers/net/ethernet/netronome/nfp] Error 2
make[3]: *** [scripts/Makefile.build:503: drivers/net/ethernet/netronome] Error 2
make[2]: *** [scripts/Makefile.build:503: drivers/net/ethernet] Error 2
make[1]: *** [scripts/Makefile.build:503: drivers/net] Error 2
make: *** [Makefile:1694: drivers] Error 2

我该如何解决?我要花一整天的时间来解决这个问题。请帮我。

回答1

我今天也遇到了这个错误。原因是最新的 gcc/g++ 有 bug。您应该将 gcc/g++ 版本降级到 9.4。见第二个答案[https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version]

相似文章

随机推荐

最新文章