From 4ed04478c1cc43ea6a91076047bf8b45605b0c5e Mon Sep 17 00:00:00 2001 From: torque Date: Thu, 31 Aug 2023 23:43:46 -0700 Subject: [PATCH] build.zig: address some Windows/Linux compilation issues A variety of linker issues (specifically missing symbol errors) don't show up with static libraries, so it was a bit hard to track this down without having something to link to. These have only been tested in cross-compilation setups, so there may still be lurking horrors. --- build.zig | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index 0f3bcd2..fe8b2e2 100644 --- a/build.zig +++ b/build.zig @@ -141,6 +141,7 @@ pub fn libresslBuild( libressl_libs.defineCMacro("HAVE_STRNDUP", null); libressl_libs.defineCMacro("HAVE_STRNLEN", null); libressl_libs.defineCMacro("HAVE_STRSEP", null); + libressl_libs.defineCMacro("HAVE_STRTONUM", null); libressl_libs.defineCMacro("HAVE_TIMEGM", null); libressl_libs.defineCMacro("HAVE_ARC4RANDOM_BUF", null); libressl_libs.defineCMacro("HAVE_ARC4RANDOM_UNIFORM", null); @@ -162,18 +163,16 @@ pub fn libresslBuild( libressl_libs.defineCMacro("_GNU_SOURCE", null); libressl_libs.defineCMacro("HAVE_ASPRINTF", null); - libressl_libs.defineCMacro("HAVE_REALLOCARRAY", null); + libressl_libs.defineCMacro("HAVE_STRCASECMP", null); libressl_libs.defineCMacro("HAVE_STRNDUP", null); libressl_libs.defineCMacro("HAVE_STRNLEN", null); - libressl_libs.defineCMacro("HAVE_STRNLEN", null); libressl_libs.defineCMacro("HAVE_STRSEP", null); libressl_libs.defineCMacro("HAVE_TIMEGM", null); libressl_libs.defineCMacro("HAVE_EXPLICIT_BZERO", null); libressl_libs.defineCMacro("HAVE_GETAUXVAL", null); - libressl_libs.defineCMacro("HAVE_GETENTROPY", null); libressl_libs.defineCMacro("HAVE_GETPAGESIZE", null); libressl_libs.defineCMacro("HAVE_SYSLOG", null); @@ -190,6 +189,7 @@ pub fn libresslBuild( libressl_libs.defineCMacro("HAVE_STRLCAT", null); libressl_libs.defineCMacro("HAVE_STRLCPY", null); + libressl_libs.defineCMacro("HAVE_GETENTROPY", null); } else @panic("weird ABI, dude"); libressl_libs.linkSystemLibrary("pthread"); @@ -216,6 +216,17 @@ pub fn libresslBuild( libressl_libs.defineCMacro("WIN32_LEAN_AND_MEAN", null); libressl_libs.defineCMacro("_WIN32_WINNT", "0x0600"); + libressl_libs.defineCMacro("HAVE_ASPRINTF", null); + libressl_libs.defineCMacro("HAVE_STRCASECMP", null); + libressl_libs.defineCMacro("HAVE_STRNLEN", null); + libressl_libs.defineCMacro("HAVE_GETAUXVAL", null); + + libressl_libs.defineCMacro("HAVE_TIMESPECSUB", null); + libressl_libs.defineCMacro("HAVE_MEMMEM", null); + libressl_libs.defineCMacro("HAVE_MACHINE_ENDIAN_H", null); + libressl_libs.defineCMacro("HAVE_ERR_H", null); + libressl_libs.defineCMacro("HAVE_NETINET_IP_H", null); + libressl_libs.linkSystemLibrary("ws2_32"); libressl_libs.linkSystemLibrary("bcrypt"); }, @@ -308,8 +319,8 @@ pub fn build(b: *std.Build) !void { // libressl_libs.defineCMacro("HAVE_STRLCPY", null); // libressl_libs.defineCMacro("HAVE_STRNDUP", null); // libressl_libs.defineCMacro("HAVE_STRNLEN", null); -// libressl_libs.defineCMacro("HAVE_STRNLEN", null); // libressl_libs.defineCMacro("HAVE_STRSEP", null); +// libressl_libs.defineCMacro("HAVE_STRTONUM", null); // libressl_libs.defineCMacro("HAVE_TIMEGM", null); // libressl_libs.defineCMacro("HAVE_ARC4RANDOM_BUF", null); // libressl_libs.defineCMacro("HAVE_ARC4RANDOM_UNIFORM", null); @@ -404,6 +415,7 @@ const libcrypto_macos_compat = [_][]const u8{ libcrypto_src_prefix ++ "compat/freezero.c", libcrypto_src_prefix ++ "compat/reallocarray.c", libcrypto_src_prefix ++ "compat/recallocarray.c", + libcrypto_src_prefix ++ "compat/syslog_r.c", libcrypto_src_prefix ++ "compat/explicit_bzero.c", libcrypto_src_prefix ++ "compat/timingsafe_bcmp.c", @@ -413,9 +425,16 @@ const libcrypto_macos_compat = [_][]const u8{ const libcrypto_linux_compat = [_][]const u8{ libcrypto_src_prefix ++ "compat/freezero.c", libcrypto_src_prefix ++ "compat/getprogname_linux.c", + + libcrypto_src_prefix ++ "compat/reallocarray.c", + libcrypto_src_prefix ++ "compat/recallocarray.c", + + libcrypto_src_prefix ++ "compat/strtonum.c", + libcrypto_src_prefix ++ "compat/syslog_r.c", + libcrypto_src_prefix ++ "compat/arc4random.c", libcrypto_src_prefix ++ "compat/arc4random_uniform.c", - libcrypto_src_prefix ++ "compat/syslog_r.c", + libcrypto_src_prefix ++ "compat/explicit_bzero.c", libcrypto_src_prefix ++ "compat/timingsafe_bcmp.c", libcrypto_src_prefix ++ "compat/timingsafe_memcmp.c", @@ -426,18 +445,33 @@ const libcrypto_linux_musl_compat = [_][]const u8{}; const libcrypto_linux_glibc_compat = [_][]const u8{ libcrypto_src_prefix ++ "compat/strlcat.c", libcrypto_src_prefix ++ "compat/strlcpy.c", + + libcrypto_src_prefix ++ "compat/getentropy_linux.c", }; const libcrypto_windows_compat = [_][]const u8{ libcrypto_src_prefix ++ "compat/freezero.c", libcrypto_src_prefix ++ "compat/getprogname_windows.c", + libcrypto_src_prefix ++ "compat/getpagesize.c", + libcrypto_src_prefix ++ "compat/reallocarray.c", libcrypto_src_prefix ++ "compat/recallocarray.c", + libcrypto_src_prefix ++ "compat/strlcat.c", + libcrypto_src_prefix ++ "compat/strlcpy.c", + libcrypto_src_prefix ++ "compat/strndup.c", + libcrypto_src_prefix ++ "compat/strsep.c", + libcrypto_src_prefix ++ "compat/strtonum.c", + libcrypto_src_prefix ++ "compat/syslog_r.c", + libcrypto_src_prefix ++ "compat/timegm.c", + libcrypto_src_prefix ++ "compat/explicit_bzero_win.c", libcrypto_src_prefix ++ "compat/getentropy_win.c", + libcrypto_src_prefix ++ "compat/arc4random.c", + libcrypto_src_prefix ++ "compat/arc4random_uniform.c", + libcrypto_src_prefix ++ "compat/timingsafe_bcmp.c", libcrypto_src_prefix ++ "compat/timingsafe_memcmp.c", };