[FFmpeg-devel] [PATCH] ffbuild/common.mak: explicitly pass windres preprocessor args

Martin Storsjö martin at martin.st
Mon Jun 14 15:02:31 EEST 2021


On Tue, 8 Jun 2021, Kyle Schwarz wrote:

> Binutils 2.36 no longer supports bundling args with the preprocessor
> option.
> ---
> ffbuild/common.mak | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ffbuild/common.mak b/ffbuild/common.mak
> index 32f5b997b5..9fbbf89130 100644
> --- a/ffbuild/common.mak
> +++ b/ffbuild/common.mak
> @@ -90,7 +90,7 @@ COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS)
> 	-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
>
> %.o: %.rc
> -	$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
> +	$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES)" $(foreach ARG,-E -xc-header -DRC_INVOKED $(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $<
>
> %.i: %.c
> 	$(CC) $(CCFLAGS) $(CC_E) $<
> -- 
> 2.31.1

If doing this, we no longer need to pass --preprocessor "$(DEPWINDRES)" at 
all (and one can remove DEPWINDRES from configure), and by not setting 
that option, we don't need to pass "-E -xcheader -DRC_INVOKED" either.

We could also just hardcode the options to pass (as it's probably safe to 
assume that windres calls a gcc compatible preprocessor), e.g. like this:

     --preprocessor-arg -MMD --preprocessor-arg -MF --preprocessor-arg 
$(@:.o=.d) --preprocessor-arg -MT --preprocessor-arg $@

But your approach of $(foreach) also seems neat. In that case, it'd be 
something like this:

$(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)")

I've been considering sending a patch like this, but have held off so far, 
as it's still under discussion in 
https://sourceware.org/bugzilla/show_bug.cgi?id=27594 whether this 
behaviour change is supposed to be reverted or not. (It's under discussion 
whether it was correct of users to use the --preprocessor option like 
this, even if the documentation used to explicitly say that it was 
allowed.)

// Martin



More information about the ffmpeg-devel mailing list