[gcc-7] 104/354: * Allow setting offload targets by OFFLOAD_TARGET_DEFAULT.

Ximin Luo infinity0 at debian.org
Thu Nov 23 15:50:37 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository gcc-7.

commit 46f8b6a1091ac3ca53a3a79520b2ba8d0ad7b754
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date:   Thu Feb 2 13:03:34 2017 +0000

      * Allow setting offload targets by OFFLOAD_TARGET_DEFAULT.
    
    
    git-svn-id: svn+ssh://svn.debian.org/svn/gcccvs/branches/sid/gcc-7@9273 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
 debian/changelog                         |   1 +
 debian/patches/gcc-foffload-default.diff | 125 +++++++++++++++++++++++++++++++
 debian/rules.patch                       |   1 +
 3 files changed, 127 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index efe19a9..11a8c24 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 gcc-7 (7-20170129-2) UNRELEASED; urgency=medium
 
   * Fix some hppa64 related build issues. Addresses: #853023.
+  * Allow setting offload targets by OFFLOAD_TARGET_DEFAULT.
 
  -- Matthias Klose <doko at debian.org>  Tue, 31 Jan 2017 12:34:55 +0100
 
diff --git a/debian/patches/gcc-foffload-default.diff b/debian/patches/gcc-foffload-default.diff
new file mode 100644
index 0000000..599cb4a
--- /dev/null
+++ b/debian/patches/gcc-foffload-default.diff
@@ -0,0 +1,125 @@
+# DP: Allow setting offload targets by OFFLOAD_TARGET_DEFAULT
+
+http://pkgs.fedoraproject.org/cgit/rpms/gcc.git/tree/gcc7-foffload-default.patch
+
+2017-01-20  Jakub Jelinek  <jakub at redhat.com>
+
+	* gcc.c (offload_targets_default): New variable.
+	(process_command): Set it if -foffload is defaulted.
+	(driver::maybe_putenv_OFFLOAD_TARGETS): Add OFFLOAD_TARGET_DEFAULT=1
+	into environment if -foffload has been defaulted.
+	* lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define.
+	(compile_images_for_offload_targets): If OFFLOAD_TARGET_DEFAULT
+	is in the environment, don't fail if corresponding mkoffload
+	can't be found.  Free and clear offload_names if no valid offload
+	is found.
+libgomp/
+	* target.c (gomp_load_plugin_for_device): If a plugin can't be
+	dlopened, assume it has no devices silently.
+
+--- a/src/gcc/gcc.c.jj	2017-01-17 10:28:40.000000000 +0100
++++ b/src/gcc/gcc.c	2017-01-20 16:26:29.649962902 +0100
+@@ -290,6 +290,10 @@ static const char *spec_host_machine = D
+ 
+ static char *offload_targets = NULL;
+ 
++/* Set to true if -foffload has not been used and offload_targets
++   is set to the configured in default.  */
++static bool offload_targets_default;
++
+ /* Nonzero if cross-compiling.
+    When -b is used, the value comes from the `specs' file.  */
+ 
+@@ -4457,7 +4461,10 @@ process_command (unsigned int decoded_op
+   /* If the user didn't specify any, default to all configured offload
+      targets.  */
+   if (ENABLE_OFFLOADING && offload_targets == NULL)
+-    handle_foffload_option (OFFLOAD_TARGETS);
++    {
++      handle_foffload_option (OFFLOAD_TARGETS);
++      offload_targets_default = true;
++    }
+ 
+   if (output_file
+       && strcmp (output_file, "-") != 0
+@@ -7693,6 +7700,12 @@ driver::maybe_putenv_OFFLOAD_TARGETS ()
+       obstack_grow (&collect_obstack, offload_targets,
+ 		    strlen (offload_targets) + 1);
+       xputenv (XOBFINISH (&collect_obstack, char *));
++      if (offload_targets_default)
++	{
++	  obstack_grow (&collect_obstack, "OFFLOAD_TARGET_DEFAULT=1",
++			sizeof ("OFFLOAD_TARGET_DEFAULT=1") - 1);
++	  xputenv (XOBFINISH (&collect_obstack, char *));
++	}
+     }
+ 
+   free (offload_targets);
+--- a/src/gcc/lto-wrapper.c.jj	2017-01-01 12:45:34.000000000 +0100
++++ b/src/gcc/lto-wrapper.c	2017-01-20 16:34:18.294016997 +0100
+@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
+ /* Environment variable, used for passing the names of offload targets from GCC
+    driver to lto-wrapper.  */
+ #define OFFLOAD_TARGET_NAMES_ENV	"OFFLOAD_TARGET_NAMES"
++#define OFFLOAD_TARGET_DEFAULT_ENV	"OFFLOAD_TARGET_DEFAULT"
+ 
+ enum lto_mode_d {
+   LTO_MODE_NONE,			/* Not doing LTO.  */
+@@ -790,8 +791,10 @@ compile_images_for_offload_targets (unsi
+   if (!target_names)
+     return;
+   unsigned num_targets = parse_env_var (target_names, &names, NULL);
++  const char *target_names_default = getenv (OFFLOAD_TARGET_DEFAULT_ENV);
+ 
+   int next_name_entry = 0;
++  bool hsa_seen = false;
+   const char *compiler_path = getenv ("COMPILER_PATH");
+   if (!compiler_path)
+     goto out;
+@@ -804,18 +807,32 @@ compile_images_for_offload_targets (unsi
+       /* HSA does not use LTO-like streaming and a different compiler, skip
+ 	 it. */
+       if (strcmp (names[i], "hsa") == 0)
+-	continue;
++	{
++	  hsa_seen = true;
++	  continue;
++	}
+ 
+       offload_names[next_name_entry]
+ 	= compile_offload_image (names[i], compiler_path, in_argc, in_argv,
+ 				 compiler_opts, compiler_opt_count,
+ 				 linker_opts, linker_opt_count);
+       if (!offload_names[next_name_entry])
+-	fatal_error (input_location,
+-		     "problem with building target image for %s\n", names[i]);
++	{
++	  if (target_names_default != NULL)
++	    continue;
++	  fatal_error (input_location,
++		       "problem with building target image for %s\n",
++		       names[i]);
++	}
+       next_name_entry++;
+     }
+ 
++  if (next_name_entry == 0 && !hsa_seen)
++    {
++      free (offload_names);
++      offload_names = NULL;
++    }
++
+  out:
+   free_array_of_ptrs ((void **) names, num_targets);
+ }
+--- a/src/libgomp/target.c.jj	2017-01-01 12:45:52.000000000 +0100
++++ b/src/libgomp/target.c	2017-01-20 20:12:13.756710875 +0100
+@@ -2356,7 +2356,7 @@ gomp_load_plugin_for_device (struct gomp
+ 
+   void *plugin_handle = dlopen (plugin_name, RTLD_LAZY);
+   if (!plugin_handle)
+-    goto dl_fail;
++    return 0;
+ 
+   /* Check if all required functions are available in the plugin and store
+      their handlers.  None of the symbols can legitimately be NULL,
diff --git a/debian/rules.patch b/debian/rules.patch
index 28015d7..206958c 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -67,6 +67,7 @@ debian_patches += \
 	PR55947-revert \
 	libffi-pax \
 	libffi-race-condition \
+	gcc-foffload-default \
 
 
 #	$(if $(filter yes, $(DEB_CROSS)),,gcc-print-file-name) \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/gcc-7.git



More information about the Reproducible-commits mailing list