From patchwork Fri Nov 18 23:25:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 22664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp461004wrr; Fri, 18 Nov 2022 15:25:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7PEuoN5ACAzolDNmKQ++zITcuBVlO0bk5+X/1Vk2zcKZ6QH3excQYmGlBrGcL5J3mCYVBH X-Received: by 2002:a17:906:8a6d:b0:7ad:d18f:c2d6 with SMTP id hy13-20020a1709068a6d00b007add18fc2d6mr7903472ejc.271.1668813959115; Fri, 18 Nov 2022 15:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668813959; cv=none; d=google.com; s=arc-20160816; b=WQYTfXX/UcGu4e5iC+2S48YZM7jQjGEr2CJJWhre0aE96U0/tH7gJGTepkn63Ui8EE vSoS7msxwYw9wrNHRrEEMesCZkkSpVujVsdEFVABV2ueYmgJQLFfdt4IH/82uPdO9a0b wq8f9524NXJGX63U4I/gyoWRssYh5omu9RGxAKwo7jHsghuRu0U+oZGaaxDuielNxCx7 JaRk5o0hWbjRT1u1p73BcmyMWZekLeRwajcVBPtcYk+eKsz9xMN55Vp+b3bsJOKWlszv NxYbPwITfwmxC0ZCknlCxKJZSAKIWmDMjyaoQ4DEo5W0Pa6O3A/tl/QzA/wNd7ljAhzv wT3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:references:in-reply-to:subject:cc:to:from:ironport-sdr :dmarc-filter:delivered-to; bh=xtoac/rQkVcWcLReCJQmDLmXlcwNbTqj9WczeZHT2cQ=; b=gIaUWJaMkmWUB81xbVPnr0KIzgaRhjI4LVLh9fMGDLsKjezjkq4b6dHBdkad4ticCf rlSqDV46rnqGL0gVExGdDj8pi5isX1KNXIyzvrv2Er7z07tPjycAupgdPP3o58bHI+/r vEL2DvRj5HSooBQPfoXM2b2nhzn+CUu6BMKxP2vUi0z69OmJ1JeQA7XxI2Xi7U9wy7zb TJZmH7aQOV6qp/z/kaffJLj7pyFrGjavz9OQNEwKiYuWIFG3Bg/QVN5hFbh4Z1Vhi9Cq eglC7FfPNT/ygwFl6M72jZF/IuTpp9wftCQQS+bN5OpgfYgwmatQVgq14/QHhqu+Cohh b16w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t18-20020a1709063e5200b0076f0940cb28si3398375eji.175.2022.11.18.15.25.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 15:25:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC385384F6CA for ; Fri, 18 Nov 2022 23:25:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E1D3F3853D7B for ; Fri, 18 Nov 2022 23:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E1D3F3853D7B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,175,1665475200"; d="scan'208,223";a="87575525" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 18 Nov 2022 15:25:27 -0800 IronPort-SDR: nVieXEEbFLdlOG/icnfBcsX0byVpzPuCUFM1Zug7ysC/u1vQayfAmeN/SgimuLspAj2RpBbXbA TOtEyAgXK5dellbsqsRBN+TkC+pGiM5ztc0KERZaR9SBIXXtIiELtNS7Yu0lguI+6ozNOpNE5A Qlb/EubSQbcOWuzGvC2a6LWXbzLPkU3DWygAMNCN+a+2W6OKrhfTjqsRLAM6yUI2pMldSpet0k 57fEFmMyk8nAR4r20a9HVGjcy727YafgfxAO24JbjYZxsz/KOCiyudyIfnXpsqsyyJ8IDGDoSN OBA= From: Thomas Schwinge To: , Tom de Vries CC: Subject: nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel' (was: [MentorEmbedded/nvptx-tools] Match standard 'ld' "search" behavior (PR #38)) In-Reply-To: References: User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Sat, 19 Nov 2022 00:25:16 +0100 Message-ID: <87iljbalr7.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749878265983254366?= X-GMAIL-MSGID: =?utf-8?q?1749878265983254366?= Hi! Re : On 2022-11-18T11:05:23-0800, I wrote: > Actually, in GCC/nvptx target testing, this #38's commit 886a95faf66bf66a82fc0fe7d2a9fd9e9fec2820 "ld: Don't search for input files in '-L'directories" is generally causing linking to fail with: > > ``` > error opening crt0.o > collect2: error: ld returned 1 exit status > compiler exited with status 1 > ``` > > I'm investigating. OK to push the attached GCC "nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel'" to all active GCC branches? (... instead of having to restore this "blunder" (do "search for input files in '-L'directories") in nvptx-tools...) Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 85ddd99017968e8aa45342645be9642e63bcc5bb Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 18 Nov 2022 23:57:52 +0100 Subject: [PATCH] nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel' A recent nvptx-tools change: commit 886a95faf66bf66a82fc0fe7d2a9fd9e9fec2820 "ld: Don't search for input files in '-L'directories" (of "Match standard 'ld' "search" behavior") in GCC/nvptx target testing generally causes linking to fail with: error opening crt0.o collect2: error: ld returned 1 exit status compiler exited with status 1 Indeed per GCC '-v' output, there is an undecorated 'crt0.o' on the linker ('collect2') command line: [...]/build-gcc/./gcc/collect2 -o [...] crt0.o [...] This is due to: gcc/config/nvptx/nvptx.h:#define STARTFILE_SPEC "%{mmainkernel:crt0.o}" ..., and the fix, as used by numerous other GCC targets, is to instead use 'crt0.o%s'; for '%s' means, per 'gcc/gcc.cc', "The Specs Language": %s current argument is the name of a library or startup file of some sort. Search for that file in a standard list of directories and substitute the full name found. With that, we get the expected path to 'crt0.o'. gcc/ * config/nvptx/nvptx.h (STARTFILE_SPEC): Fix 'crt0.o' for '-mmainkernel'. --- gcc/config/nvptx/nvptx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index 0afc83b10a3..dc676dcb5fc 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -35,7 +35,7 @@ '../../gcc.cc:asm_options', 'HAVE_GNU_AS'. */ #define ASM_SPEC "%{v}" -#define STARTFILE_SPEC "%{mmainkernel:crt0.o}" +#define STARTFILE_SPEC "%{mmainkernel:crt0.o%s}" #define TARGET_CPU_CPP_BUILTINS() nvptx_cpu_cpp_builtins () -- 2.25.1