diff options
| author | David Malcolm <dmalcolm@redhat.com> | 2015-01-09 17:01:04 +0000 |
|---|---|---|
| committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-01-09 17:01:04 +0000 |
| commit | d2286af3d3fe908f84957406aba98eefd1f6e05e (patch) | |
| tree | 6c908a45d62d11096d3b5ae2fb3675716fcbf926 /gcc/jit/jit-tempdir.c | |
| parent | 4c470097be7b403c8b424c703144b03a88f22b3b (diff) | |
| download | gcc-d2286af3d3fe908f84957406aba98eefd1f6e05e.zip gcc-d2286af3d3fe908f84957406aba98eefd1f6e05e.tar.gz gcc-d2286af3d3fe908f84957406aba98eefd1f6e05e.tar.bz2 | |
PR jit/64206: delay cleanup of tempdir if the user has requested debuginfo
gcc/jit/ChangeLog:
PR jit/64206
* docs/internals/test-hello-world.exe.log.txt: Update, the log now
shows tempdir creation/cleanup.
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* jit-logging.h (class gcc::jit::log_user): Add gcc::jit::tempdir
to the list of subclasses in the comment.
* jit-playback.c (gcc::jit::playback::context::context): Add a
comment clarifying when the tempdir gets cleaned up.
(gcc::jit::playback::context::compile): Pass the context's logger,
if any, to the tempdir.
(gcc::jit::playback::context::dlopen_built_dso): When creating the
gcc::jit::result, if GCC_JIT_BOOL_OPTION_DEBUGINFO is set, hand
over ownership of the tempdir to it.
* jit-result.c: Include "jit-tempdir.h".
(gcc::jit::result::result): Add tempdir param, saving it as
m_tempdir.
(gcc::jit::result::~result): Delete m_tempdir.
* jit-result.h (gcc::jit::result::result): Add tempdir param.
(gcc::jit::result::m_tempdir): New field.
* jit-tempdir.c (gcc::jit::tempdir::tempdir): Add logger param;
add JIT_LOG_SCOPE.
(gcc::jit::tempdir::create): Add JIT_LOG_SCOPE to log entry/exit,
and log m_path_template and m_path_tempdir.
(gcc::jit::tempdir::~tempdir): Add JIT_LOG_SCOPE to log
entry/exit, and log the unlink and rmdir calls.
* jit-tempdir.h: Include "jit-logging.h".
(class gcc::jit::tempdir): Make this be a subclass of log_user.
(gcc::jit::tempdir::tempdir): Add logger param.
* notes.txt: Update to show the two possible places where the
tempdir can be cleaned up.
From-SVN: r219395
Diffstat (limited to 'gcc/jit/jit-tempdir.c')
| -rw-r--r-- | gcc/jit/jit-tempdir.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/gcc/jit/jit-tempdir.c b/gcc/jit/jit-tempdir.c index 14c7418..856b246 100644 --- a/gcc/jit/jit-tempdir.c +++ b/gcc/jit/jit-tempdir.c @@ -66,14 +66,16 @@ make_tempdir_path_template () /* The constructor for the jit::tempdir object. The real work is done by the jit::tempdir::create method. */ -gcc::jit::tempdir::tempdir (int keep_intermediates) - : m_keep_intermediates (keep_intermediates), +gcc::jit::tempdir::tempdir (logger *logger, int keep_intermediates) + : log_user (logger), + m_keep_intermediates (keep_intermediates), m_path_template (NULL), m_path_tempdir (NULL), m_path_c_file (NULL), m_path_s_file (NULL), m_path_so_file (NULL) { + JIT_LOG_SCOPE (get_logger ()); } /* Do the real work of creating the on-disk tempdir. @@ -83,16 +85,22 @@ gcc::jit::tempdir::tempdir (int keep_intermediates) bool gcc::jit::tempdir::create () { + JIT_LOG_SCOPE (get_logger ()); + m_path_template = make_tempdir_path_template (); if (!m_path_template) return false; + log ("m_path_template: %s", m_path_template); + /* Create tempdir using mkdtemp. This is created with 0700 perms and is unique. Hence no other (non-root) users should have access to the paths within it. */ m_path_tempdir = mkdtemp (m_path_template); if (!m_path_tempdir) return false; + log ("m_path_tempdir: %s", m_path_tempdir); + m_path_c_file = concat (m_path_tempdir, "/fake.c", NULL); m_path_s_file = concat (m_path_tempdir, "/fake.s", NULL); m_path_so_file = concat (m_path_tempdir, "/fake.so", NULL); @@ -107,17 +115,28 @@ gcc::jit::tempdir::create () gcc::jit::tempdir::~tempdir () { + JIT_LOG_SCOPE (get_logger ()); + if (m_keep_intermediates) fprintf (stderr, "intermediate files written to %s\n", m_path_tempdir); else { /* Clean up .s/.so and tempdir. */ if (m_path_s_file) - unlink (m_path_s_file); + { + log ("unlinking .s file: %s", m_path_s_file); + unlink (m_path_s_file); + } if (m_path_so_file) - unlink (m_path_so_file); + { + log ("unlinking .so file: %s", m_path_so_file); + unlink (m_path_so_file); + } if (m_path_tempdir) - rmdir (m_path_tempdir); + { + log ("removing tempdir: %s", m_path_tempdir); + rmdir (m_path_tempdir); + } } free (m_path_template); |
