From: Kwok Cheung Yeung Date: Mon, 6 Jul 2020 22:21:08 +0000 (-0700) Subject: amdgcn, nvptx: Handle -fpic/-fPIC in mkoffload X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8b522311beef5e02de15427e924752ea02def2a;p=gcc.git amdgcn, nvptx: Handle -fpic/-fPIC in mkoffload 2020-07-08 Tobias Burnus 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. --- diff --git a/gcc/config/gcn/mkoffload.c b/gcc/config/gcn/mkoffload.c index 14f422e5c6d..0415d945e72 100644 --- a/gcc/config/gcn/mkoffload.c +++ b/gcc/config/gcn/mkoffload.c @@ -483,7 +483,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) @@ -493,6 +494,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) @@ -596,6 +601,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=" @@ -614,6 +621,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) @@ -766,7 +777,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; } diff --git a/gcc/config/nvptx/mkoffload.c b/gcc/config/nvptx/mkoffload.c index efdf9b9980d..4fecb2b9cfe 100644 --- a/gcc/config/nvptx/mkoffload.c +++ b/gcc/config/nvptx/mkoffload.c @@ -356,7 +356,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) @@ -366,6 +367,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) @@ -471,6 +476,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=" @@ -489,6 +496,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) @@ -587,7 +598,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; }