From: Thomas Schwinge Date: Wed, 29 Apr 2015 16:23:26 +0000 (+0200) Subject: [PR libgomp/65099] nvptx mkoffload: pass "-m32" or "-m64" to the compiler X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f82a9d904e8adb894033aa75740c9759b17bea0f;p=gcc.git [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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aaa06c36a72..d7455e4e0a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-04-29 Thomas Schwinge + + 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 PR target/65770 diff --git a/gcc/config/nvptx/mkoffload.c b/gcc/config/nvptx/mkoffload.c index dbc68bcfbed..8687154a1ac 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++)