diff options
| -rw-r--r-- | repo/packages/l/libcurl/xmake.lua | 2 | ||||
| -rw-r--r-- | repo/packages/m/mbedtls/patches/3.5.1/aesni-mingw-i386.patch | 68 | ||||
| -rw-r--r-- | repo/packages/m/mbedtls/xmake.lua | 77 | ||||
| -rw-r--r-- | src/zencore/xmake.lua | 2 | ||||
| -rw-r--r-- | src/zenhttp/xmake.lua | 19 | ||||
| -rw-r--r-- | thirdparty/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake.lua | 4 |
7 files changed, 152 insertions, 22 deletions
diff --git a/repo/packages/l/libcurl/xmake.lua b/repo/packages/l/libcurl/xmake.lua index 31ef9a418..a9dd2e686 100644 --- a/repo/packages/l/libcurl/xmake.lua +++ b/repo/packages/l/libcurl/xmake.lua @@ -21,7 +21,7 @@ package("libcurl") add_configs("cares", {description = "Enable c-ares support.", default = false, type = "boolean"}) add_configs("openssl", {description = "Enable OpenSSL for SSL/TLS.", default = nil, type = "boolean"}) add_configs("openssl3", {description = "Enable OpenSSL-3 for SSL/TLS.", default = nil, type = "boolean"}) - add_configs("mbedtls", {description = "Enable mbedTLS for SSL/TLS.", default = nil, type = "boolean"}) + add_configs("mbedtls", {description = "Enable mbedTLS for SSL/TLS.", default = true, type = "boolean"}) add_configs("nghttp2", {description = "Use Nghttp2 library.", default = false, type = "boolean"}) add_configs("openldap", {description = "Use OpenLDAP library.", default = false, type = "boolean"}) add_configs("libidn2", {description = "Use Libidn2 for IDN support.", default = false, type = "boolean"}) diff --git a/repo/packages/m/mbedtls/patches/3.5.1/aesni-mingw-i386.patch b/repo/packages/m/mbedtls/patches/3.5.1/aesni-mingw-i386.patch new file mode 100644 index 000000000..1085f4df3 --- /dev/null +++ b/repo/packages/m/mbedtls/patches/3.5.1/aesni-mingw-i386.patch @@ -0,0 +1,68 @@ +diff --git a/library/aesni.c b/library/aesni.c +index 59bcd3d92..b92c73c29 100644 +--- a/library/aesni.c ++++ b/library/aesni.c +@@ -21,14 +21,27 @@ + #if defined(MBEDTLS_AESNI_HAVE_CODE) + + #if MBEDTLS_AESNI_HAVE_CODE == 2 +-#if !defined(_WIN32) ++#if defined(__GNUC__) + #include <cpuid.h> +-#else ++#elif defined(_MSC_VER) + #include <intrin.h> ++#else ++#error "`__cpuid` required by MBEDTLS_AESNI_C is not supported by the compiler" + #endif + #include <immintrin.h> + #endif + ++#if defined(MBEDTLS_ARCH_IS_X86) ++#if defined(MBEDTLS_COMPILER_IS_GCC) ++#pragma GCC push_options ++#pragma GCC target ("pclmul,sse2,aes") ++#define MBEDTLS_POP_TARGET_PRAGMA ++#elif defined(__clang__) ++#pragma clang attribute push (__attribute__((target("pclmul,sse2,aes"))), apply_to=function) ++#define MBEDTLS_POP_TARGET_PRAGMA ++#endif ++#endif ++ + #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY) + /* + * AES-NI support detection routine +@@ -40,7 +53,7 @@ int mbedtls_aesni_has_support(unsigned int what) + + if (!done) { + #if MBEDTLS_AESNI_HAVE_CODE == 2 +- static unsigned info[4] = { 0, 0, 0, 0 }; ++ static int info[4] = { 0, 0, 0, 0 }; + #if defined(_MSC_VER) + __cpuid(info, 1); + #else +@@ -175,7 +188,7 @@ void mbedtls_aesni_gcm_mult(unsigned char c[16], + const unsigned char a[16], + const unsigned char b[16]) + { +- __m128i aa, bb, cc, dd; ++ __m128i aa = { 0 }, bb = { 0 }, cc, dd; + + /* The inputs are in big-endian order, so byte-reverse them */ + for (size_t i = 0; i < 16; i++) { +@@ -384,6 +397,15 @@ static void aesni_setkey_enc_256(unsigned char *rk_bytes, + } + #endif /* !MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */ + ++#if defined(MBEDTLS_POP_TARGET_PRAGMA) ++#if defined(__clang__) ++#pragma clang attribute pop ++#elif defined(__GNUC__) ++#pragma GCC pop_options ++#endif ++#undef MBEDTLS_POP_TARGET_PRAGMA ++#endif ++ + #else /* MBEDTLS_AESNI_HAVE_CODE == 1 */ + + #if defined(__has_feature) diff --git a/repo/packages/m/mbedtls/xmake.lua b/repo/packages/m/mbedtls/xmake.lua new file mode 100644 index 000000000..540a88f48 --- /dev/null +++ b/repo/packages/m/mbedtls/xmake.lua @@ -0,0 +1,77 @@ +package("mbedtls") + set_homepage("https://tls.mbed.org") + set_description("An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API") + set_license("Apache-2.0") + + add_urls("https://github.com/Mbed-TLS/mbedtls/releases/download/$(version).tar.bz2", {version = function (version) + if version:lt("3.6.1") then + return string.format("%s/mbedtls-%s", version, version:sub(2)) + else + return string.format("mbedtls-%s/mbedtls-%s", version:sub(2), version:sub(2)) + end + end}) + add_urls("https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/$(version).zip", {version = function (version) + return version:ge("v2.23.0") and version or ("mbedtls-" .. version:sub(2)) + end}) + add_urls("https://github.com/Mbed-TLS/mbedtls.git") + + add_versions("v3.6.1", "fc8bef0991b43629b7e5319de6f34f13359011105e08e3e16eed3a9fe6ffd3a3") + add_versions("v3.6.0", "3ecf94fcfdaacafb757786a01b7538a61750ebd85c4b024f56ff8ba1490fcd38") + add_versions("v3.5.1", "959a492721ba036afc21f04d1836d874f93ac124cf47cf62c9bcd3a753e49bdb") + add_versions("v3.4.0", "9969088c86eb89f6f0a131e699c46ff57058288410f2087bd0d308f65e9fccb5") + add_versions("v2.28.3", "0c0abbd6e33566c5c3c15af4fc19466c8edb62fa483d4ce98f1ba3f656656d2d") + add_versions("v2.25.0", "6bf01ef178925f7db3c9027344a50855b116f2defe4a24cbdc0220111a371597") + add_versions("v2.13.0", "6e747350bc13e8ff51799daa50f74230c6cd8e15977da55dd59f57b23dcf70a6") + add_versions("v2.7.6", "e527d828ab82650102ca8031302e5d4bc68ea887b2d84e43d3da2a80a9e5a2c8") + + add_patches("3.5.1", path.join(os.scriptdir(), "patches", "3.5.1", "aesni-mingw-i386.patch"), "4b5c5de69930049242cc1d6a84185881a936a27773ecaf975290ac591f38a41d") + + add_deps("cmake") + + add_links("mbedtls", "mbedx509", "mbedcrypto") + + if is_plat("windows", "mingw") then + add_syslinks("ws2_32", "advapi32", "bcrypt") + elseif is_plat("linux", "bsd") then + add_syslinks("pthread") + end + + on_install(function (package) + if package:config("shared") and package:is_plat("windows") then + io.replace("library/constant_time_impl.h", "extern volatile", "__declspec(dllimport) volatile", {plain = true}) + io.replace("include/mbedtls/x509_crt.h", "extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb;", "__declspec(dllimport) const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb;", {plain = true}) + io.replace("include/mbedtls/x509_crt.h", "extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default;", "__declspec(dllimport) const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default;", {plain = true}) + io.replace("library/psa_util_internal.h", "extern const mbedtls_error_pair_t psa_to_ssl_errors[7];", "__declspec(dllimport) const mbedtls_error_pair_t psa_to_ssl_errors[7];", {plain = true}) + end + + local configs = {"-DENABLE_TESTING=OFF", "-DENABLE_PROGRAMS=OFF", "-DMBEDTLS_FATAL_WARNINGS=OFF"} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + if package:config("shared") then + table.insert(configs, "-DUSE_SHARED_MBEDTLS_LIBRARY=ON") + table.insert(configs, "-DUSE_STATIC_MBEDTLS_LIBRARY=OFF") + if package:is_plat("windows") then + table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") + end + else + table.insert(configs, "-DUSE_SHARED_MBEDTLS_LIBRARY=OFF") + table.insert(configs, "-DUSE_STATIC_MBEDTLS_LIBRARY=ON") + end + + local cxflags + if package:is_plat("mingw") and package:is_arch("i386") then + cxflags = {"-maes", "-msse2", "-mpclmul"} + end + import("package.tools.cmake").install(package, configs, {cxflags = cxflags}) + end) + + on_test(function (package) + assert(package:has_cfuncs("mbedtls_ssl_init", {includes = "mbedtls/ssl.h"})) + assert(package:check_cxxsnippets({test = [[ + void test() { + mbedtls_aes_context ctx; + + unsigned char key[32]; + mbedtls_aes_setkey_enc(&ctx, key, 256); + } + ]]}, {includes = "mbedtls/aes.h"})) + end) diff --git a/src/zencore/xmake.lua b/src/zencore/xmake.lua index 26a6f0bdf..7ca3d3502 100644 --- a/src/zencore/xmake.lua +++ b/src/zencore/xmake.lua @@ -64,7 +64,7 @@ target('zencore') -- be specified after the former with GCC-like toolchains. xmake however -- is unaware of this and simply globs files from vcpkg's output. The -- line below forces breakpad_client to be to the right of sentry_native - add_syslinks("breakpad_client") + -- add_syslinks("breakpad_client") end if is_plat("macosx") then diff --git a/src/zenhttp/xmake.lua b/src/zenhttp/xmake.lua index 434330501..923e339d5 100644 --- a/src/zenhttp/xmake.lua +++ b/src/zenhttp/xmake.lua @@ -9,24 +9,9 @@ target('zenhttp') add_includedirs("include", {public=true}) add_deps("zencore", "zentelemetry", "transport-sdk", "asio", "cpr") add_deps("gsl-lite") - add_packages( - "curl", -- required by cpr - "http_parser" - ) + add_packages("http_parser") add_options("httpsys") if is_plat("linux") then - -- The 'vcpkg::openssl' package is two libraries; ssl and crypto, with - -- ssl being dependent on symbols in crypto. When GCC-like linkers read - -- object files from their command line, those object files only resolve - -- symbols of objects previously encountered. Thus crypto must appear - -- after ssl so it can fill out ssl's unresolved symbol table. Xmake's - -- vcpkg support is basic and works by parsing .list files. Openssl's - -- archives are listed alphabetically causing crypto to be _before_ ssl - -- and resulting in link errors. The links are restated here to force - -- xmake to use the correct order, and "syslinks" is used to force the - -- arguments to the end of the line (otherwise they can appear before - -- curl and cause more errors). - add_syslinks("crypto") - add_syslinks("dl") + add_syslinks("dl") -- TODO: is libdl needed? end diff --git a/thirdparty/xmake.lua b/thirdparty/xmake.lua index d7df0f623..9bce9f3b6 100644 --- a/thirdparty/xmake.lua +++ b/thirdparty/xmake.lua @@ -68,7 +68,7 @@ target('cpr') else add_cxxflags("-Wno-undef") end - add_packages("curl") + add_packages("libcurl", {public=true}) target('asio') set_kind('headeronly') @@ -11,7 +11,7 @@ add_requires("http_parser", {system = false}) add_requires("mimalloc", {system = false}) add_requires("eastl", {system = false}) add_requires("zlib", {system = false}) -add_requires("libcurl", {alias="curl", system = false, configs = {mbedtls = true}}) +add_requires("libcurl", {system = false}) add_defines("EASTL_STD_ITERATOR_CATEGORY_ENABLED", "EASTL_DEPRECATIONS_FOR_2024_APRIL=EA_DISABLED") @@ -41,7 +41,7 @@ end if has_config("zensentry") then if is_plat("linux") then - add_requires("sentry-native 0.5.4") + add_requires("sentry-native 0.7.6") else add_requires("sentry-native 0.7.6") -- matches vcpkg version (2024-06-15) end |