This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug jit/69144] Some libgccjit API entrypoints leave files in /tmp/libgccjit-*


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69144

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Author: dmalcolm
Date: Tue Jan 19 20:37:19 2016
New Revision: 232582

URL: https://gcc.gnu.org/viewcvs?rev=232582&root=gcc&view=rev
Log:
PR jit/69144: Ensure that libgccjit's tempdir is fully cleaned-up

There were a couple of ways that libgccjit could fail to unlink all
of its tempfiles, leading to /tmp/libgccjit-* tempdirs lingering
after the build:
- dumpfiles requested by gcc_jit_context_enable_dump
- ahead-of-time compilation artifacts which lingered in the tempdir
  after they've been copied up to the output_path.  This was only
  the case for GCC_JIT_OUTPUT_KIND_OBJECT_FILE and
  GCC_JIT_OUTPUT_KIND_EXECUTABLE.

The following patch fixes these by introducing a vec of additional
cleanups to be performed by gcc:jit::tempdir's dtor.

In addition, if a gcc_jit_result * is leaked and
GCC_JIT_BOOL_OPTION_DEBUGINFO is enabled, the tempdir will also
not be cleaned up.  This was the case for tut04-toyvm/toyvm.cc
which the patch fixes by introducing a wrapper around
gcc_jit_result *.  Doing this required some updates to the
corresponding docs.

gcc/jit/ChangeLog:
        PR jit/69144
        * jit-playback.c (gcc::jit::playback::compile_to_file::postprocess):
        Potentially add the temporary artifact to the tempdir's list of
        tempfiles needing additional cleanup.
        (gcc::jit::playback::context::extract_any_requested_dumps): Likewise
        for the dumpfile.
        * jit-tempdir.c (gcc::jit::tempdir::~tempdir): Clean up additional
        tempfiles.
        * jit-tempdir.h (gcc::jit::tempdir::add_temp_file): New method.
        (gcc::jit::tempdir::m_tempfiles): New field.
        * docs/cp/intro/tutorial04.rst: Update for changes to toyvm.cc.
        * docs/examples/tut04-toyvm/toyvm.cc (class compilation_result):
        New.
        (toyvm_function::compile): Change return type from function ptr
        to a compilation_result.
        (toyvm_function::get_function_name): New accessor.
        (toyvm_function::m_funcname): New field.
        (get_function_name): Convert to...
        (toyvm_function::make_function_name): ...this new method.
        (toyvm_function::parse): Call make_function_name.
        (toyvm_function::compile): Convert return type from function ptr
        to a compilation_result.  Use get_function_name.
        (compilation_state::compile): Convert return type from
        gcc_jit_result * to a compilation_result.
        (test_script): Update for above changes, extracting the code from
        the compilation_result.
        (main): Likewise.
        * docs/_build/texinfo/libgccjit.texi: Regenerate.


Modified:
    trunk/gcc/jit/ChangeLog
    trunk/gcc/jit/docs/_build/texinfo/libgccjit.texi
    trunk/gcc/jit/docs/cp/intro/tutorial04.rst
    trunk/gcc/jit/docs/examples/tut04-toyvm/toyvm.cc
    trunk/gcc/jit/jit-playback.c
    trunk/gcc/jit/jit-tempdir.c
    trunk/gcc/jit/jit-tempdir.h

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]