From: Jia Tan Date: Mon, 24 Jul 2023 13:43:44 +0000 (+0800) Subject: liblzma: Prevent an empty translation unit in Windows builds. X-Git-Tag: v5.2.13~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d4bf2d06f6a85fd107f2d58c744fe4880dd4b02;p=thirdparty%2Fxz.git liblzma: Prevent an empty translation unit in Windows builds. To workaround Automake lacking Windows resource compiler support, an empty source file is compiled to overwrite the resource files for static library builds. Translation units without an external declaration are not allowed by the C standard and result in a warning when used with -Wempty-translation-unit (Clang) or -pedantic (GCC). (cherry picked from commit 19899340cf74d98304f9f5b726c72e85c7017d72) --- diff --git a/src/liblzma/Makefile.am b/src/liblzma/Makefile.am index 1debf2d0..1a8ce76f 100644 --- a/src/liblzma/Makefile.am +++ b/src/liblzma/Makefile.am @@ -72,11 +72,15 @@ endif # static liblzma, we overwrite the static object file with an object file # compiled from empty input. Note that GNU-specific features are OK here, # because on Windows we are compiled with the GNU toolchain. +# +# The typedef in empty.c will prevent an empty translation unit, which is +# not allowed by the C standard. It results in a warning with +# -Wempty-translation-unit with Clang or -pedantic for GCC. .rc.lo: $(LIBTOOL) --mode=compile $(RC) $(DEFS) $(DEFAULT_INCLUDES) \ $(INCLUDES) $(liblzma_la_CPPFLAGS) $(CPPFLAGS) $(RCFLAGS) \ -i $< -o $@ - echo > empty.c + echo "typedef void empty;" > empty.c $(COMPILE) -c empty.c -o $(*D)/$(*F).o # Remove ordinals from the generated .def file. People must link by name,