Skip to content

Build options

简体中文 · Reference

Package configs

Applications use PACE as an xmake package. This repository is also a package repository; each module is a config of the pace package, the way Boost's libraries are:

set_languages("cxx20")
add_rules("mode.debug", "mode.release")
add_repositories("pace https://github.com/TabNahida/PACE.git main")
add_requires("pace", {configs = {tls = true, http2 = true}})

target("app")
    set_kind("binary")
    add_files("main.cpp")
    add_packages("pace")
Config Default Effect
http_client true Unified URL calls and per-origin pooling when any HTTP protocol is enabled
http1 true HTTP/1.0 and HTTP/1.1, http::app and the gateway services
websocket true WebSocket
tls false TLS streams; also adds the TLS forms of HTTP/1, HTTP/2 and WebSocket
native_tls false PACE TLS 1.2/1.3 and ECH; with dns, DNS over TLS
dns false Native asynchronous DNS; the URL clients then resolve host names
quic false QUIC
quic_backend "ngtcp2" "ngtcp2", "openssl" or "native"; Windows needs "native"
http2 false HTTP/2 with nghttp2
http3 false HTTP/3 with nghttp3; turns QUIC on
crypto "openssl" "openssl" or "aws-lc"
certificate_compression "none" "zlib" or "brotli" for native TLS 1.3
uring false Linux io_uring readiness backend
modules false C++ named modules
profiling false Intrusive per-thread stage timings

add_packages("pace") supplies the include path, the PACE_HAS_<MODULE> definitions, the libraries in link order and the system libraries. The package installs one static library per enabled module (libpace_http1.a and so on, as Boost installs libboost_*); applications never name them. add_requires("pace 1.0.0-alpha.5", …) pins a release. The recipe is packages/p/pace/xmake.lua, and the package workflow installs every commit through it on Linux, macOS and Windows. xmake's own repository still serves the 0.6 releases; the 1.0 recipe moves there once the API is frozen.

The rest of this page covers building PACE from a source checkout: working on PACE, its tests, examples and benchmarks.

Overview

PACE builds with xmake 2.9.8 or newer (CI uses 3.0.9 and 3.1.1). Options are set with xmake f and kept until the next xmake f; -c clears the previous configuration first. The library options have the same names as the package configs.

xmake f -c -m release --tls=y --http2=y -y
xmake -y
xmake test -v

The build is described in these files:

File Contents
xmake.lua Project, language standard, the Windows QUIC check, sanitizer and fuzz flags, the includes below
xmake/options.lua The library options
xmake/packages.lua Pinned third-party packages
xmake/targets.lua One library target per module, and the aggregate pace
xmake/modules.lua The C++ named module target pace_module
xmake/checks.lua The header self-containment check
xmake/tests.lua, examples.lua, benchmarks.lua, fuzz.lua Tests, examples, benchmarks and fuzzers, each with its own options

Build modes are debug, release and releasedbg (-m). The runtime and networking modules need no third-party library; each optional module adds only its own packages.

Library options

Option Default Effect
--http_client=y/n y Build the unified HTTP client
--http1=y/n y HTTP/1.0 and HTTP/1.1 module, including http::app and the gateway services (pace_http1)
--websocket=y/n y WebSocket module (pace_websocket)
--tls=y/n n TLS and HTTPS with OpenSSL (pace_tls); also adds the TLS forms of HTTP/1, HTTP/2 and WebSocket
--native_tls=y/n n Native TLS 1.2/1.3 (pace_tls_native). With --dns=y, also enables DNS over TLS
--dns=y/n n Asynchronous native DNS (pace_dns); the URL clients then resolve host names
--quic=y/n n QUIC (pace_quic)
--quic_backend=ngtcp2/openssl/native ngtcp2 Select ngtcp2, OpenSSL QUIC, or the PACE transport with PACE TLS 1.3
--http2=y/n n HTTP/2 with nghttp2 (pace_http2); HTTPS needs --tls=y as well
--http3=y/n n HTTP/3 with nghttp3 (pace_http3); turns QUIC on
--cxxstandard=cxx20/cxx23/cxxlatest cxx20 C++ language standard
--modules=y/n n Build the C++ named modules (pace_module)
--sanitizers=y/n n AddressSanitizer and UndefinedBehaviorSanitizer
--profiling=y/n n Intrusive per-thread stage timings, for diagnostics only
--uring=y/n n Linux io_uring readiness backend (liburing)
--fuzz=none/libfuzzer/replay none Fuzz targets
--header_check=y/n n Compile every public header on its own

