Skip to content

objtool: bad .discard.annotate_insn #2162

@sinatosk

Description

@sinatosk

I was asked to report the issue here by nickdesaulniers from here related to llvm/llvm-project#195657. I posted to that existing issue as I thought it might be the same.

I'm using Gentoo Linux 2.18 and Linux 7.1-rc2 mainline with the following packages from Gentoo's repository

recently LLVM 22.1.5 was released in Gentoo's testing repository and I included GCC 16.1.0 from testing repository.

I've tried the following with and without march/mtune set.

I've compiled Linux with LLVM 22.1.4 ( LLVM 22.1.4 at this point was compiled by GCC 15.2.1 ) but after upgrading to LLVM 22.1.5 ( LLVM 22.1.5 at this point was compiled by GCC 16.1.0 ) and compiling Linux with Clang 22.1.5 failed with the following errors

drivers/video/fbdev/core/fb.o: error: objtool: bad .discard.annotate_insn entry: 25 of type 8
make[6]: *** [scripts/Makefile.build:507: drivers/video/fbdev/core/fb.o] Error 255
make[6]: *** Deleting file 'drivers/video/fbdev/core/fb.o'
make[5]: *** [scripts/Makefile.build:548: drivers/video/fbdev/core] Error 2
make[4]: *** [scripts/Makefile.build:548: drivers/video/fbdev] Error 2
make[3]: *** [scripts/Makefile.build:548: drivers/video] Error 2
make[3]: *** Waiting for unfinished jobs....
drivers/gpu/drm/display/drm_display_helper.o: error: objtool: bad .discard.annotate_insn entry: 0 of type 8
make[6]: *** [scripts/Makefile.build:507: drivers/gpu/drm/display/drm_display_helper.o] Error 255
make[6]: *** Deleting file 'drivers/gpu/drm/display/drm_display_helper.o'
make[5]: *** [scripts/Makefile.build:548: drivers/gpu/drm/display] Error 2
make[4]: *** [scripts/Makefile.build:548: drivers/gpu/drm] Error 2
make[3]: *** [scripts/Makefile.build:548: drivers/gpu] Error 2
make[2]: *** [scripts/Makefile.build:548: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
arch/x86/kvm/kvm-amd.o: error: objtool: bad .discard.annotate_insn entry: 63 of type 7
make[4]: *** [scripts/Makefile.build:507: arch/x86/kvm/kvm-amd.o] Error 255
make[4]: *** Deleting file 'arch/x86/kvm/kvm-amd.o'
make[3]: *** [scripts/Makefile.build:548: arch/x86/kvm] Error 2
make[2]: *** [scripts/Makefile.build:548: arch/x86] Error 2
fs/smb/server/ksmbd.o: error: objtool: bad .discard.annotate_insn entry: 0 of type 8
make[5]: *** [scripts/Makefile.build:507: fs/smb/server/ksmbd.o] Error 255
make[5]: *** Deleting file 'fs/smb/server/ksmbd.o'
make[4]: *** [scripts/Makefile.build:548: fs/smb/server] Error 2
make[4]: *** Waiting for unfinished jobs....
sound/soc/dwc/designware_i2s.o: error: objtool: +0xdc5: special: can't find orig instruction
make[5]: *** [scripts/Makefile.build:507: sound/soc/dwc/designware_i2s.o] Error 255
make[5]: *** Deleting file 'sound/soc/dwc/designware_i2s.o'
make[4]: *** [scripts/Makefile.build:548: sound/soc/dwc] Error 2
make[3]: *** [scripts/Makefile.build:548: sound/soc] Error 2
make[2]: *** [scripts/Makefile.build:548: sound] Error 2
net/tls/tls.o: error: objtool: bad .discard.annotate_insn entry: 0 of type 8
make[4]: *** [scripts/Makefile.build:507: net/tls/tls.o] Error 255
make[4]: *** Deleting file 'net/tls/tls.o'
make[3]: *** [scripts/Makefile.build:548: net/tls] Error 2
make[3]: *** Waiting for unfinished jobs....
fs/nfs/nfs.o: error: objtool: bad .discard.annotate_insn entry: 0 of type 8
make[4]: *** [scripts/Makefile.build:507: fs/nfs/nfs.o] Error 255
make[4]: *** Deleting file 'fs/nfs/nfs.o'
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:548: fs/nfs] Error 2
make[3]: *** Waiting for unfinished jobs....
fs/f2fs/f2fs.o: error: objtool: bad .discard.annotate_insn entry: 0 of type 8
make[4]: *** [scripts/Makefile.build:507: fs/f2fs/f2fs.o] Error 255
make[4]: *** Deleting file 'fs/f2fs/f2fs.o'
make[3]: *** [scripts/Makefile.build:548: fs/f2fs] Error 2
make[3]: *** [scripts/Makefile.build:548: fs/smb] Error 2
make[2]: *** [scripts/Makefile.build:548: net] Error 2
make[2]: *** [scripts/Makefile.build:548: fs] Error 2
make[1]: *** [/usr/src/linux-mainline/Makefile:2141: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

So I downgraded to LLVM 22.1.4 ( at this point it was compiled by GCC 16.1.0 ) thinking it was a bug with LLVM 22.1.5 and it still failed with the same above errors which I thought was odd as I've compiled Linux mainline successfully with LLVM 22.1.4 before ( at that point LLVM 22.1.4 was compiled by GCC 15.2.1 ).

I downgraded GCC to 15.2.1 by

  • Compiled GCC 15.2.1 using GCC 16.1.0
  • Compiled LLVM 22.1.5 using GCC 15.2.1

and now Linux mainline successfully compiles with LLVM 22.1.5 ( Linux compiles with GCC 16.1.0 too ).

So I'm wondering if GCC 16.1.0 is compiling LLVM 22.1.4/22.1.5 incorrectly ( I've not tested LLVM lower than 22.1.4 )

At the time of this post, I'm now running Linux 7.1-rc2 compiled by LLVM 22.1.5 ( bootstrapped from GCC 15.2.1 ) from Linus's mainline at commit fcee7d82f27d6a8b1ddc5bbefda59b4e441e9bc0

Metadata

Metadata

Assignees

No one assigned

    Labels

    [FIXED][LLVM] 23This bug was fixed in LLVM 23[TOOL] lldThe issue is relevant to LLD linker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions