Skip to content

jedisct1/boringssl-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoringSSL (boringcrypto) for WebAssembly

A zig build file to compile BoringSSL's libcrypto to WebAssembly/WASI.

Precompiled library

For convenience, a precompiled library for WebAssembly can be directly downloaded from this repository.

Dependencies

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

BoringSSL submodule

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

Building the BoringSSL crypto library for WebAssembly

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 turns OPENSSL_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

Cross-compiling to other targets

The build file can be used to cross-compile to other targets as well. However, assembly implementations will not be included.

Examples

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

Releases

No releases published

Packages

No packages published

Languages