[PATCH v4 1/2] debug: Autogenerate _FORTIFY_SOURCE tests

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Jan 11 16:41:02 GMT 2022



On 11/01/2022 12:28, Siddhesh Poyarekar wrote:
> On 11/01/2022 18:57, Adhemerval Zanella via Libc-alpha wrote:
>> I see no much point in regenerate adding the auto-generated files on
>> repository, I think it would be better to move them to build directory
>> instead.
> 
> Fair point.
> 
>> The changes below based on your patch should do it. I had to do a special
>> iterator to handle the C++ files.
>>
>> diff --git a/debug/Makefile b/debug/Makefile
>> index b5e13eec94..7c9023b55a 100644
>> --- a/debug/Makefile
>> +++ b/debug/Makefile
>> @@ -148,12 +148,6 @@ tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3)
>>   CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
>>                         -Wno-deprecated-declarations \
>>                         -Wno-error
>> -$(eval $(call cflags-$(2),$(1),$(3)))
>> -tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
>> -    ( echo "/* Autogenerated from Makefile.  */"; \
>> -      echo "$(src-chk-$(2))"; \
>> -      echo "#include \"tst-fortify.c\"" ) > $$@.tmp
>> -    mv $$@.tmp $$@
>>   endef
>>     chk-extensions = c cc
>> @@ -167,6 +161,32 @@ $(foreach e,$(chk-extensions), \
>>     tests-all-chk += $(tests-c-chk) $(tests-cc-chk)
>>   +generated += \
>> +  $(addsuffix .c, $(tests-c-chk)) \
>> +  $(addsuffix .cc, $(tests-cc-chk)) \
>> +  gen-debug-templates
>> +
>> +$(objpfx)gen-debug-templates.stmp: tst-fortify.c Makefile
>> +    $(make-target-directory)
>> +    for e in $(chk-extensions); do                           \
>> +      for t in $(chk-types); do                              \
>> +        for l in $(chk-levels); do                           \
>> +          file=$(objpfx)tst-fortify-$${e}-$${t}-$${l}.$${e}; \
>> +          (                                                  \
>> +            echo "/* Autogenerated from Makefile.  */";      \
>> +        echo "#include \"tst-fortify.c\""                \
>> +          ) > $${file};                                      \
>> +        done;                                                \
>> +      done;                                                  \
>> +    done;                                                    \
>> +    echo > $(@)
> 
> Trouble here is that if one of the sources goes missing, there's no rule to regenerate it, so an incremental build with a new autogenerated test won't work.
> 
> Maybe ditch the generator and keep the above rules to generate sources, except that they generate the sources in $(objpfx) instead of the source directory?

Yeah, that the same issue we have for math autogenerated files.  In such cases
I either trigger a full rebuild or just remove the stmp file to regenerate
the files.

But if you have a better idea I think we can use it and maybe also adapt on
math.


More information about the Libc-alpha mailing list