X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=gcc%2Fconfig%2Fnvptx%2Fmkoffload.cc;h=d8c81eb05473994cccc1670092640db0a83e9131;hb=683f11843974f0bdf42f79cdcbb0c2b43c7b81b0;hp=b28c1a32292a62b6b871c9e656091a50a252dd30;hpb=10b502fb78351a4073b6682c026a92c82d3da6c5;p=thirdparty%2Fgcc.git diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc index b28c1a32292..d8c81eb0547 100644 --- a/gcc/config/nvptx/mkoffload.cc +++ b/gcc/config/nvptx/mkoffload.cc @@ -231,7 +231,7 @@ access_check (const char *name, int mode) } static void -process (FILE *in, FILE *out) +process (FILE *in, FILE *out, uint32_t omp_requires) { size_t len = 0; const char *input = read_file (in, &len); @@ -240,6 +240,8 @@ process (FILE *in, FILE *out) unsigned obj_count = 0; unsigned ix; + fprintf (out, "#include \n\n"); + /* Dump out char arrays for each PTX object file. These are terminated by a NUL. */ for (size_t i = 0; i != len;) @@ -309,6 +311,7 @@ process (FILE *in, FILE *out) fprintf (out, "static const struct nvptx_tdata {\n" + " uintptr_t omp_requires_mask;\n" " const struct ptx_obj *ptx_objs;\n" " unsigned ptx_num;\n" " const char *const *var_names;\n" @@ -316,12 +319,12 @@ process (FILE *in, FILE *out) " const struct nvptx_fn *fn_names;\n" " unsigned fn_num;\n" "} target_data = {\n" - " ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n" + " %d, ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n" " var_mappings," " sizeof (var_mappings) / sizeof (var_mappings[0]),\n" " func_mappings," " sizeof (func_mappings) / sizeof (func_mappings[0])\n" - "};\n\n"); + "};\n\n", omp_requires); fprintf (out, "#ifdef __cplusplus\n" "extern \"C\" {\n" @@ -583,19 +586,37 @@ main (int argc, char **argv) unsetenv ("COMPILER_PATH"); unsetenv ("LIBRARY_PATH"); + char *omp_requires_file; + if (save_temps) + omp_requires_file = concat (dumppfx, ".mkoffload.omp_requires", NULL); + else + omp_requires_file = make_temp_file (".mkoffload.omp_requires"); + + xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL)); fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true, ".gcc_args"); obstack_free (&argv_obstack, NULL); + unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE"); xputenv (concat ("GCC_EXEC_PREFIX=", execpath, NULL)); xputenv (concat ("COMPILER_PATH=", cpath, NULL)); xputenv (concat ("LIBRARY_PATH=", lpath, NULL)); + in = fopen (omp_requires_file, "rb"); + if (!in) + fatal_error (input_location, "cannot open omp_requires file %qs", + omp_requires_file); + uint32_t omp_requires; + if (fread (&omp_requires, sizeof (omp_requires), 1, in) != 1) + fatal_error (input_location, "cannot read omp_requires file %qs", + omp_requires_file); + fclose (in); + in = fopen (ptx_name, "r"); if (!in) fatal_error (input_location, "cannot open intermediate ptx file"); - process (in, out); + process (in, out, omp_requires); fclose (in); }