Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
# emscripten lane emsdk and Node, which runs its programs, and a lane whose entry
# says external the libraries its libraries need, built with the lane's compilers.
# GCC 14 and Clang 18 run their b2 in a container with no network but the loopback,
# whose image is prepared separately and pulled by its immutable digest.
# whose image is prepared separately and pulled by its immutable digest. A lane, an
# own lane but OpenSSL's upstream suite and the lint restore the OpenSSL and
# libdatachannel configurations they built before, which b2 -a keeps, and save
# those their cache lacks (tools/ci/actions/third-party).
# own-lanes one job per own lane of a library and target it runs on, which runs the lane
# in every directory that declares it there. One that names no target, as an
# oracle, runs on Linux x86-64 with Clang 18, and with Node when it runs the
Expand Down Expand Up @@ -256,6 +259,14 @@ jobs:
- if: matrix.container
uses: ./tools/ci/actions/container

# The configurations of OpenSSL and libdatachannel this lane built before, which its b2 -a
# keeps; it saves those it builds that its cache does not hold.
- name: Restore the third-party builds
uses: ./tools/ci/actions/third-party
with:
step: restore
job: ${{ matrix.id }}

# The lane registers its toolset in .local/user-config.jam, prints its b2 command and runs
# it; Windows's Python is python.
- name: Lane
Expand All @@ -265,6 +276,13 @@ jobs:
PYTHON: ${{ runner.os == 'Windows' && 'python' || 'python3' }}
run: '"$PYTHON" tools/ci/matrix.py lane "$LANE"'

- name: Save the third-party builds
if: ${{ !cancelled() }}
uses: ./tools/ci/actions/third-party
with:
step: save
job: ${{ matrix.id }}

- name: Upload the lane's XML
if: always() && steps.lane.outputs.xml != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down Expand Up @@ -370,13 +388,29 @@ jobs:
python3 libs/beast/test/applications/inventory_test.py
python3 libs/beast/test/applications/driver_test.py

# As a lane's, except where the lane runs OpenSSL's upstream suite, which a configuration
# restored from the cache would not run again.
- name: Restore the third-party builds
if: ${{ !startsWith(matrix.lane, 'openssl-upstream') }}
uses: ./tools/ci/actions/third-party
with:
step: restore
job: own-${{ matrix.id || matrix.name }}

# It registers its toolset in .local/user-config.jam, prints its b2 command and runs it.
- name: Own lane
id: lane
env:
LANE: ${{ toJSON(matrix) }}
run: python3 tools/ci/matrix.py own-lane "$LANE"

- name: Save the third-party builds
if: ${{ !cancelled() && !startsWith(matrix.lane, 'openssl-upstream') }}
uses: ./tools/ci/actions/third-party
with:
step: save
job: own-${{ matrix.id || matrix.name }}

- name: Upload the lane's XML
if: always() && steps.lane.outputs.xml != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down Expand Up @@ -554,6 +588,14 @@ jobs:
# builds, with the toolset of that target: a WASI dry run generates the bindings its
# commands include, and an emscripten command is analysed with the sysroot of the cache the
# emsdk action restores.
#
# The configured headers of OpenSSL and libdatachannel, which each shard generates for its
# compilation database, come from the lint's cache, which the first shard saves.
- name: Restore the third-party headers
uses: ./tools/ci/actions/third-party
with:
step: restore
job: lint
- name: Lint
env:
SHARD: ${{ matrix.shard }}/${{ strategy.job-total }}
Expand All @@ -566,6 +608,12 @@ jobs:
python3 tools/ci/matrix.py register "${toolsets[@]}"
tools/lint/lint.sh --clang-format .local/wasi-sdk/bin/clang-format \
--clang-tidy .local/wasi-sdk/bin/clang-tidy --shard "$SHARD"
- name: Save the third-party headers
if: ${{ !cancelled() && matrix.shard == 1 }}
uses: ./tools/ci/actions/third-party
with:
step: save
job: lint

