A zig build file to compile BoringSSL's libcrypto
to WebAssembly/WASI.
For convenience, a precompiled library for WebAssembly can be directly downloaded from this repository.
The only required dependencies to rebuild the library are:
- Go - Required by BoringSSL to generate the error codes map
- Zig - To compile C/C++ code to WebAssembly
This repository includes an unmodified version of BoringSSL
as a submodule. If you didn't clone it with the --recursive
flag, the following command can be used to pull the submodule:
git submodule update --init --recursive --depth=1
Generic build for WebAssembly/WASI:
zig build -Doptimize=ReleaseFast
The resulting static library is put into zig-out/libcrypto.a
.
Build modes:
-Doptimize=ReleaseFast
-Doptimize=ReleaseSafe
-Doptimize-ReleaseSmall
(also turnsOPENSSL_SMALL
on to disable precomputed tables)-Doptimize=Debug
(default, not recommended in production builds)
The library is compatible with the vast majority of WebAssembly runtimes, and can be used linked with C, Zig, Rust, whatever.
Optimizations only compatible with some runtimes can be also enabled:
zig build -Dtarget=wasm32-wasi -Drelease-fast \
-Dcpu=generic+simd128+multivalue+bulk_memory
Possibly relevant extensions:
bulk_memory
exception_handling
multivalue
sign_ext
simd128
tail_call
The build file can be used to cross-compile to other targets as well. However, assembly implementations will not be included.
Compile to the native architecture:
zig build -Dtarget=native -Drelease-fast
Cross-compile to x86_64-linux
:
zig build -Dtarget=x86_64-linux -Drelease-small
Cross-compile to Apple Silicon:
zig build -Dtarget=aarch64-macos -Drelease-safe