From nobody Sun Feb 8 04:11:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6398F4A21 for ; Tue, 23 Dec 2025 12:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766491442; cv=none; b=K0gblk+Cy0fEyR+FUKamgqdm1FdqJ6fKfep3hhDpN8ULcAJcsUIpumhweAeZ7HBNxH5nkO34w7q1TpRaujtdZc1cCL969hH0nwhl//DUhXyhrMpJEkHwgZ+Zayzo8aBjGy325D7sctEFmvhwkwD7zHSUQHnq9At/qNKlmd9u5lc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766491442; c=relaxed/simple; bh=I+XQz5ZA9scEVkvg4fujtseP2yOgUEuDnqarllifMug=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Um/FX24gWOTjBPXXKhiwgTKHHybEG143dC2g8FllvPmeg/94dGwmTKRdoAhx/DoiOaSgUy/NHkIACInk+Cmay7Gb5Js8xobjkEg9m5Z57AaB2UHHigpMqh+NQbdPj0FTPQGc6Lb3IakFO1ZesbSY2UPXib6Z+R4Y0qEePNlHo0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ixdLogje; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ixdLogje" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6456EC113D0; Tue, 23 Dec 2025 12:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766491440; bh=I+XQz5ZA9scEVkvg4fujtseP2yOgUEuDnqarllifMug=; h=From:To:Cc:Subject:Date:From; b=ixdLogjeFJnAKfb0XbN3Czi+E5VB+DQSYDNN1fXia3wyr8NmQz4LvHUM+Z5NMcBum Jmc/UcssqZNYi9SPxsbyQlESIwC3Goq3cjggL9LRe2BjHR5Z3p8GwKf+EnEDrUrMqa XEmrCpV4/2UOnSHjt4huHc74HW7Gnb9UBTPWpBRBPvBxDuyEzdNlUzol0IYVycmNKb gNV2op2HH94LRqzMskLuiWkgAwHHSG8PtQs+/USKZeo/a+lLvt3k4T9Yiw5/RCdFx9 0laQRXr5pDdxblhrYz/YCQ0xDA2xcLPTb2rrMnQgmQs33jX8Z8+YbFEhvsMfVWBdMZ FxCkwoePA8nvQ== From: Sasha Levin To: jpoimboe@kernel.org, peterz@infradead.org Cc: alexandre.chartre@oracle.com, linux-kernel@vger.kernel.org, Sasha Levin Subject: [PATCH] objtool: fix build failure due to missing libopcodes check Date: Tue, 23 Dec 2025 07:03:57 -0500 Message-ID: <20251223120357.2492008-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 59953303827e ("objtool: Disassemble code with libopcodes instead of running objdump") added support for using libopcodes for disassembly. However, the feature detection checks for libbfd availability but then unconditionally links against libopcodes: ifeq ($(feature-libbfd),1) OBJTOOL_LDFLAGS +=3D -lopcodes endif This causes build failures in environments where libbfd is installed but libopcodes is not, since the test-libbfd.c feature test only links against -lbfd and -ldl, not -lopcodes: /usr/bin/ld: cannot find -lopcodes: No such file or directory collect2: error: ld returned 1 exit status make[4]: *** [Makefile:109: objtool] Error 1 Additionally, the shared feature framework uses $(CC) which is the cross-compiler in cross-compilation builds. Since objtool is a host tool that links with $(HOSTCC) against host libraries, the feature detection can falsely report libopcodes as available when the cross-compiler's sysroot has it but the host system doesn't. Fix this by replacing the feature framework check with a direct inline test that uses $(HOSTCC) to compile and link a test program against libopcodes, similar to how xxhash availability is detected. Fixes: 59953303827e ("objtool: Disassemble code with libopcodes instead of = running objdump") Assisted-by: claude-opus-4-5-20251101 Signed-off-by: Sasha Levin --- tools/objtool/Makefile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index ad6e1ec706ce..9b4503113ce5 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -72,23 +72,27 @@ HOST_OVERRIDES :=3D CC=3D"$(HOSTCC)" LD=3D"$(HOSTLD)" A= R=3D"$(HOSTAR)" =20 # # To support disassembly, objtool needs libopcodes which is provided -# with libbdf (binutils-dev or binutils-devel package). +# with libbfd (binutils-dev or binutils-devel package). # -FEATURE_USER =3D .objtool -FEATURE_TESTS =3D libbfd disassembler-init-styled -FEATURE_DISPLAY =3D -include $(srctree)/tools/build/Makefile.feature +# We check using HOSTCC directly rather than the shared feature framework +# because objtool is a host tool that links against host libraries. +# +HAVE_LIBOPCODES :=3D $(shell echo 'int main(void) { return 0; }' | \ + $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) =20 -ifeq ($(feature-disassembler-init-styled), 1) - OBJTOOL_CFLAGS +=3D -DDISASM_INIT_STYLED -endif +# Styled disassembler support requires binutils >=3D 2.39 +HAVE_DISASM_STYLED :=3D $(shell echo '$(pound)include ' | \ + $(HOSTCC) -E -xc - 2>/dev/null | grep -q disassembler_style && echo y) =20 BUILD_DISAS :=3D n =20 -ifeq ($(feature-libbfd),1) +ifeq ($(HAVE_LIBOPCODES),y) BUILD_DISAS :=3D y - OBJTOOL_CFLAGS +=3D -DDISAS -DPACKAGE=3D"objtool" + OBJTOOL_CFLAGS +=3D -DDISAS -DPACKAGE=3D'"objtool"' OBJTOOL_LDFLAGS +=3D -lopcodes +ifeq ($(HAVE_DISASM_STYLED),y) + OBJTOOL_CFLAGS +=3D -DDISASM_INIT_STYLED +endif endif =20 export BUILD_DISAS --=20 2.51.0