Each enabled module defines PACE_HAS_<MODULE> (PACE_HAS_HTTP1, PACE_HAS_WEBSOCKET, PACE_HAS_TLS, PACE_HAS_DNS, PACE_HAS_QUIC, PACE_HAS_HTTP2, PACE_HAS_HTTP3) for every target that depends on it; the ngtcp2 backend also defines PACE_QUIC_NGTCP2, and the native backend defines PACE_QUIC_NATIVE. Do not define these macros yourself: they must come from the build of the library. Combining --dns=y and --native_tls=y enables PACE_HAS_DNS_ENCRYPTED for consumers of pace_dns_encrypted or pace. This combination supports both OpenSSL and AWS-LC crypto providers. DNS over TLS reference

On Windows or MinGW, select --quic_backend=native with --quic=y or --http3=y. The native engine enables PACE TLS 1.3 and uses the selected --crypto=openssl/aws-lc provider. See platform support.

To build only the runtime and networking, turn off the modules that are on by default:

xmake f -c -m release --http1=n --websocket=n -y

To build everything:

xmake f -c -m release --tls=y --dns=y --quic=y --http2=y --http3=y -y

Packages

xmake fetches these pinned versions the first time an option needs them, which can need network access:

Package Version Needed by
OpenSSL 3.5.7 --tls, --quic, --http3
ngtcp2 1.26.0 --quic / --http3 with --quic_backend=ngtcp2
nghttp2 1.70.0 --http2
nghttp3 1.18.0 --http3
liburing 2.12 --uring on Linux
doctest 2.5.3 --tests (test executables only)
Asio, libuv 1.34.2, 1.52.1 --benchmarks (comparison benchmarks only)

Windows ARM64 and FreeBSD use repository-local package definitions for OpenSSL and ngtcp2 respectively (packages/p/pace-openssl3-arm64/xmake.lua, packages/p/pace-ngtcp2-bsd/xmake.lua); see Windows ARM64 OpenSSL.

Targets

These are the targets of a source build. Package users link add_packages("pace") and never name them.

Target Kind Contents Depends on Packages
pace_runtime static Tasks, io_context, timers, cancellation, structured concurrency, workers — liburing with --uring
pace_net static TCP, UDP, addresses, stream helpers pace_runtime —
pace_http header-only HTTP messages and router pace_runtime —
pace_tls static TLS streams pace_net OpenSSL
pace_dns static DNS resolver pace_net —
pace_dns_encrypted static DNS over TLS client pace_dns, pace_tls_native —
pace_quic static QUIC (one backend) pace_net Native uses pace_tls_native and pace_crypto. The other backends use OpenSSL and optionally ngtcp2
pace_http1 static HTTP/1, http::app, gateway pace_net, pace_http, and pace_tls, pace_dns when enabled —
pace_http2 static HTTP/2 pace_net, pace_http, and pace_tls, pace_dns when enabled nghttp2
pace_http3 static HTTP/3 pace_net, pace_http, pace_quic, and pace_dns when enabled nghttp3
pace_websocket static WebSocket pace_net, and pace_tls when enabled —
pace header-only Every enabled module, and <pace/pace.hpp> all of the above that are enabled —
pace_module static C++ named modules (with --modules=y) pace —

A module target compiles only src/<module>/, installs only its own headers (include/pace/<module>/ and the umbrella <pace/<module>.hpp>) and links only the modules and packages it needs. xmake build pace_tls builds the runtime, networking and TLS and nothing else. Selecting pace_net never links OpenSSL or HTTP code, even when another target in the same project enables them. There is no single libpace.a: a manual link line must name each module it uses and their dependencies.

Dependencies are public: a target that depends on a module inherits its include paths, defines, packages and system libraries (pthread on POSIX; ws2_32 and bcrypt on Windows).

Depending on one module from source

Inside this repository (tests, examples, benchmarks), or in a project that includes the checkout, depend on the narrowest target you use and include its umbrella header:

target("my_application")
    set_kind("binary")
    add_files("main.cpp")
    add_deps("pace_http2")       -- or "pace" for every enabled module
#include <pace/http2.hpp>        // or <pace/pace.hpp> for every enabled module

The module must be enabled when configuring (--http2=y here). To build PACE as part of another xmake project instead of installing the package, keep its checkout in your tree and include its root file, which loads its own build files and keeps its paths anchored to the checkout:

set_project("my_pace_application")
set_languages("cxx20")
add_rules("mode.debug", "mode.release")

includes("third_party/PACE")

