On Thu, Dec 17, 2020 at 02:47:49PM +0000, luca.boccassi@xxxxxxxxx wrote: > From: Luca Boccassi <luca.boccassi@xxxxxxxxxxxxx> > > Add some minimal compat type defs, and stub out the enable/measure > sources. Also add a way to handle the fact that mingw adds a > .exe extension automatically in the Makefile install rules, and > that there is not pkg-config and the libcrypto linker flag is > different. > > Signed-off-by: Luca Boccassi <luca.boccassi@xxxxxxxxxxxxx> > --- > v2: rework the stubbing out to detect mingw in the Makefile and remove > sources from compilation, instead of ifdefs. > add a new common/win32_defs.h for the compat definitions. > define strerror_r using strerror_s. > > To compile with mingw: > make CC=x86_64-w64-mingw32-gcc-8.3-win32 > note that the openssl headers and a win32 libcrypto.dll need > to be available in the default search paths, and otherwise have > to be specified as expected via CPPFLAGS/LDFLAGS > I got some warnings and an error when compiling: $ make CC=x86_64-w64-mingw32-gcc CC lib/compute_digest.o CC lib/hash_algs.o CC lib/sign_digest.o CC lib/utils.o lib/utils.c: In function ‘xmalloc’: lib/utils.c:25:25: warning: unknown conversion type character ‘l’ in format [-Wformat=] 25 | libfsverity_error_msg("out of memory (tried to allocate %" SIZET_PF " bytes)", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from lib/../common/win32_defs.h:24, from lib/../common/common_defs.h:18, from lib/lib_private.h:15, from lib/utils.c:14: /usr/x86_64-w64-mingw32/include/inttypes.h:36:18: note: format string is defined here 36 | #define PRIu64 "llu" | ^ lib/utils.c:25:25: warning: too many arguments for format [-Wformat-extra-args] 25 | libfsverity_error_msg("out of memory (tried to allocate %" SIZET_PF " bytes)", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AR libfsverity.a CC lib/compute_digest.shlib.o CC lib/hash_algs.shlib.o CC lib/sign_digest.shlib.o CC lib/utils.shlib.o lib/utils.c: In function ‘xmalloc’: lib/utils.c:25:25: warning: unknown conversion type character ‘l’ in format [-Wformat=] 25 | libfsverity_error_msg("out of memory (tried to allocate %" SIZET_PF " bytes)", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from lib/../common/win32_defs.h:24, from lib/../common/common_defs.h:18, from lib/lib_private.h:15, from lib/utils.c:14: /usr/x86_64-w64-mingw32/include/inttypes.h:36:18: note: format string is defined here 36 | #define PRIu64 "llu" | ^ lib/utils.c:25:25: warning: too many arguments for format [-Wformat-extra-args] 25 | libfsverity_error_msg("out of memory (tried to allocate %" SIZET_PF " bytes)", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CCLD libfsverity.so.0 /usr/lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -l:libcrypto.dll collect2: error: ld returned 1 exit status make: *** [Makefile:137: libfsverity.so.0] Error 1 This is on Arch Linux with mingw-w64-gcc and mingw-w64-openssl installed. So there's something wrong with the SIZET_PF format string, and also -l:libcrypto.dll isn't correct; it should be just -lcrypto like it is on Linux. (MinGW knows to look for a .dll file.) - Eric