Re: Triggering -save-temps from the front-end code

2022-11-28 Thread Marc Glisse via Gcc

On Mon, 28 Nov 2022, Florian Weimer via Gcc wrote:


* Arsen Arsenović:


Hi,

Florian Weimer via Gcc  writes:


Unfortunately, some build systems immediately delete the input source
files.  Is there some easy way I can dump the pre-processed and
non-preprocessed sources to my log file?  I tried to understand how
-save-temps for crash recovery works, but it seems that this runs
outside of the frontend, in the driver.


Would dumping unconditionally into some "side channel" -dumpdir be a
sufficient workaround?


Of the file names overlap, and it seems in this case, the dump files are
just overwritten.  I don't see a way to make the file names unique.

I guess for the tough cases, I can just keep running the build under
strace.


You could override unlink with LD_PRELOAD. Use a special purpose 
filesystem (gitfs? I haven't tried it yet). Wrap gcc with a command that 
calls the true gcc with a different TMPDIR / -dumpdir each time.


--
Marc Glisse


Re: Triggering -save-temps from the front-end code

2022-11-28 Thread Florian Weimer via Gcc
* Arsen Arsenović:

> Hi,
>
> Florian Weimer via Gcc  writes:
>
>> Unfortunately, some build systems immediately delete the input source
>> files.  Is there some easy way I can dump the pre-processed and
>> non-preprocessed sources to my log file?  I tried to understand how
>> -save-temps for crash recovery works, but it seems that this runs
>> outside of the frontend, in the driver.
>
> Would dumping unconditionally into some "side channel" -dumpdir be a
> sufficient workaround?

Of the file names overlap, and it seems in this case, the dump files are
just overwritten.  I don't see a way to make the file names unique.

I guess for the tough cases, I can just keep running the build under
strace.

Thanks,
Florian



Re: Triggering -save-temps from the front-end code

2022-11-28 Thread Arsen Arsenović via Gcc
Hi,

Florian Weimer via Gcc  writes:

> Unfortunately, some build systems immediately delete the input source
> files.  Is there some easy way I can dump the pre-processed and
> non-preprocessed sources to my log file?  I tried to understand how
> -save-temps for crash recovery works, but it seems that this runs
> outside of the frontend, in the driver.

Would dumping unconditionally into some "side channel" -dumpdir be a
sufficient workaround?

https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Overall-Options.html#index-dumpdir

Hope that helps, have a great day.
-- 
Arsen Arsenović


signature.asc
Description: PGP signature


Re: Triggering -save-temps from the front-end code

2022-11-28 Thread Richard Biener via Gcc
On Mon, Nov 28, 2022 at 12:30 PM Florian Weimer via Gcc  wrote:
>
> I've got some instrumentation for logging errors to a magic directory,
> so that I can see if a build triggered them even when it did not
> fail—and hid all compiler errors and warnings.
>
> Unfortunately, some build systems immediately delete the input source
> files.  Is there some easy way I can dump the pre-processed and
> non-preprocessed sources to my log file?  I tried to understand how
> -save-temps for crash recovery works, but it seems that this runs
> outside of the frontend, in the driver.

Yep, there's no way to trigger -save-temps behavior after-the-fact.

> Here's an example of the
> challenges this would help to solve:
>
>   Building in strict C99 mode
>   
>
> Thanks,
> Florian
>


Triggering -save-temps from the front-end code

2022-11-28 Thread Florian Weimer via Gcc
I've got some instrumentation for logging errors to a magic directory,
so that I can see if a build triggered them even when it did not
fail—and hid all compiler errors and warnings.

Unfortunately, some build systems immediately delete the input source
files.  Is there some easy way I can dump the pre-processed and
non-preprocessed sources to my log file?  I tried to understand how
-save-temps for crash recovery works, but it seems that this runs
outside of the frontend, in the driver.

Here's an example of the
challenges this would help to solve:

  Building in strict C99 mode
  

Thanks,
Florian