tools:
name: Tests of the tools (${{ matrix.shard }}/${{ strategy.job-total }})
Expand Down
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ Jamroot is its build configuration, and `libs/<name>` is its repository.
- for native or WASIp2/P3 guest TLS: Python 3, Perl, Make (nmake on Windows),
the selected compiler and `third_party/libs/openssl`, initialized with
`git submodule update --init third_party/libs/openssl`. B2 builds the pinned
OpenSSL sources and matching generated headers. Native Trystero's
OpenSSL sources and matching generated headers, each configuration once, in
`bin/third_party/openssl/config-<hash>`, which its inputs and its command
name and `b2 -a` keeps, as it does libdatachannel's: removing the directory
builds it again (`CODING-GUIDELINES.md` chapter 15). Native Trystero's
libdatachannel uses that same provider. Neither `OPENSSL_ROOT` nor
`LIBDATACHANNEL_ROOT` selects a separate installed copy. Source archives
contain the required sources and do not require Git for these builds.
Expand Down
16 changes: 16 additions & 0 deletions CODING-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7972,6 +7972,22 @@ The closure record distinguishes the baseline CI from validation of later change
archives for one configuration, two OpenSSL copies in one program.
Source: `docs/superpowers/plans/2026-10-16-openssl-source-build.md`,
`docs/superpowers/plans/2026-10-16-cobalt-ssl.md` (superproject).
- **Each configuration of OpenSSL and libdatachannel is built once, in
`bin/third_party/<name>/config-<hash>`, named by the bytes of its inputs
(its scripts and its pin) and by its build command, and never again, `b2 -a`
included: its outputs are `NOUPDATE`.** A directory that exists holds the
build of exactly those inputs and that command, so consumers whose
properties differ only in what the command leaves out, as
`exception-handling` for OpenSSL's C, share it, and the CI restores a lane's
directories from its cache (`tools/ci/actions/third-party`) and builds only
those the cache lacks. A consumer depends on the selection of its
configuration, `<name>-config-<hash>.selected` in its own variant directory,
which is written when the configuration changes, to a new one or back to one
built earlier, so the consumer is built again. Removing a configuration's
directory builds it again. A checkout that differs from its pin stops b2
before any build, by the library's own `check_checkout`.
Source: `tools/webcpp-third-party.jam`, `tools/third_party_build.py`
(superproject).
- **A dated curl export of Mozilla's root certificates (2026-09-25, 121 CAs)
is checked in under `third_party/ca_certificates`, with a manifest of its
URL, SHA-256 and DER fingerprints and its MPL-2.0 licence, verified and
Expand Down
4 changes: 3 additions & 1 deletion doc/releases/0.1.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ None.
== Tools and build

* Fixed emscripten release programs linking unoptimized; they now link at `-O3`.
* Fixed WASI release programs carrying wasi-sdk's libc++ debug information, most of their size; they now link with `--strip-debug`.
* Fixed WASI release programs carrying wasi-sdk's `libc++` debug information, most of their size; they now link with `--strip-debug`.
* Fixed clean CMake consumer audits rejecting system libraries and phony dependency rules.
* Changed CI to consume verified prepared environments without rebuilding images in PR jobs.
* Added verified archive caches and isolated container availability from unrelated CI lanes.
Expand Down Expand Up @@ -105,6 +105,8 @@ None.
* Added source-built OpenSSL and Cobalt SSL targets for WASIp2.
* Added explicit browser pthread profiles with main-thread handoff tests.
* Fixed the lint's clang-tidy stopping at Boost.Unordered on arm64 hosts.
* Changed OpenSSL and libdatachannel to build each configuration once, in a directory its inputs name, which b2 -a keeps.
* Added the CI's cache of the OpenSSL and libdatachannel builds, which a lane reuses until an input changes.
* Changed lint to verify WASIp3 ABI snapshots before excluding upstream headers.
* Fixed embedded CA headers using an unowned namespace and include path.
* Added source-built Boost.Context for native stackful coroutine applications.
Expand Down
26 changes: 16 additions & 10 deletions third_party/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,33 @@ alias bips : : <conditional>@bips-checked-out : :
explicit bips ;

