mkoffload: Cleanup temporary omp_requires_file
authorTobias Burnus <tobias@codesourcery.com>
Fri, 19 Aug 2022 14:09:28 +0000 (16:09 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 19 Aug 2022 14:09:28 +0000 (16:09 +0200)
The file (suffix ".mkoffload.omp_requires") used to save the 'omp requires'
data has to be passed to maybe_unlink for cleanup or -v -save-temps stderr
diagnostic. That was missed before. - For GCN, the same has to be done for
the files with suffix ".mkoffload.dbg.o".

gcc/ChangeLog:

* config/gcn/mkoffload.cc (main): Add omp_requires_file and dbgobj to
files_to_cleanup.
* config/i386/intelmic-mkoffload.cc (prepare_target_image): Add
omp_requires_file to temp_files.
* config/nvptx/mkoffload.cc (omp_requires_file): New global static var.
(main): Remove local omp_requires_file var.
(tool_cleanup): Handle omp_requires_file.

gcc/config/gcn/mkoffload.cc
gcc/config/i386/intelmic-mkoffload.cc
gcc/config/nvptx/mkoffload.cc

index d246433..4206448 100644 (file)
@@ -1030,6 +1030,7 @@ main (int argc, char **argv)
                    }
                  else
                    dbgobj = make_temp_file (".mkoffload.dbg.o");
+                 obstack_ptr_grow (&files_to_cleanup, dbgobj);
 
                  /* If the copy fails then just ignore it.  */
                  if (copy_early_debug_info (argv[ix], dbgobj))
@@ -1085,6 +1086,7 @@ main (int argc, char **argv)
        omp_requires_file = concat (dumppfx, ".mkoffload.omp_requires", NULL);
       else
        omp_requires_file = make_temp_file (".mkoffload.omp_requires");
+      obstack_ptr_grow (&files_to_cleanup, omp_requires_file);
 
       /* Run the compiler pass.  */
       xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
index 596f6f1..5deddff 100644 (file)
@@ -526,6 +526,7 @@ prepare_target_image (const char *target_compiler, int argc, char **argv, uint32
     omp_requires_file = concat (dumppfx, ".mkoffload.omp_requires", NULL);
   else
     omp_requires_file = make_temp_file (".mkoffload.omp_requires");
+  temp_files[num_temps++] = omp_requires_file;
   xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
 
   compile_for_target (&argv_obstack);
index 0fa5f44..3eea0a8 100644 (file)
@@ -55,6 +55,7 @@ static id_map *var_ids, **vars_tail = &var_ids;
 /* Files to unlink.  */
 static const char *ptx_name;
 static const char *ptx_cfile_name;
+static const char *omp_requires_file;
 static const char *ptx_dumpbase;
 
 enum offload_abi offload_abi = OFFLOAD_ABI_UNSET;
@@ -68,6 +69,8 @@ tool_cleanup (bool from_signal ATTRIBUTE_UNUSED)
     maybe_unlink (ptx_cfile_name);
   if (ptx_name)
     maybe_unlink (ptx_name);
+  if (omp_requires_file)
+    maybe_unlink (omp_requires_file);
 }
 
 static void
@@ -586,7 +589,6 @@ 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