Skip to content

Commit

Permalink
nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel'
Browse files Browse the repository at this point in the history
A recent nvptx-tools change: commit 886a95faf66bf66a82fc0fe7d2a9fd9e9fec2820
"ld: Don't search for input files in '-L'directories" (of
<SourceryTools/nvptx-tools#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'.

(cherry picked from commit dda43e1)
  • Loading branch information
tschwinge committed Nov 19, 2022
1 parent 1bfdef4 commit 3180cd7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/config/nvptx/nvptx.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/* Run-time Target. */

#define STARTFILE_SPEC "%{mmainkernel:crt0.o}"
#define STARTFILE_SPEC "%{mmainkernel:crt0.o%s}"

#define ASM_SPEC "%{misa=*:-m %*}"

Expand Down

0 comments on commit 3180cd7

Please sign in to comment.