# OpenSSL uses its upstream Configure/Make source manifest. The bridge emits
# static archives and matching generated headers in B2's variant directory.
# static archives and matching generated headers in the directory of their
# configuration, bin/third_party/openssl/config-<hash>, named by the bytes of
# the inputs below and the build command (tools/webcpp-third-party.jam).
import webcpp-openssl ;
.openssl-headers = [ glob libs/openssl/include/openssl/*.h ] ;
# OpenSSL's VMS prologue and epilogue, __DECC_INCLUDE_*.H, are no header of the
# install (tools/openssl/build.py leaves them out). b2's glob, which ignores
# case on Windows, would declare them outputs never made, which would generate
# the headers again on every run.
.openssl-headers = [ glob libs/openssl/include/openssl/*.h
: libs/openssl/include/openssl/__DECC_* ] ;
.openssl-templates = [ glob libs/openssl/include/openssl/*.h.in ] ;
webcpp-openssl.declare $(WEBCPP_ROOT)
: $(.openssl-headers:B).h $(.openssl-templates:B)
: ../tools/openssl/build.py ../tools/openssl/source.py ../tools/openssl/wasip3.conf
../tools/openssl/msvc.conf
../tools/openssl/pin.json [ glob-tree-ex libs/openssl : *.c *.h *.in *.pl *.pm *.t *.S *.s
*.conf *.num build.info Configure VERSION.dat *.tmpl : .git ] ;
: tools/openssl/build.py tools/openssl/source.py tools/openssl/wasip3.conf
tools/openssl/msvc.conf tools/openssl/pin.json ;
explicit openssl ;

# libdatachannel and its pinned nested dependencies use upstream CMake, with
# the exact OpenSSL archives above. Each archive reaches the program once.
# the exact OpenSSL archives above. Each archive reaches the program once. Its
# configurations are named as OpenSSL's are, by the bytes of the inputs below,
# the build command and OpenSSL's configuration.
import webcpp-libdatachannel ;
.libdatachannel-headers = [ glob libs/libdatachannel/include/rtc/*.hpp libs/libdatachannel/include/rtc/*.h ] ;
webcpp-libdatachannel.declare $(WEBCPP_ROOT)
: $(.libdatachannel-headers:BS)
: ../tools/libdatachannel/build.py ../tools/libdatachannel/source.py
../tools/libdatachannel/pin.json ../tools/libdatachannel/msvc.cmake
[ glob-tree-ex libs/libdatachannel : *.c *.cpp *.h *.hpp *.in *.cmake CMakeLists.txt : .git ] ;
: tools/libdatachannel/build.py tools/libdatachannel/source.py
tools/libdatachannel/pin.json tools/libdatachannel/msvc.cmake ;
explicit libdatachannel ;

# A dated, digest-pinned Mozilla/curl data export, not third-party source code.
Expand Down
71 changes: 71 additions & 0 deletions tools/ci/actions/third-party/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

name: Third-party builds
description: >-
Restores, before a job's b2, and saves, after it, the configurations of the source-built OpenSSL
and libdatachannel under bin/third_party, which B2 names by the bytes of their inputs and by
their build command and never builds again, b2 -a included (tools/webcpp-third-party.jam): a job
builds only the configurations its cache does not hold. The cache is the job's own, on its runner
image, and starts afresh when an input of those builds or a pinned toolchain changes. A job saves
it only when it built a configuration the cache did not hold, under the hash of the
configurations' names.

inputs:
step:
description: restore, before the job's b2, or save, after it.
required: true
job:
description: What keys the cache, such as the lane's id.
required: true

runs:
using: composite
steps:
- name: Cache key
id: key
shell: bash
env:
JOB: ${{ inputs.job }}
INPUTS: >-
${{ hashFiles('tools/openssl/build.py', 'tools/openssl/source.py',
'tools/openssl/pin.json', 'tools/openssl/msvc.conf', 'tools/openssl/wasip3.conf',
'tools/libdatachannel/build.py', 'tools/libdatachannel/source.py',
'tools/libdatachannel/pin.json', 'tools/libdatachannel/msvc.cmake',
'tools/third_party_build.py', 'tools/webcpp-third-party.jam', 'tools/webcpp-openssl.jam',
'tools/webcpp-libdatachannel.jam', 'tools/ci/actions/third-party/**',
'tools/ci/actions/gcc/**', 'tools/ci/actions/wasi-sdk/**', 'tools/ci/actions/emsdk/**',
'tools/ci/actions/container/**', 'tools/ci/container/**') }}
run: bash tools/ci/actions/third-party/key.sh

- name: Restore the third-party builds
id: restore
if: inputs.step == 'restore'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
bin/third_party/openssl
bin/third_party/libdatachannel
key: ${{ steps.key.outputs.prefix }}
restore-keys: ${{ steps.key.outputs.prefix }}

- name: Record the restored builds
if: inputs.step == 'restore'
shell: bash
env:
RESTORED: ${{ steps.restore.outputs.cache-matched-key }}
run: echo "WEBCPP_THIRD_PARTY_RESTORED=$RESTORED" >> "$GITHUB_ENV"

- name: Save the third-party builds
if: >-
inputs.step == 'save' && steps.key.outputs.built == 'true'
&& steps.key.outputs.key != env.WEBCPP_THIRD_PARTY_RESTORED
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
bin/third_party/openssl
bin/third_party/libdatachannel
key: ${{ steps.key.outputs.key }}
50 changes: 50 additions & 0 deletions tools/ci/actions/third-party/key.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

# The cache key of tools/ci/actions/third-party, which it computes before the job's b2, to
# restore, and after it, to save.
#
# Usage, from the superproject's root, with JOB, what keys the cache (such as the lane's id),
# INPUTS, the hash of the files the builds read, and the variables a runner sets (ImageOS,
# ImageVersion, GITHUB_OUTPUT):
#
# key.sh writes to GITHUB_OUTPUT the prefix, the job's cache on its runner image for those
# inputs, whose most recent entry a job restores; the key, the prefix and a hash of the
# names of the configurations under bin/third_party, under which a job saves them; and
# built, whether there is any.
#
# A checkout without bin/third_party, a fresh one or that of a job whose programs use neither
# library, has no configuration, and nothing to save. Bash 3.2, the macOS runners', runs it too.
set -euo pipefail

if [ -z "${JOB-}" ] || [ -z "${INPUTS-}" ]; then
printf 'usage: key.sh, with JOB and INPUTS set\n' >&2
exit 2
fi

here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# The functions every action shares: digest.
# shellcheck source=SCRIPTDIR/../../helpers.sh
. "${here}/../../helpers.sh"

# The runner image's compilers, and the job's: a key holds no comma, which a job's name may.
prefix="third-party-v1-${JOB//[^A-Za-z0-9._-]/-}-${ImageOS:-image}-${ImageVersion:-0}-"
prefix="${prefix}${INPUTS:0:16}-"

# The configurations' directories, of either library, whose own directory may not exist.
shopt -s nullglob
configurations=(bin/third_party/openssl/config-*/ bin/third_party/libdatachannel/config-*/)
# Given no file, digest hashes its standard input, as cat reads it.
# shellcheck disable=SC2119
names="$(printf '%s\n' ${configurations[@]+"${configurations[@]}"} | digest)"
built=false
if [ "${#configurations[@]}" -gt 0 ]; then
built=true
fi

printf 'prefix=%s\nkey=%s%s\nbuilt=%s\n' "${prefix}" "${prefix}" "${names:0:16}" "${built}" \
>> "${GITHUB_OUTPUT}"
Loading
Loading