[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
This commit is contained in:
Thomas Schwinge 2015-04-29 18:23:26 +02:00 committed by Thomas Schwinge
parent aaf3de7ab2
commit f82a9d904e
2 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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++)