Build breakage after commit 436326bc525d
Subsystems (2)
Hi Sasha,
Commit 436326bc525d ("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.
Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc' /usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable' /usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits' /usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler' /usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc' /usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...
(many more similar messages skipped).
Reverting commit 436326bc525d makes the problem go away.
BR, Rafael
Peter Zijlstra
maintainerQuoted 39 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...
Quoted 3 lines
(many more similar messages skipped).
Reverting commit
436326bc525dmakes the problem go away.
Bah, I hate makefiles.
Anyway, the below is that revert + adding an explicit libbfd-opcodes feature test.
Did I do this right? Josh, Arnaldo, could you comment on that CC vs HOSTCC issue that Sasha mentioned?
---
tools/build/Makefile.feature +1 -0
@@ -117,6 +117,7 @@ FEATURE_TESTS_EXTRA := \ libcapstone \ libbfd-liberty \ libbfd-liberty-z \ + libbfd-opcodes \ libopencsd \ libperl \ cxx \
tools/build/feature/Makefile +4 -0
@@ -19,6 +19,7 @@ FILES= \ test-reallocarray.bin \ test-libbfd-liberty.bin \ test-libbfd-liberty-z.bin \ + test-libbfd-opcodes.bin \ test-cplus-demangle.bin \ test-cxa-demangle.bin \ test-libcap.bin \
@@ -288,6 +289,9 @@ endif $(OUTPUT)test-libbfd-liberty-z.bin: $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz +$(OUTPUT)test-libbfd-opcodes.bin: + $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c $(LDFLAGS) -lbfd -ldl -lopcodes + $(OUTPUT)test-cplus-demangle.bin: $(BUILD) -liberty
tools/objtool/Makefile +10 -14
@@ -72,27 +72,23 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # # To support disassembly, objtool needs libopcodes which is provided -# with libbfd (binutils-dev or binutils-devel package). +# with libbdf (binutils-dev or binutils-devel package). # -# We check using HOSTCC directly rather than the shared feature framework -# because objtool is a host tool that links against host libraries. -# -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +FEATURE_USER = .objtool +FEATURE_TESTS = libbfd-opcodes disassembler-init-styled +FEATURE_DISPLAY = +include $(srctree)/tools/build/Makefile.feature -# Styled disassembler support requires binutils >= 2.39 -HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ - $(HOSTCC) -E -xc - 2>/dev/null | grep -q disassembler_style && echo y) +ifeq ($(feature-disassembler-init-styled), 1) + OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED +endif BUILD_DISAS := n -ifeq ($(HAVE_LIBOPCODES),y) +ifeq ($(feature-libbfd-opcodes),1) BUILD_DISAS := y - OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' + OBJTOOL_CFLAGS += -DDISAS -DPACKAGE="objtool" OBJTOOL_LDFLAGS += -lopcodes -ifeq ($(HAVE_DISASM_STYLED),y) - OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED -endif endif export BUILD_DISAS
Quoted 40 lines · Peter Zijlstra
Quoted 39 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...
Quoted 3 lines
Quoted 3 lines
(many more similar messages skipped).
Reverting commit
436326bc525dmakes the problem go away.
Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
Quoted 4 lines
Bah, I hate makefiles.
Anyway, the below is that revert + adding an explicit libbfd-opcodes feature test.
If the issue is indeed static libs, then I don't think that the below would work.
I think that we need to explicitly list out all the dependencies rather than just -lopcodes.
With only -lopcodes:
$ echo '#include <dis-asm.h>
int main(void) { disassemble_init_for_target(NULL); return 0; }' | gcc -xc - -DPACKAGE='"test"' -lopcodes -o /tmp/test/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/15/../../../x86_64-linux-gnu/libopcodes.a(i386-dis.o): warning: relocation against _sch_istable' in read-only section .text' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/15/../../../x86_64-linux-gnu/libopcodes.a(i386-dis.o): in function `i386_dis_printf':
./builddir-single/opcodes/../../opcodes/i386-dis.c:9675:(.text+0x673): undefined reference to `_sch_istable'/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/15/../../../x86_64-linux-gnu/libopcodes.a(i386-dis.o): in function `putop':
./builddir-single/opcodes/../../opcodes/i386-dis.c:10825:(.text+0x8f65): undefined reference to `_sch_istable'/usr/bin/ld: ./builddir-single/opcodes/../../opcodes/i386-dis.c:11075:(.text+0x9eb1): undefined reference to `_sch_istable'/usr/bin/ld: ./builddir-single/opcodes/../../opcodes/i386-dis.c:10919:(.text+0xa007): undefined reference to `_sch_istable'/usr/bin/ld: ./builddir-single/opcodes/../../opcodes/i386-dis.c:11002:(.text+0xa190): undefined reference to `_sch_istable'/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/15/../../../x86_64-linux-gnu/libopcodes.a(i386-dis.o):./builddir-single/opcodes/../../opcodes/i386-dis.c:11071: more undefined references to _sch_istable' follow /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/15/../../../x86_64-linux-gnu/libopcodes.a(disassemble.o): in function opcodes_assert':
./builddir-single/opcodes/../../opcodes/disassemble.c:856:(.text+0x2ae): undefined reference to `_bfd_error_handler'/usr/bin/ld: ./builddir-single/opcodes/../../opcodes/disassemble.c:857:(.text+0x2d0): undefined reference to `_bfd_error_handler'/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
With the rest of the dependencies:
$ echo '#include <dis-asm.h>
int main(void) { disassemble_init_for_target(NULL); return 0; }' | gcc -xc - -DPACKAGE='"test"' -lopcodes -lbfd -liberty -lz -o /tmp/test$ echo $? 0
But I'm not sure how we determine what the dependencies are exactly without trying all the various combinations of them...
The below patch also brings back the cross compilation issue that originally prompted my patch (see
https://qa-reports.linaro.org/lkft/sashal-linus-next/build/v6.18-rc7-14082-gef67311bf79e/testrun/30638724/suite/build/test/gcc-14-ppc6xx_defconfig/log)
Quoted 80 lines
Did I do this right? Josh, Arnaldo, could you comment on that CC vs HOSTCC issue that Sasha mentioned?
---
tools/build/Makefile.feature +1
-0@@ -117,6 +117,7 @@ FEATURE_TESTS_EXTRA := \ libcapstone \ libbfd-liberty \ libbfd-liberty-z \ + libbfd-opcodes \ libopencsd \ libperl \ cxx \tools/build/feature/Makefile +1
-0@@ -19,6 +19,7 @@ FILES= \ test-reallocarray.bin \ test-libbfd-liberty.bin \ test-libbfd-liberty-z.bin \ + test-libbfd-opcodes.bin \ test-cplus-demangle.bin \ test-cxa-demangle.bin \ test-libcap.bin \@@ -288,6 +289,9 @@ endif$(OUTPUT)test-libbfd-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz+$(OUTPUT)test-libbfd-opcodes.bin:
tools/build/feature/Makefile +2
-0+ $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c $(LDFLAGS) -lbfd -ldl -lopcodes +$(OUTPUT)test-cplus-demangle.bin:
$(BUILD) -libertytools/objtool/Makefile +8
-9@@ -72,27 +72,23 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # # To support disassembly, objtool needs libopcodes which is provided -# with libbfd (binutils-dev or binutils-devel package). +# with libbdf (binutils-dev or binutils-devel package). # -# We check using HOSTCC directly rather than the shared feature framework -# because objtool is a host tool that links against host libraries. -# -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +FEATURE_USER = .objtool +FEATURE_TESTS = libbfd-opcodes disassembler-init-styled +FEATURE_DISPLAY = +include $(srctree)/tools/build/Makefile.feature -# Styled disassembler support requires binutils >= 2.39 -HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ - $(HOSTCC) -E -xc - 2>/dev/null | grep -q disassembler_style && echo y) +ifeq ($(feature-disassembler-init-styled), 1) + OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED +endif
BUILD_DISAS:= ntools/objtool/Makefile +1
-1-ifeq ($(HAVE_LIBOPCODES),y) +ifeq ($(feature-libbfd-opcodes),1)
BUILD_DISAS:= ytools/objtool/Makefile +1
-1- OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' + OBJTOOL_CFLAGS += -DDISAS -DPACKAGE="objtool"OBJTOOL_LDFLAGS += -lopcodestools/objtool/Makefile +0
-3-ifeq ($(HAVE_DISASM_STYLED),y) - OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED -endifendif
export
BUILD_DISAS
Signature · 2 lines
Thanks, Sasha
Quoted 42 lines · Sasha Levin
Quoted 40 lines · Peter Zijlstra
Quoted 39 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
(many more similar messages skipped).
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
Quoted 45 lines · Rafael J. Wysocki
Quoted 44 lines · Sasha Levin
Quoted 42 lines · Peter Zijlstra
Quoted 41 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...(many more similar messages skipped).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
ls /usr/lib/*/libopcodes*
Signature · 2 lines
Thanks, Sasha
Quoted 51 lines · Sasha Levin
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Sasha Levin
Quoted 40 lines · Peter Zijlstra
Quoted 39 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...Quoted 3 lines
Quoted 3 lines
(many more similar messages skipped).
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
ls
/usr/lib/*/libopcodes*
"No such file or directory"
However,
Quoted 1 line
ls
/usr/lib64/libopcodes*
/usr/lib64/libopcodes-2.45.0.20251103-150100757.so /usr/lib64/libopcodes.a
Quoted 59 lines · Rafael J. Wysocki
Quoted 58 lines · Sasha Levin
Quoted 45 lines · Rafael J. Wysocki
Quoted 44 lines · Sasha Levin
Quoted 42 lines · Peter Zijlstra
Quoted 41 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...(many more similar messages skipped).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
Quoted 8 lines
Quoted 1 line
ls
/usr/lib/*/libopcodes*"No such file or directory"
However,
Quoted 1 line
ls
/usr/lib64/libopcodes*
/usr/lib64/libopcodes-2.45.0.20251103-150100757.so/usr/lib64/libopcodes.a
The linker looks for libopcodes.so (not the versioned .so). Without that symlink, it falls back to libopcodes.a. So yes, looks like you're using static linking.
To confirm, can you try to:
sudo ln -s libopcodes-2.45.0.20251103-150100757.so /usr/lib64/libopcodes.so
Any then running the build again?
Signature · 2 lines
Thanks, Sasha
Quoted 74 lines · Sasha Levin
Quoted 59 lines · Rafael J. Wysocki
Quoted 58 lines · Sasha Levin
Quoted 45 lines · Rafael J. Wysocki
Quoted 44 lines · Sasha Levin
Quoted 42 lines · Peter Zijlstra
Quoted 41 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...(many more similar messages skipped).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
Quoted 8 lines
Quoted 1 line
ls
/usr/lib/*/libopcodes*"No such file or directory"
However,
Quoted 1 line
ls
/usr/lib64/libopcodes*
/usr/lib64/libopcodes-2.45.0.20251103-150100757.so/usr/lib64/libopcodes.aThe linker looks for libopcodes.so (not the versioned .so). Without that symlink, it falls back to libopcodes.a. So yes, looks like you're using static linking.
Quoted 5 lines
To confirm, can you try to:
sudo ln -s libopcodes-2.45.0.20251103-150100757.so /usr/lib64/libopcodes.soAny then running the build again?
Yes, this makes the build work (without reverting the commit in question).
Quoted 75 lines · Rafael J. Wysocki
Quoted 74 lines · Sasha Levin
Quoted 59 lines · Rafael J. Wysocki
Quoted 58 lines · Sasha Levin
Quoted 45 lines · Rafael J. Wysocki
Quoted 44 lines · Sasha Levin
Quoted 42 lines · Peter Zijlstra
Quoted 41 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...(many more similar messages skipped).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
Quoted 8 lines
Quoted 1 line
ls
/usr/lib/*/libopcodes*"No such file or directory"
However,
Quoted 1 line
ls
/usr/lib64/libopcodes*
/usr/lib64/libopcodes-2.45.0.20251103-150100757.so/usr/lib64/libopcodes.aThe linker looks for libopcodes.so (not the versioned .so). Without that symlink, it falls back to libopcodes.a. So yes, looks like you're using static linking.
Quoted 7 lines
Quoted 5 lines
To confirm, can you try to:
sudo ln -s libopcodes-2.45.0.20251103-150100757.so /usr/lib64/libopcodes.soAny then running the build again?
Yes, this makes the build work (without reverting the commit in question).
Great! So something like the patch below should fix the static scenario. I've tested it locally on Debian but it'll be great to give it a go on a different distro.
It's also a bit ugly, but I'm not really sure what we can do about it. No dependency info in static libs :/
tools/objtool/Makefile +17 -4
@@ -77,8 +77,21 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \ + echo 'extern void disassemble_init_for_target(void *);' \ + 'int main(void) { disassemble_init_for_target(0); return 0; }' | \ + $(HOSTCC) -xc - -o /dev/null $$libs 2>/dev/null && \ + echo "$$libs" && break; \ + done) # Styled disassembler support requires binutils >= 2.39 HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \
@@ -86,10 +99,10 @@ HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ BUILD_DISAS := n -ifeq ($(HAVE_LIBOPCODES),y) +ifneq ($(LIBOPCODES_LIBS),) BUILD_DISAS := y OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' - OBJTOOL_LDFLAGS += -lopcodes + OBJTOOL_LDFLAGS += $(LIBOPCODES_LIBS) ifeq ($(HAVE_DISASM_STYLED),y) OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED endif
Signature · 2 lines
Thanks, Sasha
Josh Poimboeuf
maintainerQuoted 102 lines · Sasha Levin
Quoted 75 lines · Rafael J. Wysocki
Quoted 74 lines · Sasha Levin
Quoted 59 lines · Rafael J. Wysocki
Quoted 58 lines · Sasha Levin
Quoted 45 lines · Rafael J. Wysocki
Quoted 44 lines · Sasha Levin
Quoted 42 lines · Peter Zijlstra
Quoted 41 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...(many more similar messages skipped).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
Quoted 8 lines
Quoted 1 line
ls
/usr/lib/*/libopcodes*"No such file or directory"
However,
Quoted 1 line
ls
/usr/lib64/libopcodes*
/usr/lib64/libopcodes-2.45.0.20251103-150100757.so/usr/lib64/libopcodes.aThe linker looks for libopcodes.so (not the versioned .so). Without that symlink, it falls back to libopcodes.a. So yes, looks like you're using static linking.
Quoted 7 lines
Quoted 5 lines
To confirm, can you try to:
sudo ln -s libopcodes-2.45.0.20251103-150100757.so /usr/lib64/libopcodes.soAny then running the build again?
Yes, this makes the build work (without reverting the commit in question).
Great! So something like the patch below should fix the static scenario. I've tested it locally on Debian but it'll be great to give it a go on a different distro.
It's also a bit ugly, but I'm not really sure what we can do about it. No dependency info in static libs :/
tools/objtool/Makefile +0
-2@@ -77,8 +77,21 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y)
tools/objtool/Makefile HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" · line 89
Quoted 10 lines
tools/objtool/Makefile +10
-0+# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \
Instead of hard-coding all the libraries, I think we can just use pkg-config to tell us the needed dependencies.
See for example what we're already doing elsewhere in that Makefile:
LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
Signature · 1 line
Josh
Quoted 117 lines · Josh Poimboeuf
Quoted 102 lines · Sasha Levin
Quoted 75 lines · Rafael J. Wysocki
Quoted 74 lines · Sasha Levin
Quoted 59 lines · Rafael J. Wysocki
Quoted 58 lines · Sasha Levin
Quoted 45 lines · Rafael J. Wysocki
Quoted 44 lines · Sasha Levin
Quoted 42 lines · Peter Zijlstra
Quoted 41 lines · Rafael J. Wysocki
Hi Sasha,
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") breaks kernel build for me.Here's what I get when I try to build the kernel after that commit:
LD /scratch/rafael/work/build/xps13/tools/objtool/objtool-in.o
LINK /scratch/rafael/work/build/xps13/tools/objtool/objtool/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_operands':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3945:(.text+0x6317):
undefined reference to `xmalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:3992:(.text+0x6723):
undefined reference to `_sch_istable'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `print_insn_aarch64':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:4559:(.text+0x6b1e):
undefined reference to `bfd_get_bits'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-dis.o):
in function `parse_aarch64_dis_option':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-dis.c:103:(.text+0x6dea):
undefined reference to `_bfd_error_handler'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(aarch64-opc.o):
in function `init_insn_sequence':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/aarch64-opc.c:5561:(.text+0x5c06):
undefined reference to `xcalloc'/usr/lib64/gcc/x86_64-suse-linux/15/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/15/../../../../lib64/libopcodes.a(disassemble.o):
in function `remove_whitespace_and_extra_commas':
/home/abuild/rpmbuild/BUILD/binutils-2.45/build-dir/opcodes/../../opcodes/disassemble.c:801:(.text+0x346):
undefined reference to `_sch_istable'
...(many more similar messages skipped).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Reverting commit
436326bc525dmakes the problem go away.Thanks for the report Rafael!
Could you confirm that you're linking against static libraries? I haven't tested that scenario.
How do I check that?
What do you get running the below?
Quoted 8 lines
Quoted 1 line
ls
/usr/lib/*/libopcodes*"No such file or directory"
However,
Quoted 1 line
ls
/usr/lib64/libopcodes*
/usr/lib64/libopcodes-2.45.0.20251103-150100757.so/usr/lib64/libopcodes.aThe linker looks for libopcodes.so (not the versioned .so). Without that symlink, it falls back to libopcodes.a. So yes, looks like you're using static linking.
Quoted 7 lines
Quoted 5 lines
To confirm, can you try to:
sudo ln -s libopcodes-2.45.0.20251103-150100757.so /usr/lib64/libopcodes.soAny then running the build again?
Yes, this makes the build work (without reverting the commit in question).
Great! So something like the patch below should fix the static scenario. I've tested it locally on Debian but it'll be great to give it a go on a different distro.
It's also a bit ugly, but I'm not really sure what we can do about it. No dependency info in static libs :/
tools/objtool/Makefile +0
-2@@ -77,8 +77,21 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y)tools/objtool/Makefile HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" · line 89
Quoted 10 lines
tools/objtool/Makefile +10
-0+# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \Instead of hard-coding all the libraries, I think we can just use pkg-config to tell us the needed dependencies.
Quoted 4 lines
See for example what we're already doing elsewhere in that
Makefile:
LIBELF_FLAGS:= $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)LIBELF_LIBS:= $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
It works for elfutils because they adopted pkg-config, but binutils doesn't work with pkg-config:
$ pkg-config libelf --libs -lelf
$ pkg-config libopcodes --libs Package libopcodes was not found in the pkg-config search path. Perhaps you should add the directory containing `libopcodes.pc' to the PKG_CONFIG_PATH environment variable Package 'libopcodes', required by 'virtual:world', not found
Signature · 2 lines
Thanks, Sasha
PATCH 1/1 objtool: fix libopcodes linking with static libraries
Commit 436326bc525d ("objtool: fix build failure due to missing libopcodes check") tests for libopcodes using an empty main(), which passes even when static libraries lack their dependencies. This causes undefined reference errors (xmalloc, bfd_get_bits, etc.) when linking against static libopcodes without its required libbfd and libiberty.
Fix by testing with an actual libopcodes symbol and trying increasingly complete library combinations until one succeeds.
---
Rafael, I'd appreciate if you could test this patch without the .so symlink workaround. Thanks :)
tools/objtool/Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tools/objtool/Makefile +17 -4
@@ -77,8 +77,21 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \ + echo 'extern void disassemble_init_for_target(void *);' \ + 'int main(void) { disassemble_init_for_target(0); return 0; }' | \ + $(HOSTCC) -xc - -o /dev/null $$libs 2>/dev/null && \ + echo "$$libs" && break; \ + done) # Styled disassembler support requires binutils >= 2.39 HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \
@@ -86,10 +99,10 @@ HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ BUILD_DISAS := n -ifeq ($(HAVE_LIBOPCODES),y) +ifneq ($(LIBOPCODES_LIBS),) BUILD_DISAS := y OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' - OBJTOOL_LDFLAGS += -lopcodes + OBJTOOL_LDFLAGS += $(LIBOPCODES_LIBS) ifeq ($(HAVE_DISASM_STYLED),y) OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED endif
Signature · 1 line
2.51.0
Re: [PATCH] objtool: fix libopcodes linking with static libraries
Quoted 10 lines · Sasha Levin
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") tests for libopcodes using an emptymain(), which passes even when static libraries lack their dependencies. This causes undefined reference errors (xmalloc,bfd_get_bits, etc.) when linking against static libopcodes without its required libbfd and libiberty.Fix by testing with an actual libopcodes symbol and trying increasingly complete library combinations until one succeeds.
Quoted 7 lines
Fixes 436326bc525d ("objtool: fix build failure due to missing libopcodes check")Reported-by Rafael J. Wysocki <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Rafael, I'd appreciate if you could test this patch without the .so symlink workaround. Thanks :)
Works here, so
Quoted 47 lines
tools/objtool/Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)tools/objtool/Makefile +17
-5@@ -77,8 +77,21 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \ + echo 'extern void disassemble_init_for_target(void *);' \ + 'int main(void) { disassemble_init_for_target(0); return 0; }' | \ + $(HOSTCC) -xc - -o /dev/null $$libs 2>/dev/null && \ + echo "$$libs" && break; \ + done) # Styled disassembler support requires binutils >= 2.39 HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \@@ -86,10 +99,10 @@ HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ BUILD_DISAS := n -ifeq ($(HAVE_LIBOPCODES),y) +ifneq ($(LIBOPCODES_LIBS),) BUILD_DISAS := y OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' - OBJTOOL_LDFLAGS += -lopcodes + OBJTOOL_LDFLAGS += $(LIBOPCODES_LIBS) ifeq ($(HAVE_DISASM_STYLED),y) OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED endif --2.51.0
Peter Zijlstra
maintainerRe: [PATCH] objtool: fix libopcodes linking with static libraries
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Sasha Levin
Commit
436326bc525d("objtool: fix build failure due to missing libopcodes check") tests for libopcodes using an emptymain(), which passes even when static libraries lack their dependencies. This causes undefined reference errors (xmalloc,bfd_get_bits, etc.) when linking against static libopcodes without its required libbfd and libiberty.Fix by testing with an actual libopcodes symbol and trying increasingly complete library combinations until one succeeds.
Fixes 436326bc525d ("objtool: fix build failure due to missing libopcodes check")Reported-by Rafael J. Wysocki <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Quoted 6 lines
Quoted 2 lines
Rafael, I'd appreciate if you could test this patch without the .so symlink workaround. Thanks :)
Works here, so
Excellent, thanks all!
[tip: objtool/urgent] objtool: Fix libopcodes linking with static libraries
In reply to Sasha LevinThe following commit has been merged into the objtool/urgent branch of tip:
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: 3f2de814c0597c97d5abe09a1635d8c4e2fddaf2 Gitweb: https://git.kernel.org/tip/3f2de814c0597c97d5abe09a1635d8c4e2fddaf2 Author: Sasha Levin <[email protected]> AuthorDate: Wed, 21 Jan 2026 11:25:32 -05:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 21 Jan 2026 20:25:14 +01:00
objtool: Fix libopcodes linking with static libraries
Commit 436326bc525d ("objtool: fix build failure due to missing libopcodes check") tests for libopcodes using an empty main(), which passes even when static libraries lack their dependencies. This causes undefined reference errors (xmalloc, bfd_get_bits, etc.) when linking against static libopcodes without its required libbfd and libiberty.
Fix by testing with an actual libopcodes symbol and trying increasingly complete library combinations until one succeeds.
--- tools/objtool/Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tools/objtool/Makefile +17 -4
@@ -77,8 +77,21 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \ + echo 'extern void disassemble_init_for_target(void *);' \ + 'int main(void) { disassemble_init_for_target(0); return 0; }' | \ + $(HOSTCC) -xc - -o /dev/null $$libs 2>/dev/null && \ + echo "$$libs" && break; \ + done) # Styled disassembler support requires binutils >= 2.39 HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \
@@ -86,10 +99,10 @@ HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ BUILD_DISAS := n -ifeq ($(HAVE_LIBOPCODES),y) +ifneq ($(LIBOPCODES_LIBS),) BUILD_DISAS := y OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' - OBJTOOL_LDFLAGS += -lopcodes + OBJTOOL_LDFLAGS += $(LIBOPCODES_LIBS) ifeq ($(HAVE_DISASM_STYLED),y) OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED endif