]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
amdgcn, nvptx: Handle -fpic/-fPIC in mkoffload
authorKwok Cheung Yeung <kcy@codesourcery.com>
Mon, 6 Jul 2020 22:21:08 +0000 (15:21 -0700)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Wed, 8 Jul 2020 20:44:14 +0000 (13:44 -0700)
This is a backport from master
(commit a8b522311beef5e02de15427e924752ea02def2a).

2020-07-08  Tobias Burnus  <tobias@codesourcery.com>

gcc/ChangeLog:

* config/gcn/mkoffload.c (compile_native, main): Pass -fPIC/-fpic
on to the native compiler, if used.
* config/nvptx/mkoffload.c (compile_native, main): Likewise.

gcc/ChangeLog.omp
gcc/config/gcn/mkoffload.c
gcc/config/nvptx/mkoffload.c

index 5a3027a2838f52c5a45f38d8b35a1fd14f0f456f..8ef30c9cb3824a301028130cef00fbe235a88fd2 100644 (file)
@@ -1,3 +1,10 @@
+2020-07-08  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       * config/gcn/mkoffload.c (compile_native, main): Pass -fPIC/-fpic
+       on to the native compiler, if used.
+       * config/nvptx/mkoffload.c (compile_native, main): Likewise.
+
 2020-07-03  Andrew Stubbs  <ams@codesourcery.com>
 
        Backport from mainline:
index 723da108b655b148b5e06b1f9ed20b7de4e9482b..318bf435cf318785cfec0af840e20b3948b31d88 100644 (file)
@@ -482,7 +482,8 @@ process_obj (FILE *in, FILE *cfile)
 /* Compile a C file using the host compiler.  */
 
 static void
-compile_native (const char *infile, const char *outfile, const char *compiler)
+compile_native (const char *infile, const char *outfile, const char *compiler,
+               bool fPIC, bool fpic)
 {
   const char *collect_gcc_options = getenv ("COLLECT_GCC_OPTIONS");
   if (!collect_gcc_options)
@@ -492,6 +493,10 @@ compile_native (const char *infile, const char *outfile, const char *compiler)
   struct obstack argv_obstack;
   obstack_init (&argv_obstack);
   obstack_ptr_grow (&argv_obstack, compiler);
+  if (fPIC)
+    obstack_ptr_grow (&argv_obstack, "-fPIC");
+  if (fpic)
+    obstack_ptr_grow (&argv_obstack, "-fpic");
   if (save_temps)
     obstack_ptr_grow (&argv_obstack, "-save-temps");
   if (verbose)
@@ -589,6 +594,8 @@ main (int argc, char **argv)
   /* Scan the argument vector.  */
   bool fopenmp = false;
   bool fopenacc = false;
+  bool fPIC = false;
+  bool fpic = false;
   for (int i = 1; i < argc; i++)
     {
 #define STR "-foffload-abi="
@@ -607,6 +614,10 @@ main (int argc, char **argv)
        fopenmp = true;
       else if (strcmp (argv[i], "-fopenacc") == 0)
        fopenacc = true;
+      else if (strcmp (argv[i], "-fPIC") == 0)
+       fPIC = true;
+      else if (strcmp (argv[i], "-fpic") == 0)
+       fpic = true;
       else if (strcmp (argv[i], "-save-temps") == 0)
        save_temps = true;
       else if (strcmp (argv[i], "-v") == 0)
@@ -732,7 +743,7 @@ main (int argc, char **argv)
   xputenv (concat ("COMPILER_PATH=", cpath, NULL));
   xputenv (concat ("LIBRARY_PATH=", lpath, NULL));
 
-  compile_native (gcn_cfile_name, outname, collect_gcc);
+  compile_native (gcn_cfile_name, outname, collect_gcc, fPIC, fpic);
 
   return 0;
 }
index 803b58513382e15268e273e2edb34b7abc3cb4dd..729b29870bdea2e1053615304e3e2af1550ae40a 100644 (file)
@@ -355,7 +355,8 @@ process (FILE *in, FILE *out)
 }
 
 static void
-compile_native (const char *infile, const char *outfile, const char *compiler)
+compile_native (const char *infile, const char *outfile, const char *compiler,
+               bool fPIC, bool fpic)
 {
   const char *collect_gcc_options = getenv ("COLLECT_GCC_OPTIONS");
   if (!collect_gcc_options)
@@ -365,6 +366,10 @@ compile_native (const char *infile, const char *outfile, const char *compiler)
   struct obstack argv_obstack;
   obstack_init (&argv_obstack);
   obstack_ptr_grow (&argv_obstack, compiler);
+  if (fPIC)
+    obstack_ptr_grow (&argv_obstack, "-fPIC");
+  if (fpic)
+    obstack_ptr_grow (&argv_obstack, "-fpic");
   if (save_temps)
     obstack_ptr_grow (&argv_obstack, "-save-temps");
   if (verbose)
@@ -464,6 +469,8 @@ main (int argc, char **argv)
   /* Scan the argument vector.  */
   bool fopenmp = false;
   bool fopenacc = false;
+  bool fPIC = false;
+  bool fpic = false;
   for (int i = 1; i < argc; i++)
     {
 #define STR "-foffload-abi="
@@ -482,6 +489,10 @@ main (int argc, char **argv)
        fopenmp = true;
       else if (strcmp (argv[i], "-fopenacc") == 0)
        fopenacc = true;
+      else if (strcmp (argv[i], "-fPIC") == 0)
+       fPIC = true;
+      else if (strcmp (argv[i], "-fpic") == 0)
+       fpic = true;
       else if (strcmp (argv[i], "-save-temps") == 0)
        save_temps = true;
       else if (strcmp (argv[i], "-v") == 0)
@@ -560,7 +571,7 @@ main (int argc, char **argv)
 
   fclose (out);
 
-  compile_native (ptx_cfile_name, outname, collect_gcc);
+  compile_native (ptx_cfile_name, outname, collect_gcc, fPIC, fpic);
 
   return 0;
 }