Subject: bug#46495: 28.0.50; [native-comp] Build fails for 32bit --with-wide-int

From: Eli Zaretskii <[email-masked]>
Date: Wed, 31 Mar 2021 16:33:57 +0300

> From: David Malcolm <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> Date: Wed, 31 Mar 2021 09:03:33 -0400
> 
> > David, what's the story with these temporary directories?
> 
> They're meant to be cleaned up automatically by libgccjit: on
> gcc_jit_result_release for a successful compilation, or at the end of
> gcc_jit_context_compile* for a failed compilation.
> 
> The removal code is in gcc::jit::tempdir::~tempdir in gcc/jit/jit-
> tempdir.c, maybe there's a bug there? (perhaps only affecting Windows?)
> It calls unlink on everything it "knows" about, and them rmdir on the
> directory.  I see now that I'm not checking for errors on those unlink
> and rmdir calls.

maybe you are relying on the Posix semantics whereby you can remove
files that are still in use, and the OS will remove them when the last
user closes the file?  That's not going to work on Windows, you need
to close first and remove later.

When does the object go out of scope, and its destructor called?

> Is the code setting GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES to true,
> perhaps?

No.  the code is just tut01d-hello-world.c as it is given here:

  https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html

The only variation (as described in my previous messages) is that I
added

  gcc_jit_context_set_bool_option (
				   ctxt,
				   GCC_JIT_BOOL_OPTION_DEBUGINFO,
				   1);

in one of the variants I compiled.  But the variant with the above
added actually behaves correctly and removes the temporary directory
upon exit.