From patchwork Mon Jan 12 22:54:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1491 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768258484; bh=Hs0xOZb2GottTBOhFVPfOdlN7r4B6OCE3LQnkLB9QoY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bmz294T4Mvf034bU1DFgOBSHX5WGaFK57X9Ti2RaQDBDDCY/z8wn3c2oCuOnp5qf1 kX/K+0yzJuntY7hHTsTsexr1yvbh1I2Zs55bwsSyTLRwAMyL+S+WLGL7+ngUGe1ugL /bRzEfGo1/ZJlAtOYCmsxWVXc65rzVq7S9vF0PiLgwHhWTJC5nlcFEynR4eDmFNYw2 0BwhrYgwmbNSZ/h6vodnVJi6P+ZINjBY8OE1YjnR1JBA1EWY9uX+AgQqLyY+4EPF9t 0VPFbaM6rTARI7eG5CLupWklGhtJn5CGoutMJ9x9spmvUxYw3YTC6dk4dB4MsPphJm 6ZwdpRTUXSXOg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DF1AF692F6 for ; Mon, 12 Jan 2026 15:54:44 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GYxeIBiLXqy5 for ; Mon, 12 Jan 2026 15:54:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768258484; bh=Hs0xOZb2GottTBOhFVPfOdlN7r4B6OCE3LQnkLB9QoY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bmz294T4Mvf034bU1DFgOBSHX5WGaFK57X9Ti2RaQDBDDCY/z8wn3c2oCuOnp5qf1 kX/K+0yzJuntY7hHTsTsexr1yvbh1I2Zs55bwsSyTLRwAMyL+S+WLGL7+ngUGe1ugL /bRzEfGo1/ZJlAtOYCmsxWVXc65rzVq7S9vF0PiLgwHhWTJC5nlcFEynR4eDmFNYw2 0BwhrYgwmbNSZ/h6vodnVJi6P+ZINjBY8OE1YjnR1JBA1EWY9uX+AgQqLyY+4EPF9t 0VPFbaM6rTARI7eG5CLupWklGhtJn5CGoutMJ9x9spmvUxYw3YTC6dk4dB4MsPphJm 6ZwdpRTUXSXOg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CB09469237 for ; Mon, 12 Jan 2026 15:54:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768258482; bh=s66eiR1aGNbav54h937OQdWmcl/x972m/+glP+MEtoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/45x4qucu0qzIV5d4p2mjZf4mFWjT7MVfVP/8jtehXJlPVwM4k3kKEwvY8J0WwCu W9LtAeDFJ9lmy4KJU35T35xW7aLy4PXDwdPAV7+YFpfi/VOUZFKhfxGfJwB42OTrAu 8mkoT9r2lGD6RmdDFr8aCU99gM0TSv8SyW1GBCeKOgW1EiTdpJ8Jpefc3RIDRmEFkB BBtfW3jKwlLODjvzaYpfh7X45lLD02fPu5O/RKXgxWmRcVFKI8DtFYN1orLP2APoWu 3pDQO01TXLxBDfPOmyk5OsaEcX1XpIRgHstT3uWJ5otmJlUPxcVilZzSxvy04kpb8m 53ek6Ezcqjqhw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9AF7A6913F; Mon, 12 Jan 2026 15:54:42 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 46LPVMyGUdKu; Mon, 12 Jan 2026 15:54:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768258478; bh=RM18GXjvKWRonkZb1W8uV5YXhrc+TNnZO3tj/wQFbV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WhPyG/kcd82fBIanqq6V7t+tnEcOa6zQnGDVq2UXoalmUbm0WvA7Hhoxd5hxuJeWw 6vxhX0kTgmVlhp3j+6kl4ItfLcy++FQ1Cs/coK0uXSCyxIJ+zrUsvJ1XvecHfrf0fI y97duPxZX1D+3B99Xhh2CC1osdIa2B7Gp2oxyYO2iZIb53vQohaqE0AA0tpwfW25qB LSxCIBVmy2TPxkS9fNGrtQ1a7EvUQZgaOraU/PP6YGzZsiQgepCQz5294lx74vW9rh YDyU/Z80egiQHL2mmRYvJIfNIgtgDki49F1XwgEbwPnURyTVncdzVZDBLCBxKmpjXN nIXjPkvD9Jshg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2872269237; Mon, 12 Jan 2026 15:54:38 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 12 Jan 2026 15:54:03 -0700 Message-ID: <20260112225406.3274105-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260112225406.3274105-1-sjg@u-boot.org> References: <20260112225406.3274105-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZPX42QNPARKAMIXLH7QL3DUTF3SVQD6J X-Message-ID-Hash: ZPX42QNPARKAMIXLH7QL3DUTF3SVQD6J X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 5/5] buildman: Filter out doubled-prefix toolchain binaries List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Some toolchain tarballs from kernel.org contain symlinks with a doubled cross-compile prefix, e.g. 'x86_64-linux-x86_64-linux-gcc' alongside the correct 'x86_64-linux-gcc'. This causes buildman to print a warning about ambiguous toolchains when downloading. Add a regex-based check to detect and filter out these malformed binaries during toolchain scanning. When verbose output is enabled, these files are shown as "ignoring ... (doubled prefix)" rather than "found ..." Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/test.py | 24 ++++++++++++++++++++++++ tools/buildman/toolchain.py | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tools/buildman/test.py b/tools/buildman/test.py index da6df1f173c..0f4a5b9e543 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -744,6 +744,30 @@ class TestBuild(TestBuildBase): # Verify downloaded priority beats system priority self.assertLess(toolchain.PRIORITY_DOWNLOADED, sys_tc.priority) + def test_is_doubled_prefix(self): + """Test detection of doubled toolchain prefixes""" + # Valid toolchain names (not doubled) + self.assertFalse( + toolchain.Toolchains.is_doubled_prefix('aarch64-linux-gcc')) + self.assertFalse( + toolchain.Toolchains.is_doubled_prefix('x86_64-linux-gcc')) + self.assertFalse( + toolchain.Toolchains.is_doubled_prefix('arm-linux-gnueabi-gcc')) + self.assertFalse( + toolchain.Toolchains.is_doubled_prefix('gcc')) + + # Doubled prefixes (should be filtered out) + self.assertTrue( + toolchain.Toolchains.is_doubled_prefix( + 'aarch64-linux-aarch64-linux-gcc')) + self.assertTrue( + toolchain.Toolchains.is_doubled_prefix( + 'x86_64-linux-x86_64-linux-gcc')) + + # Not a gcc file + self.assertFalse( + toolchain.Toolchains.is_doubled_prefix('aarch64-linux-ld')) + def test_get_env_args(self): """Test the GetEnvArgs() function""" tc = self.toolchains.select('arm') diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index 8f3d3ab3b0c..27302f20d42 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -30,6 +30,10 @@ from u_boot_pylib import tools # Environment variable / argument types for get_env_args() (VAR_CROSS_COMPILE, VAR_PATH, VAR_ARCH, VAR_MAKE_ARGS) = range(4) +# Matches a repeated prefix, e.g. 'aarch64-linux-aarch64-linux-gcc' +RE_DOUBLED_PREFIX = re.compile(r'^(.+)\1gcc$') + + class MyHTMLParser(HTMLParser): """Simple class to collect links from a page @@ -378,6 +382,22 @@ class Toolchains: f"toolchain for arch '{toolchain.arch}' has priority " f"{self.toolchains[toolchain.arch].priority}") + @staticmethod + def is_doubled_prefix(fname): + """Check if a gcc filename has a doubled prefix + + Some toolchain tarballs contain symlinks with the cross-compile prefix + repeated, e.g. 'x86_64-linux-x86_64-linux-gcc'. These are not valid + toolchains and should be ignored. + + Args: + fname (str): Filename to check (basename, not full path) + + Returns: + bool: True if the prefix is doubled, False otherwise + """ + return bool(RE_DOUBLED_PREFIX.match(fname)) + def scan_path(self, path, verbose): """Scan a path for a valid toolchain @@ -394,6 +414,11 @@ class Toolchains: if verbose: print(f" - looking in '{dirname}'") for fname in glob.glob(dirname + '/*gcc'): + basename = os.path.basename(fname) + if self.is_doubled_prefix(basename): + if verbose: + print(f" - ignoring '{fname}' (doubled prefix)") + continue if verbose: print(f" - found '{fname}'") fnames.append(fname)