Skip to content

Commit

Permalink
openssl3: Support wasm (#6037)
Browse files Browse the repository at this point in the history
* openssl: Support wasm

* fix find linux/version.h

* openssl: revert all

* openssl3: only wasm static config readonly

* fix configure
  • Loading branch information
star-hengxing authored Dec 24, 2024
1 parent 6b8cbc6 commit 5a47b59
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
14 changes: 14 additions & 0 deletions packages/o/openssl3/patches/3.3.2/command-line-length.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 8ddb128..52b9ad6 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -1961,7 +1961,7 @@ EOF
my @objs = map { platform->obj($_) } @{$args{objs}};
my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
- my $max_per_call = 500;
+ my $max_per_call = ($^O eq 'msys') ? 80 : 500;
my @objs_grouped;
push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
my $fill_lib =

23 changes: 19 additions & 4 deletions packages/o/openssl3/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ package("openssl3")
add_versions("3.0.1", "53d8121af1c33c62a05a5370e9ba40fcc237717b79a7d99009b0c00c79bd7d78")
add_versions("3.0.0", "1bdb33f131af75330de94475563c62d6908ac1c18586f7f4aa209b96b0bfc2f9")

-- https://github.com/microsoft/vcpkg/blob/11faa3f168ec2a2f77510b92a42fb5c8a7e28bd8/ports/openssl/command-line-length.patch
add_patches("3.3.2", path.join(os.scriptdir(), "patches/3.3.2/command-line-length.patch"), "e969153046f22d6abbdedce19191361f20edf3814b3ee47fb79a306967e03d81")

on_fetch("fetch")

-- https://security.stackexchange.com/questions/173425/how-do-i-calculate-md2-hash-with-openssl
add_configs("md2", {description = "Enable MD2 on OpenSSl3 or not", default = false, type = "boolean"})
if is_plat("cross", "android", "iphoneos", "wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end

on_load(function (package)
if not package:is_precompiled() then
Expand All @@ -34,7 +40,7 @@ package("openssl3")
if jom then
package:add("deps", "jom", {private = true})
end
elseif package:is_plat("android") and is_subhost("windows") and os.arch() == "x64" then
elseif package:is_plat("android", "wasm") and is_subhost("windows") and os.arch() == "x64" then
-- when building for android on windows, use msys2 perl instead of strawberry-perl to avoid configure issue
package:add("deps", "msys2", {configs = {msystem = "MINGW64", base_devel = true}, private = true})
end
Expand Down Expand Up @@ -154,7 +160,7 @@ package("openssl3")
end
end)

on_install("cross", "android", "iphoneos", function (package)
on_install("cross", "android", "iphoneos", "wasm", function (package)
local target_arch = "generic32"
if package:is_arch("x86_64") then
target_arch = "x86_64"
Expand Down Expand Up @@ -199,9 +205,15 @@ package("openssl3")
if package:config("md2") then
table.insert(configs, "enable-md2")
end
if package:is_plat("wasm") then
-- @see https://github.com/openssl/openssl/issues/12174
table.insert(configs, "no-afalgeng")
end

local buildenvs = import("package.tools.autoconf").buildenvs(package)
if package:is_cross() and package:is_plat("android") and is_subhost("windows") then
if (package:is_cross() and package:is_plat("android") and is_subhost("windows")) or
package:is_plat("wasm") then

buildenvs.CFLAGS = buildenvs.CFLAGS:gsub("\\", "/")
buildenvs.CXXFLAGS = buildenvs.CXXFLAGS:gsub("\\", "/")
buildenvs.CPPFLAGS = buildenvs.CPPFLAGS:gsub("\\", "/")
Expand All @@ -210,6 +222,10 @@ package("openssl3")
else
os.vrunv("./Configure", configs, {envs = buildenvs})
end

if is_host("windows") and package:is_plat("wasm") then
io.replace("Makefile", "bat.exe", "bat", {plain = true})
end
local makeconfigs = {CFLAGS = buildenvs.CFLAGS, ASFLAGS = buildenvs.ASFLAGS}
import("package.tools.make").build(package, makeconfigs)
import("package.tools.make").make(package, {"install_sw"})
Expand All @@ -218,4 +234,3 @@ package("openssl3")
on_test(function (package)
assert(package:has_cfuncs("SSL_new", {includes = "openssl/ssl.h"}))
end)

0 comments on commit 5a47b59

Please sign in to comment.