diff mbox

Forwarding -foffload=[...] from the driver (compile-time) to libgomp (run-time)

Message ID alpine.DEB.2.10.1508241754110.19249@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers Aug. 24, 2015, 5:54 p.m. UTC
On Fri, 21 Aug 2015, Joseph Myers wrote:

> On Fri, 21 Aug 2015, Nathan Sidwell wrote:
> 
> > this appears to cause an ICE in add_omp_infile_spec_func at;
> >   gcc_assert (offload_targets != NULL);
> > 
> > when you use something like -foffload='-save-temps -v -fdump-rtl-all
> > -fdump-tree-all -fno-verbose-asm'
> > 
> > Is that use ill-formed?
> 
> I'll need to reverse-engineer the question of what's a well-formed 
> -foffload= option (bug 67300 filed yesterday for the lack of any 
> documentation of that option).

Although there is no documentation for the -foffload options in the
manual, I found something at <https://gcc.gnu.org/wiki/Offloading>
that I hope is current.

It turns out the problem wasn't in the assertion, but in how a default
-foffload option was generated.  Generating it via specs meant that if
the only -foffload option specified options without specifying a
target (i.e., options applicable to all the configured offload
targets), then the offload_targets variable was never set and so the
assertion failure resulted (as well as OFFLOAD_TARGET_NAMES not being
exported).  Rather than trying to make the specs produce something if
no -foffload=* options other than -foffload=-* options were passed,
I'm testing this patch to default the offload targets after the
original command line is processed (and before extra options from
these specs are processed, so before the assertion is executed), and
will commit it if tests are OK.

2015-08-24  Joseph Myers  <joseph@codesourcery.com>

	* gcc.c (driver_self_specs) [ENABLE_OFFLOADING]: Don't generate a
	-foffload option.
	(process_command): Call handle_foffload_option (OFFLOAD_TARGETS)
	if no offload target specified.

Comments

Joseph Myers Aug. 24, 2015, 10:22 p.m. UTC | #1
On Mon, 24 Aug 2015, Joseph Myers wrote:

> I'm testing this patch to default the offload targets after the
> original command line is processed (and before extra options from
> these specs are processed, so before the assertion is executed), and
> will commit it if tests are OK.

Now committed to gomp-4_0-branch.
Nathan Sidwell Aug. 24, 2015, 10:50 p.m. UTC | #2
On 08/24/15 18:22, Joseph Myers wrote:
> On Mon, 24 Aug 2015, Joseph Myers wrote:
>
>> I'm testing this patch to default the offload targets after the
>> original command line is processed (and before extra options from
>> these specs are processed, so before the assertion is executed), and
>> will commit it if tests are OK.
>
> Now committed to gomp-4_0-branch.

thanks!
diff mbox

Patch

Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c	(revision 227045)
+++ gcc/gcc.c	(working copy)
@@ -1064,9 +1064,6 @@  static const char *const multilib_defaults_raw[] =
 static const char *const driver_self_specs[] = {
   "%{fdump-final-insns:-fdump-final-insns=.} %<fdump-final-insns",
 #ifdef ENABLE_OFFLOADING
-  /* If the user didn't specify any, default to all configured offload
-     targets.  */
-  "%{!foffload=*:-foffload=" OFFLOAD_TARGETS "}",
   /* If linking against libgomp, add a setup file.  */
   "%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*} 1):" \
   "%:add-omp-infile()}",
@@ -4291,6 +4288,11 @@  process_command (unsigned int decoded_options_coun
 			   CL_DRIVER, &handlers, global_dc);
     }
 
+  /* If the user didn't specify any, default to all configured offload
+     targets.  */
+  if (offload_targets == NULL)
+    handle_foffload_option (OFFLOAD_TARGETS);
+
   if (output_file
       && strcmp (output_file, "-") != 0
       && strcmp (output_file, HOST_BIT_BUCKET) != 0)