From patchwork Wed Feb 2 14:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1587625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=bCtpq4To; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ucue2P0t; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jpkkg0gzQz9sFh for ; Thu, 3 Feb 2022 01:31:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CDDF8385DC27 for ; Wed, 2 Feb 2022 14:31:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 0EDAE3858C2C for ; Wed, 2 Feb 2022 14:30:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0EDAE3858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D932021122; Wed, 2 Feb 2022 14:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1643812254; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gKgCtlRWrqhurRseHUernUykxOgLmXGrJKeGnu9FNwo=; b=bCtpq4TozjLV5QLH8Jr1Odl+TDMPQBxYNJRHo0RsB1pvvsusqgvbcUekMgL7wX5RpuKAwM rxUaOVhtfLJV3H68lKrS2AtMMWCHR7842y0sxnvveD7TlUu+gcpNwSau2erl1NqGCGg4Us hRWaLNYK70++eWO/8hMAKh+6HdpwziU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1643812254; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gKgCtlRWrqhurRseHUernUykxOgLmXGrJKeGnu9FNwo=; b=Ucue2P0t8CTQKkH4sVnl33D34J5emg6NhYD30O6k6NHriqCZAd7Eq8m5g7m8X1aV68aOiY jTNmC/5PU4vvpcDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BF77013E64; Wed, 2 Feb 2022 14:30:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id l26WLJ6V+mHkbQAAMHmgww (envelope-from ); Wed, 02 Feb 2022 14:30:54 +0000 Message-ID: <7e837179-e25b-76d4-ad21-3ee6b2326bea@suse.cz> Date: Wed, 2 Feb 2022 15:30:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] lto: fix error handling for -Wl,-plugin-opt=debug To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When one uses something like: -Wl,-plugin-opt=debug, we end up with lto1 WPA invocation that has 'debug' on command line. We interpret that as input filename. The patch moves resolution checking later so that we end up with a reasonable error message: lto1: error: open debug failed: No such file or directory lto1: fatal error: errors during merging of translation units Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR lto/104333 gcc/lto/ChangeLog: * lto-common.cc (read_cgraph_and_symbols): Move resolution checking for number of files later and report a reasonable error message. --- gcc/lto/lto-common.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc index 4d6686b0b99..fbcd4742ee4 100644 --- a/gcc/lto/lto-common.cc +++ b/gcc/lto/lto-common.cc @@ -2704,6 +2704,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) { unsigned int i, last_file_ix; FILE *resolution; + unsigned resolution_objects = 0; int count = 0; struct lto_file_decl_data **decl_data; symtab_node *snode; @@ -2726,18 +2727,14 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) if (resolution_file_name) { int t; - unsigned num_objects; resolution = fopen (resolution_file_name, "r"); if (resolution == NULL) fatal_error (input_location, "could not open symbol resolution file: %m"); - t = fscanf (resolution, "%u", &num_objects); + t = fscanf (resolution, "%u", &resolution_objects); gcc_assert (t == 1); - - /* True, since the plugin splits the archives. */ - gcc_assert (num_objects == nfiles); } symtab->state = LTO_STREAMING; @@ -2806,7 +2803,12 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) lto_register_canonical_types_for_odr_types (); if (resolution_file_name) - fclose (resolution); + { + /* True, since the plugin splits the archives. */ + if (!seen_error ()) + gcc_assert (resolution_objects == nfiles); + fclose (resolution); + } /* Show the LTO report before launching LTRANS. */ if (flag_lto_report || (flag_wpa && flag_lto_report_wpa))