This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

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)

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]