public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	Andrew Stubbs <ams@codesourcery.com>
Subject: [Patch] mkoffload: Cleanup temporary omp_requires_file
Date: Fri, 19 Aug 2022 16:01:10 +0200	[thread overview]
Message-ID: <8623b1a3-ef98-1ebb-1abc-194b646288a7@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]

Rather obvious, once found. I forgot to add some cleanup, cluttering
/tmp with ".mkoffload.omp_requires".

The same issue exists for GCN also for ".mkoffload.dbg"

OK for mainline? – For the dbg issue, OK also for GCC 11 and 12 backport?

Follow-up to the 'OpenMP: Move omp requires checks to libgomp" commit
https://gcc.gnu.org/r13-1458-g683f11843974f0bdf42f79cdcbb0c2b43c7b81b0

For GCN, the issues exists since
https://gcc.gnu.org/r11-6683-g505caa7295b93ecdec8ac9b31595eb34dbd48c9f

Tobias

PS: In case you wonder why it is also added with -save-temps: The
internally called maybe_unlink removed the file, unless -save-temps. For
the latter, with verbose flag, it also shows them as '[Leaving %s]'.

PPS: If you see some ...target.o files in /tmp, that's because of
https://gcc.gnu.org/PR106686
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: fix-mkoffload-tmp.diff --]
[-- Type: text/x-patch, Size: 3131 bytes --]

mkoffload: Cleanup temporary omp_requires_file

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.

diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc
index d2464332275..4206448703a 100644
--- a/gcc/config/gcn/mkoffload.cc
+++ b/gcc/config/gcn/mkoffload.cc
@@ -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));
diff --git a/gcc/config/i386/intelmic-mkoffload.cc b/gcc/config/i386/intelmic-mkoffload.cc
index 596f6f107b8..5deddff6ca2 100644
--- a/gcc/config/i386/intelmic-mkoffload.cc
+++ b/gcc/config/i386/intelmic-mkoffload.cc
@@ -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);
diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc
index 0fa5f4423bf..7557681ad07 100644
--- a/gcc/config/nvptx/mkoffload.cc
+++ b/gcc/config/nvptx/mkoffload.cc
@@ -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
@@ -571,7 +689,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

             reply	other threads:[~2022-08-19 14:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 14:01 Tobias Burnus [this message]
2022-08-19 14:05 ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8623b1a3-ef98-1ebb-1abc-194b646288a7@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=ams@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).