From patchwork Sun Jul 28 14:24:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1965723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EUsE8+G6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WX3hx6ZX9z20Fr for ; Mon, 29 Jul 2024 00:26:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2FEB83858D28 for ; Sun, 28 Jul 2024 14:26:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 602493858D28 for ; Sun, 28 Jul 2024 14:26:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 602493858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 602493858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722176798; cv=none; b=Q+IieM3soEgPpUsteRQqzPjEVNo0TLJskbDcwROjr2WWrx6NbCTHhJO+peqJbcSwxBeBuXFaMTeD/hsllx05PyjcJzysLJ8DQ3tAwhIoTUVkOD/w26F7zdARl3nZj+lLPSzkF26bOOXEYZYXhSJ9KJQU+7OjH9ooetD3bdbEFmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722176798; c=relaxed/simple; bh=kiueuD2M8LlwFmDXueEmRWeaIBpGe/jpuxzzpPLKMJY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dnfeUccx1LDToSVeFnGg8O64/H2H/LqZu2Wtue9szDZqfsq1nmO2SBqtzH4gNz3lOTl0oYIbRrrd5xGIXeTqZLhR3UXRZc6vTU3YZHMrbkjQz3nGXxdT1RCFMsIwvDMHDKhiVJkMPDESzT8L1JAd97yNf9Lc4SgIuum+Zl53tmg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722176797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ermnByU9vx/b6PnaiaqN6cq4BcD3sefvzeGb5Zc0Scw=; b=EUsE8+G6vLj9g6QBVE/L/poL9t36RuKi0bB8KPcWhX34LyHOQ7XMJkLn6YB+t6Y0gtbRcD tUcR4hsFPOifsR+vTUdJumMZabSr/lknbjYwmDNAfcs2Dxey5NIuVf6EZtotVCOwCKHd8c Q2DMnTdzqifEIq5r/Z6cM1N2sauMtaM= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-q482YYVxPm2xU2QFlKIz6Q-1; Sun, 28 Jul 2024 10:26:35 -0400 X-MC-Unique: q482YYVxPm2xU2QFlKIz6Q-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B30019560AA for ; Sun, 28 Jul 2024 14:26:34 +0000 (UTC) Received: from localhost (unknown [10.42.28.14]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5DBE41955F40 for ; Sun, 28 Jul 2024 14:26:32 +0000 (UTC) From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Subject: [PATCH] gcc: Make exec-tool.in handle missing Binutils more gracefully Date: Sun, 28 Jul 2024 15:24:07 +0100 Message-ID: <20240728142631.581139-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped on x86_64-linux and for msp430-elf cross with and without binutils for the target to verify the error is printed as expected. The $invoked variable will be one of as, collect-ld, nm, or dsymutil, i.e. the tool that the script is invoking and wants to exec. OK for trunk? -- >8 -- When users try to build a cross-compiler without first installing binutils they get confusing errors like: /tmp/gcc-obj/./gcc/as: line 114: exec: -m: invalid option This is an incredibly common source of questions on gcc-help and IRC, and bogus bug reports e.g. see PR 116119 for the latest example. This change adds an explicit check for an empty $original variable and exits with a user-friendly error. gcc/ChangeLog: * exec-tool.in: Exit with an error if $original is empty. --- gcc/exec-tool.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/exec-tool.in b/gcc/exec-tool.in index 7d152e083a7..2767e1019b8 100644 --- a/gcc/exec-tool.in +++ b/gcc/exec-tool.in @@ -81,6 +81,14 @@ case "$invoked" in ;; esac +if test -z "$original" +then + echo "$0: \$original is unset" >&2 + echo "This probably means there is no '$invoked' for the target." >&2 + echo "For a cross-compiler, you probably need to install Binutils first." >&2 + exit 1 +fi + case "$original" in ../*) # compute absolute path of the location of this script