target("my_application")
    set_kind("binary")
    add_files("main.cpp")
    add_deps("pace")

Configure --tests=n --examples=n when you need only the libraries. The library is C++ ABI code, not a stable C ABI: build it with the same toolchain and options (including profiling) as the application.

Independent configurations

xmake keeps one configuration per project directory. -o <dir> only changes where outputs go. For several configurations side by side, give each its own XMAKE_CONFIGDIR and use it for every command:

export XMAKE_CONFIGDIR="$PWD/build/core-config"
xmake f -c -m release -o build/core --http1=n --websocket=n -y
xmake -y
xmake test -v

Unset XMAKE_CONFIGDIR to return to the default configuration.

C++ named modules

--modules=y builds pace_module, which provides one named module per library module: pace.runtime, pace.net, pace.http, pace.http1, pace.gateway, pace.tls, pace.dns, pace.quic, pace.http2, pace.http3, pace.websocket, and pace for all of them. Each module exports only its own names, so a program that uses TCP imports both:

import pace.runtime;
import pace.net;

import pace; is the equivalent of #include <pace/pace.hpp>. A module whose library is disabled still exists and exports nothing. The module interfaces in modules/ are generated from modules/exports.json by scripts/generate_modules.py. They wrap the ordinary headers and libraries, so module and header consumers share one ABI and can be mixed in one program.

Depend on pace_module instead of pace. As a package, set modules = true and enable module scanning for the target that imports PACE; the package carries every interface file:

add_requires("pace", {configs = {modules = true}})

target("app")
    set_kind("binary")
    add_files("main.cpp")
    add_packages("pace")
    set_policy("build.c++.modules", true)

Named modules need Clang (CI uses Clang 18 and 21) or GCC 16 or newer; GCC 15 and older stop with an error, because of a compiler defect with coroutines in modules. Headers remain the primary interface; the default build never runs a module scanner.

Header self-containment check

--header_check=y adds pace_header_check, which compiles every header under include/pace/ in its own translation unit, so a header that relies on an include it does not make fails here rather than in a consumer. Headers of disabled modules compile to nothing. Build it with every module enabled:

xmake f -c -m release -o build/hc --tls=y --dns=y --quic=y --http2=y --http3=y --header_check=y -y
xmake -y

CI also builds each module on its own with the check enabled, which catches a module that silently relies on another one.

Sanitizers

--sanitizers=y compiles and links every target, the libraries included, with -fsanitize=address,undefined -fno-omit-frame-pointer. It has no effect on the windows (MSVC) platform. Use a debug build and make failures fatal:

xmake f -c -m debug -o build/asan --sanitizers=y -y
xmake -y
ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 UBSAN_OPTIONS=halt_on_error=1 xmake test -v

Profiling

--profiling=y defines PACE_ENABLE_PROFILING for pace_runtime and everything that depends on it, and records per-thread stage timings. It adds overhead: use a separate build directory, and keep it off for performance comparisons. Applications must be built with the same setting as the library.

io_uring

--uring=y on Linux links liburing into pace_runtime and defines PACE_HAS_IO_URING. On other platforms the option does nothing. Enabling it does not change the default backend, which stays epoll: select io_uring with PACE_IO_BACKEND=io_uring or an explicit io_context constructor argument. See I/O backends.

Fuzzing

--fuzz=libfuzzer (Clang with libFuzzer) builds fuzz targets for the HTTP/1 server and client parsers and the WebSocket server, and instruments the library code with ASan and UBSan as well. --fuzz=replay builds the same targets with a small driver that replays input files, so any toolchain can run the corpus as a regression test. In both modes xmake test replays the seed corpus in tests/fuzz/corpus/.

xmake f -c -m debug -o build/fuzz --toolchain=clang --fuzz=libfuzzer -y
xmake -y
xmake run pace_fuzz_http1_server tests/fuzz/corpus/http1_server

Tests, examples and benchmarks

Option Default Builds
--tests=y/n y doctest executables (pace_*_tests) for the enabled modules, and pace_interop_server for external interop peers
--examples=y/n y echo_server, http_server and the tutorial_* programs of the enabled modules; with --tests=y the tutorials also run as tests
--benchmarks=y/n n TCP comparison against standalone Asio and libuv (pace_bench)
--components=y/n n PACE component microbenchmarks
--scaling=y/n n Worker-count and execution-mode scaling benchmarks
--protocol_benchmarks=y/n n HTTP, WebSocket and protocol probes for the enabled modules

xmake test -v runs every test executable and tutorial that was built. Benchmark methodology is in performance.

See also