diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2015-04-29 18:23:26 +0200 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2015-04-29 18:23:26 +0200 |
commit | f82a9d904e8adb894033aa75740c9759b17bea0f (patch) | |
tree | 1fa51fe9e956c45fa637058738c884fa3162251c | |
parent | aaf3de7ab2aac4b0b4c5a4fb260ca1955350a360 (diff) | |
download | gcc-f82a9d904e8adb894033aa75740c9759b17bea0f.zip gcc-f82a9d904e8adb894033aa75740c9759b17bea0f.tar.gz gcc-f82a9d904e8adb894033aa75740c9759b17bea0f.tar.bz2 |
[PR libgomp/65099] nvptx mkoffload: pass "-m32" or "-m64" to the compiler
... depending on "-foffload-abi=[...]".
Coding style/code copied from gcc/config/i386/intelmic-mkoffload.c for
consistency.
gcc/
* config/nvptx/mkoffload.c (target_ilp32): New variable.
(main): Set it depending on "-foffload-abi=[...]".
(compile_native, main): Use it to pass "-m32" or "-m64" to the
compiler.
From-SVN: r222583
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/nvptx/mkoffload.c | 18 |
2 files changed, 25 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aaa06c3..d7455e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-04-29 Thomas Schwinge <thomas@codesourcery.com> + + PR libgomp/65099 + * config/nvptx/mkoffload.c (target_ilp32): New variable. + (main): Set it depending on "-foffload-abi=[...]". + (compile_native, main): Use it to pass "-m32" or "-m64" to the + compiler. + 2015-04-29 Alan Lawrence <alan.lawrence@arm.com> PR target/65770 diff --git a/gcc/config/nvptx/mkoffload.c b/gcc/config/nvptx/mkoffload.c index dbc68bc..8687154 100644 --- a/gcc/config/nvptx/mkoffload.c +++ b/gcc/config/nvptx/mkoffload.c @@ -126,6 +126,9 @@ static id_map *var_ids, **vars_tail = &var_ids; static const char *ptx_name; static const char *ptx_cfile_name; +/* Shows if we should compile binaries for i386 instead of x86-64. */ +bool target_ilp32 = false; + /* Delete tempfiles. */ /* Unlink a temporary file unless requested otherwise. */ @@ -885,6 +888,7 @@ 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); + obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); obstack_ptr_grow (&argv_obstack, infile); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-o"); @@ -962,11 +966,23 @@ main (int argc, char **argv) passed with @file. Expand them into argv before processing. */ expandargv (&argc, &argv); + /* Find out whether we should compile binaries for i386 or x86-64. */ + for (int i = argc - 1; i > 0; i--) + if (strncmp (argv[i], "-foffload-abi=", sizeof ("-foffload-abi=") - 1) == 0) + { + if (strstr (argv[i], "ilp32")) + target_ilp32 = true; + else if (!strstr (argv[i], "lp64")) + fatal_error (input_location, + "unrecognizable argument of option -foffload-abi"); + break; + } + struct obstack argv_obstack; obstack_init (&argv_obstack); obstack_ptr_grow (&argv_obstack, driver); obstack_ptr_grow (&argv_obstack, "-xlto"); - obstack_ptr_grow (&argv_obstack, "-m64"); + obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); obstack_ptr_grow (&argv_obstack, "-S"); for (int ix = 1; ix != argc; ix++) |