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. */
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");
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++)