public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] lto-wrapper.cc: Add offload target name to 'offload_args' suffix
@ 2024-04-03 11:53 Tobias Burnus
  2024-04-03 13:00 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2024-04-03 11:53 UTC (permalink / raw)
  To: gcc-patches, Richard Biener

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

Found when working with -save-temps and looking at 'mkoffload'
with a GCC configured for both nvptx and gcn offloading.

Before (for 'a.out') for mkoffload:a.offload_args now: a.amdgcn-amdhsa.offload_args 
and a.nvptx-none.offload_args
OK for mainline?

Tobias

PS: The code does not free the 'xmalloc'ed memory, but that's also
the case of all/most 'concat' in this file; the concat could also
be skipped when no save_temps is used, in case this optimization
makes sense.

[-- Attachment #2: lto-wrapper-offload-arg.diff --]
[-- Type: text/x-patch, Size: 1076 bytes --]

lto-wrapper.cc: Add offload target name to 'offload_args' suffix

lto-wrapper.cc's compile_offload_image calls mkoffload with
an @./a.offload_args argument ('a.' in case of, e.g., 'a.out'). However,
when generating code for both nvptx and gcn, they use the same name
with -save-temps. Hence, this commit adds a <target> + '.' before
'offload_args' in line with other offload-target-specific files.

gcc/ChangeLog:

	* lto-wrapper.cc (compile_offload_image): Prefix 'offload_args'
	suffix by the target name.

diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index ca53e4b462e..610594cdc2b 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -993,7 +993,8 @@ compile_offload_image (const char *target, const char *compiler_path,
 
   obstack_ptr_grow (&argv_obstack, NULL);
   argv = XOBFINISH (&argv_obstack, char **);
-  fork_execute (argv[0], argv, true, "offload_args");
+  suffix = concat (target, ".offload_args", NULL);
+  fork_execute (argv[0], argv, true, suffix);
   obstack_free (&argv_obstack, NULL);
 
   free_array_of_ptrs ((void **) paths, n_paths);

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

* Re: [Patch] lto-wrapper.cc: Add offload target name to 'offload_args' suffix
  2024-04-03 11:53 [Patch] lto-wrapper.cc: Add offload target name to 'offload_args' suffix Tobias Burnus
@ 2024-04-03 13:00 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-04-03 13:00 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches

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

On Wed, 3 Apr 2024, Tobias Burnus wrote:

> Found when working with -save-temps and looking at 'mkoffload'
> with a GCC configured for both nvptx and gcn offloading.
> 
> Before (for 'a.out') for mkoffload:a.offload_args now:
> a.amdgcn-amdhsa.offload_args and a.nvptx-none.offload_args
> OK for mainline?

OK.

Richard.

> Tobias
> 
> PS: The code does not free the 'xmalloc'ed memory, but that's also
> the case of all/most 'concat' in this file; the concat could also
> be skipped when no save_temps is used, in case this optimization
> makes sense.
> 

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

end of thread, other threads:[~2024-04-03 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03 11:53 [Patch] lto-wrapper.cc: Add offload target name to 'offload_args' suffix Tobias Burnus
2024-04-03 13:00 ` Richard Biener

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