public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel' (was: [MentorEmbedded/nvptx-tools] Match standard 'ld' "search" behavior (PR #38))
       [not found] ` <MentorEmbedded/nvptx-tools/pull/38/c1320419585@github.com>
@ 2022-11-18 23:25   ` Thomas Schwinge
  2022-11-19  6:35     ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Schwinge @ 2022-11-18 23:25 UTC (permalink / raw)
  To: gcc-patches, Tom de Vries
  Cc: reply+AAAFJ6N2QCLFB22I4MIOMNGBQUE7HEVBNHHFNHPAMA

[-- Attachment #1: Type: text/plain, Size: 1015 bytes --]

Hi!

Re
<https://github.com/MentorEmbedded/nvptx-tools/pull/38#issuecomment-1320419585>:

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-In-STARTFILE_SPEC-fix-crt0.o-for-mmainkernel.patch --]
[-- Type: text/x-diff, Size: 1895 bytes --]

From 85ddd99017968e8aa45342645be9642e63bcc5bb Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
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
<https://github.com/MentorEmbedded/nvptx-tools/pull/38>
"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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel' (was: [MentorEmbedded/nvptx-tools] Match standard 'ld' "search" behavior (PR #38))
  2022-11-18 23:25   ` nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel' (was: [MentorEmbedded/nvptx-tools] Match standard 'ld' "search" behavior (PR #38)) Thomas Schwinge
@ 2022-11-19  6:35     ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2022-11-19  6:35 UTC (permalink / raw)
  To: Thomas Schwinge, gcc-patches
  Cc: reply+AAAFJ6N2QCLFB22I4MIOMNGBQUE7HEVBNHHFNHPAMA

On 11/19/22 00:25, Thomas Schwinge wrote:
> Hi!
> 
> Re
> <https://github.com/MentorEmbedded/nvptx-tools/pull/38#issuecomment-1320419585>:
> 
> 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...)
> 

Hi,

yes, LGTM.

Thanks,
- Tom

> 
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-19  6:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <MentorEmbedded/nvptx-tools/pull/38@github.com>
     [not found] ` <MentorEmbedded/nvptx-tools/pull/38/c1320419585@github.com>
2022-11-18 23:25   ` nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel' (was: [MentorEmbedded/nvptx-tools] Match standard 'ld' "search" behavior (PR #38)) Thomas Schwinge
2022-11-19  6:35     ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).