On 12/6/25 1:46 PM, Peter Damianov wrote:
This patch adds support for compiling Windows resource files
(.rc) and pre-compiled resource files (.res) directly through the
GCC driver on PECOFF targets.

Previously, users had to manually invoke windres to compile resource
files before linking:

     windres -o resource.o resource.rc
     gcc main.c resource.o -o program.exe

With this patch, GCC can handle resource files automatically:

     gcc main.c resource.rc -o program.exe
     gcc main.c resource.res -o program.exe

Now, for an explanation of each line of the spec:

If any of -E -M or -MM were passed, do nothing. No object files are output.
     "%{!E:%{!M:%{!MM:windres

Add -J so that windres does not perform autodetection of input type
Add -O so that the output type is always COFF
      -J rc -O coff \

For multilib configurations, tell windres to write out the correct COFF format
     %{m32:--target=pe-i386} %{m64:--target=pe-x86-64} \

Pass through -I -D -U on to windres, because it supports them.
     %{I*:-I%*} %{D*:-D%*} %{U*:-U%*} \

If -c is passed, pass through -o to windres, if it was specified. Otherwise,
  output to the input basename with .o suffix. Else, output to a
  temp file that will be deleted after linking.
     %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O} %i}}}",

gcc/ChangeLog:

        PR driver/108866
        * gcc.cc (default_compilers): Add EXTRA_DEFAULT_COMPILERS so the config
        of a target can add an extra compiler spec to default_compilers.
        * config/i386/cygming.h: Add EXTRA_DEFAULT_COMPILERS spec for windres.
        * config/aarch64/cygming.h: Likewise.

Signed-off-by: Peter Damianov <[email protected]>

I will push it soon if there are no more comments.

Reply via email to