Skip to content

BUILD_BUG() failed with arm64's gki_defconfig #1503

@nathanchance

Description

@nathanchance

During Android's mainline merges, I noticed a patch removing some BUILD_BUG() calls that were triggering. This can be reproduced with a ToT LLVM and mainline kernel with Android's gki_defconfig so this is probably something that should be investigated and fixed.

$ clang --version | head -n1
ClangBuiltLinux clang version 14.0.0 (https://github.com/llvm/llvm-project 9b6f264d2b09ab5e970e54f77119eb823f0fcc50)

$ git show -s --format='%h ("%s")'
5833291ab6de ("Merge tag 'pci-v5.16-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci")

# gitlies's txt export is base64 encoded so it has to be decoded...
$ curl -LSs 'https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/arch/arm64/configs/gki_defconfig?format=TEXT' | base64 -d > .config

# Android uses full LTO, which takes forever; this bug can be reproduced with ThinLTO
$ scripts/config -d LTO_CLANG_FULL -e LTO_CLANG_THIN

$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 olddefconfig vmlinux
ld.lld: error: call to __compiletime_assert_200 marked "dontcall-error": BUILD_BUG failed
...

Brief initial triage leads me to believe this is an LTO problem, as outright disabling LTO makes the problem go away:

$ curl -LSs 'https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/arch/arm64/configs/gki_defconfig?format=TEXT' | base64 -d > .config

$ scripts/config -d LTO_CLANG_FULL

$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 olddefconfig vmlinux

$ echo $?
0

I will see if I can figure out exactly what configuration options tickle this then create a small reproducer and report it upstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [ARCH] arm64This bug impacts ARCH=arm64[BUG] linuxA bug that should be fixed in the mainline kernel.[FEATURE] CFIRelated to building the kernel with Clang Control Flow Integrity[FIXED][LINUX] 5.16This bug was fixed in Linux 5.16

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions