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
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,11 @@ wrapper each quoted as one word of Jam.
action before it is cached. It refuses an empty or relative prefix: b2 given
an empty `--prefix` installs into `/usr/local`. `install.sh source <dir>`
fills such a tree alone, for a machine whose Boost comes from elsewhere.
Every tree it extracts gets the patches of `tools/ci/actions/boost/patches`
first, with `git apply` (`CODING-GUIDELINES.md` chapter 14, the build):
one that does not apply, or that the archive holds already, fails the
action naming it, the patches are part of the cache key, and a prefix whose
headers lack one is refused.
- `wasi-sdk` installs wasi-sdk 34 into `.local/wasi-sdk`: the runner's
build of its clang and tools, with the release's platform-independent
`wasi-sysroot-34.0` and `libclang_rt-34.0` in place of that build's
Expand Down
18 changes: 18 additions & 0 deletions CODING-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,24 @@ site's own decisions follow in the next sections.
(Homebrew's has no `libs/url/src`).
Source: `organization/openspec/changes/archive/2026-10-07-genesis/design.md`
(proposals).
- **The Boost that the CI provisions, `tools/ci/actions/boost`, is patched in
one place: each file of `tools/ci/actions/boost/patches` is a `git apply`
patch of Boost's headers, against the archive's root, that `install.sh`
applies to every tree it extracts, before anything is installed or kept
from it, for every job, MSVC lanes, docs and lint included.** A patch
corrects a Boost defect that blocks a lane until a Boost release fixes it,
and its opening paragraph names the upstream change. It is removed, never
skipped: one that no longer applies, or that the archive already holds,
fails `install.sh` naming it, and a cached prefix whose headers lack one is
refused. Library-specific corrections stay with their library (Cobalt's
`upstream/` bundles, applied by its maintainer import into shipped sources),
and a user's build with their own Boost gets no patch: the defect stays
theirs until the release. The first is
`hash2-mul128-msvc-arm64.patch`, Boost 1.92.0's `mul128.hpp` that MSVC for
ARM64 rejects (C2601) wherever `boost/hash2/xxh3.hpp` is included, fixed
upstream by https://github.com/boostorg/hash2/pull/49; the owner approved
carrying it on 2026-11-22.
Source: `tools/ci/actions/boost/install.sh` (webcpp).
- **Boost.JSON's definitions and Boost.Test's header-only framework are
objects of webcpp's own build, `/webcpp//boost_json` and
`tools/boost_test_runner.cpp`.** Boost.JSON is built once per variant, so
Expand Down
77 changes: 72 additions & 5 deletions tools/ci/actions/boost/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
# The headers are installed, and beside them, in <prefix>/source, the sources of Boost's compiled
# libraries, from which webcpp builds those it needs (the Jamroot's /webcpp//boost_url,
# boost_charconv and boost_locale; libs/cobalt ships its own sources).
#
# Before anything is kept or installed from it, every tree install.sh extracts gets the patches of
# patches/, each a git diff of Boost's headers (paths under boost/) against the archive's root,
# that corrects a defect of this Boost until a release fixes it upstream; its opening paragraph
# names the upstream change. A patch that no longer applies, as when a new Boost holds the fix,
# fails install.sh, naming it, so that it is removed rather than skipped; and a prefix whose
# headers lack one of them fails check.
set -euo pipefail

version=1.92.0
Expand All @@ -38,6 +45,51 @@ here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=SCRIPTDIR/../../helpers.sh
. "${here}/../../helpers.sh"

# The patches every extracted tree gets (patches/, above), in the order of their names.
patches() {
local patch
for patch in "${here}"/patches/*.patch; do
[ -f "${patch}" ] && printf '%s\n' "${patch}"
done
return 0
}

# Runs git apply with the rest of the arguments in tree. git looks for no repository above tree:
# in one, it would read the patch's paths from that repository's root and skip, without a word,
# those outside tree.
apply_in() {
local tree="$1"
shift
GIT_CEILING_DIRECTORIES="$(dirname "${tree}")" git -C "${tree}" apply "$@"
}

# Applies every patch to the tree of Boost's archive, and fails, naming the patch, on one that
# touches something other than Boost's headers, on one that is applied already (the archive holds
# the fix: remove the patch) and on one that does not apply (update or remove it).
patch_tree() {
local tree="$1" patch name
while IFS= read -r patch; do
name="tools/ci/actions/boost/patches/$(basename "${patch}")"
if grep -E '^(\+\+\+|---) ' "${patch}" | grep -qvE '^(\+\+\+ b|--- a)/boost/'; then
printf 'install.sh: %s patches a file outside boost/, the headers\n' "${name}" >&2
exit 1
fi
if apply_in "${tree}" --check "${patch}" 2>/dev/null; then
apply_in "${tree}" "${patch}"
printf 'install.sh: applied %s\n' "${name}"
elif apply_in "${tree}" --reverse --check "${patch}" 2>/dev/null; then
printf 'install.sh: Boost %s holds the change of %s already: remove the patch\n' \
"${version}" "${name}" >&2
exit 1
else
printf 'install.sh: %s does not apply to Boost %s: update it, or remove it %s\n' \
"${name}" "${version}" 'if this Boost holds the fix it names' >&2
apply_in "${tree}" --check "${patch}" || true
exit 1
fi
done < <(patches)
}

# The file that install.sh writes last into a tree of Boost's sources it made, with the version
# and the archive's SHA-256: the one sign that a directory is such a tree, which it may replace.
marker=.webcpp-boost-source
Expand Down Expand Up @@ -103,6 +155,7 @@ source_tree() {
made+=("${work}")
"${here}/../../download.sh" "${url}" "${sha256}" "${work}/${archive}"
tar -xzf "${work}/${archive}" -C "${work}"
patch_tree "${work}/boost_${version//./_}"
keep_sources "${work}/boost_${version//./_}" "${directory}"
}

Expand All @@ -118,9 +171,13 @@ key() {
macOS) image="macos-$(sw_vers -productVersion | cut -d . -f 1)" ;;
*) image="${ImageOS:-windows}" ;;
esac
local files
files="$(digest "${here}/action.yml" "${here}/install.sh" "${here}/../../download.sh" \
"${here}/../../helpers.sh")"
local files patch
local inputs=("${here}/action.yml" "${here}/install.sh" "${here}/../../download.sh"
"${here}/../../helpers.sh")
while IFS= read -r patch; do
inputs+=("${patch}")
done < <(patches)
files="$(digest "${inputs[@]}")"
printf 'prefix=%s\n' "$(mixed "${RUNNER_TEMP}")/boost-${version}" >> "${GITHUB_OUTPUT}"
printf 'key=boost-%s-%s-%s-%s\n' "${version}" "${image}" "${RUNNER_ARCH}" \
"${files:0:16}" >> "${GITHUB_OUTPUT}"
Expand All @@ -146,6 +203,7 @@ install() {
fi
rm "${archive}"
cd "boost_${version//./_}"
patch_tree "$(pwd)"
keep_sources "$(pwd)" "${prefix}/source"
local b2=./b2
if [ "${RUNNER_OS}" = Windows ]; then
Expand Down Expand Up @@ -175,8 +233,9 @@ install() {
# Whether prefix holds what configure uses: Boost's headers in <prefix>/include/boost, b2 in
# <prefix>/bin, and in <prefix>/source the tree keep_sources writes for this archive (its marker
# names the archive's SHA-256) with the sources of each compiled library the Jamroot builds
# (tools/boost/Jamfile). So a prefix cached before it kept them, or before it kept one of them, is
# refused here, and not at the first build that needs them.
# (tools/boost/Jamfile), and headers that hold every patch of patches/. So a prefix cached before
# it kept them, before it kept one of them, or before a patch was added, is refused here, and not
# at the first build that needs them.
check() {
local prefix="$1"
local b2="${prefix}/bin/b2"
Expand All @@ -197,6 +256,14 @@ check() {
printf 'install.sh: %s holds no Boost headers, no b2 or no sources\n' "${prefix}" >&2
exit 1
fi
local patch
while IFS= read -r patch; do
if ! apply_in "${prefix}/include" --reverse --check "${patch}" 2>/dev/null; then
printf 'install.sh: the Boost headers of %s lack %s\n' "${prefix}" \
"tools/ci/actions/boost/patches/$(basename "${patch}")" >&2
exit 1
fi
done < <(patches)
}

configure() {
Expand Down
20 changes: 20 additions & 0 deletions tools/ci/actions/boost/patches/hash2-mul128-msvc-arm64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Boost 1.92.0's boost/hash2/detail/mul128.hpp repeats, in the
`#elif defined(_M_ARM64) || defined(_M_ARM64EC)` branch of mul128, the first two lines of
mul128_impl's definition, its signature and its opening brace, so that MSVC for ARM64 stops with
C2601 (local function definitions are illegal) in every translation unit that includes
boost/hash2/xxh3.hpp. This patch removes the two lines, as the upstream fix does:
https://github.com/boostorg/hash2/pull/49. Remove this file once the Boost that
tools/ci/actions/boost/install.sh pins contains that fix: install.sh then fails, saying so.

diff --git a/boost/hash2/detail/mul128.hpp b/boost/hash2/detail/mul128.hpp
--- a/boost/hash2/detail/mul128.hpp
+++ b/boost/hash2/detail/mul128.hpp
@@ -71,8 +71,6 @@ BOOST_CXX14_CONSTEXPR inline uint128 mul128( std::uint64_t x, std::uint64_t y )

#elif defined(_M_ARM64) || defined(_M_ARM64EC)

-BOOST_CXX14_CONSTEXPR inline uint128 mul128_impl( std::uint64_t x, std::uint64_t y ) noexcept
-{
if( !detail::is_constant_evaluated() )
{
uint128 r = { 0, 0 };
132 changes: 127 additions & 5 deletions tools/ci/actions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
b2 in <prefix> itself and the headers in <prefix>/include/boost-1_92, keeps in <prefix>/source the
archive's boost/version.hpp and every libs/<library>/src, which configure names in
user-config.jam, and fails, before the prefix is cached, when the prefix holds no headers, no b2 or
no sources after the install; its source step fills a directory with the same tree alone, and
no sources after the install; it installs the headers with every patch of its patches/ applied,
also in a tree inside a git repository, keys its cache on them, fails, naming the patch, on one
that the archive holds already, one that does not apply and one outside the headers, and configure
refuses a prefix whose headers lack one; each patch names its upstream fix; its source step fills
a directory with the same tree alone, and
the marker it writes last, in place of a tree whose marker says the action wrote it, refuses any
other directory before it downloads anything, and leaves the tree as it was and nothing behind
when it fails. The wit-bindgen action
Expand Down Expand Up @@ -219,8 +223,9 @@ def test_boost_refuses_an_empty_or_relative_prefix(scratch: Path) -> None:
# <prefix>/include/boost-1_92/boost, and b2's Jamroot to the portable layout, which puts b2 in
# --prefix and ignores --bindir; the system and standard layouts, the defaults elsewhere, put them
# in <prefix>/include/boost and --bindir. The stand-in takes Windows's defaults, so that only an
# install that names both layouts finds the headers and b2 where configure looks for them. With
# STAND_IN_INSTALLS_NOTHING set, it installs nothing and succeeds.
# install that names both layouts finds the headers and b2 where configure looks for them. It
# installs the headers of the tree it runs in. With STAND_IN_INSTALLS_NOTHING set, it installs
# nothing and succeeds.
FAKE_B2 = r'''#!/usr/bin/env bash
set -euo pipefail
prefix='' bindir='' layout=portable headers=boost-1_92
Expand All @@ -236,8 +241,8 @@ def test_boost_refuses_an_empty_or_relative_prefix(scratch: Path) -> None:
if [ -n "${STAND_IN_INSTALLS_NOTHING-}" ]; then
exit 0
elif [ -z "$bindir" ]; then
mkdir -p "$prefix/include/$headers/boost"
echo '#define BOOST_VERSION 109200' > "$prefix/include/$headers/boost/version.hpp"
mkdir -p "$prefix/include/$headers"
cp -R boost "$prefix/include/$headers/boost"
elif [ "$layout" = standard ]; then
mkdir -p "$bindir" && cp "$0" "$bindir/b2"
else
Expand All @@ -246,11 +251,39 @@ def test_boost_refuses_an_empty_or_relative_prefix(scratch: Path) -> None:
'''


# A header of the stand-in archive with a defect, its two lines repeated, and the patch that
# removes them, as tools/ci/actions/boost/patches holds one.
DEFECT = 'int f()\n{\nint f()\n{\n return 0;\n}\n'
FIXED = 'int f()\n{\n return 0;\n}\n'
DEFECT_PATCH = '''The stand-in defect, fixed upstream by https://github.com/boostorg/example/pull/1.

diff --git a/boost/defect.hpp b/boost/defect.hpp
--- a/boost/defect.hpp
+++ b/boost/defect.hpp
@@ -1,6 +1,4 @@
int f()
{
-int f()
-{
return 0;
}
'''


def boost_patches(scratch: Path, patch: str = DEFECT_PATCH) -> Path:
"""tools/ci/actions/boost/patches of the scratch superproject, with patch in it."""
patches = scratch / 'tools/ci/actions/boost/patches'
patches.mkdir()
(patches / 'defect.patch').write_text(patch)
return patches / 'defect.patch'


def boost_archive(scratch: Path) -> Path:
"""A boost_1_92_0.tar.gz whose bootstrap.sh writes the stand-in b2."""
tree = scratch / 'archive/boost_1_92_0'
(tree / 'tools/build').mkdir(parents=True)
for path, text in (('boost/version.hpp', '#define BOOST_VERSION 109200\n'),
('boost/defect.hpp', DEFECT),
('libs/url/src/url.cpp', '// url\n'),
('libs/url/src/detail/pattern.hpp', '// pattern\n'),
('libs/json/src/src.cpp', '// json\n'),
Expand Down Expand Up @@ -464,6 +497,91 @@ def test_boost_source_that_fails_leaves_the_tree_and_no_files(scratch: Path) ->
assert list(temp.iterdir()) == [], (how, list(temp.iterdir()))


def test_boost_installs_patched_headers(scratch: Path) -> None:
# The tree is patched before its headers are installed, also where it lies inside a git
# repository, whose root git apply would otherwise read the patch's paths from, skipping
# them without a word; and configure accepts the prefix.
script, runner = boost_install_tree(scratch)
boost_patches(scratch)
subprocess.run(['git', 'init', '-q', str(scratch)], check=True)
prefix = scratch / 'prefix'
result = run(script, 'install', prefix, env=runner)
assert result.returncode == 0, (result.returncode, result.stdout, result.stderr)
assert 'install.sh: applied tools/ci/actions/boost/patches/defect.patch' in result.stdout, (
result.stdout)
assert (prefix / 'include/boost/defect.hpp').read_text() == FIXED
result = subprocess.run(['bash', str(script), 'configure', str(prefix)], capture_output=True,
text=True, check=False, cwd=scratch, env={**os.environ, **runner})
assert result.returncode == 0, (result.returncode, result.stderr)
# A prefix whose headers lack a patch, one cached before it was added, is refused.
(prefix / 'include/boost/defect.hpp').write_text(DEFECT)
result = subprocess.run(['bash', str(script), 'configure', str(prefix)], capture_output=True,
text=True, check=False, cwd=scratch, env={**os.environ, **runner})
assert result.returncode == 1, (result.returncode, result.stderr)
assert (f'install.sh: the Boost headers of {prefix} lack '
'tools/ci/actions/boost/patches/defect.patch') in result.stderr, result.stderr


def test_boost_key_changes_with_the_patches(scratch: Path) -> None:
# A digest of the action's files, of the patches with them, keys the cached prefix: a patch
# added or changed installs Boost again.
script = boost_tree(scratch)
shutil.copy2(BOOST.parent / 'action.yml', script.parent / 'action.yml')
# A macOS runner, whose image a stand-in sw_vers names, on any machine.
tools = scratch / 'stand-in bin'
tools.mkdir()
(tools / 'sw_vers').write_text('#!/bin/sh\necho 15.7\n')
(tools / 'sw_vers').chmod(0o755)
output = scratch / 'output'
runner = {'RUNNER_OS': 'macOS', 'RUNNER_ARCH': 'ARM64', 'RUNNER_TEMP': str(scratch / 'temp'),
'GITHUB_OUTPUT': str(output), 'PATH': f'{tools}{os.pathsep}{os.environ["PATH"]}'}
keys = []
for patch in (None, DEFECT_PATCH, DEFECT_PATCH + '\n'):
if patch is not None:
shutil.rmtree(scratch / 'tools/ci/actions/boost/patches', ignore_errors=True)
boost_patches(scratch, patch)
output.write_text('')
result = run(script, 'key', env=runner)
assert result.returncode == 0 and not result.stderr, (result.returncode, result.stderr)
keys.append(re.search(r'^key=(.+)$', output.read_text(), re.MULTILINE))
assert all(keys) and len({key.group(1) for key in keys if key}) == 3, keys


def test_boost_fails_on_a_patch_that_does_not_apply(scratch: Path) -> None:
# A patch is removed, not skipped: one that the archive holds already (a Boost that has the
# fix), one that no longer applies, and one outside the headers each fail the install, naming
# the patch, and the prefix is not written.
script, runner = boost_install_tree(scratch)
name = 'tools/ci/actions/boost/patches/defect.patch'
outside = DEFECT_PATCH.replace('boost/defect.hpp', 'libs/url/src/url.cpp')
stale = DEFECT_PATCH.replace(' int f()\n {\n-int f()', ' int g()\n {\n-int g()')
for patch, archive, expected in (
(DEFECT_PATCH, FIXED, f'Boost 1.92.0 holds the change of {name} already: '
'remove the patch'),
(stale, DEFECT, f'{name} does not apply to Boost 1.92.0: update it, or remove it'),
(outside, DEFECT, f'{name} patches a file outside boost/, the headers')):
shutil.rmtree(scratch / 'tools/ci/actions/boost/patches', ignore_errors=True)
boost_patches(scratch, patch)
tree = scratch / 'archive/boost_1_92_0'
(tree / 'boost/defect.hpp').write_text(archive)
with tarfile.open(scratch / 'boost_1_92_0.tar.gz', 'w:gz') as tar:
tar.add(tree, arcname='boost_1_92_0')
prefix = scratch / 'prefix'
result = run(script, 'install', prefix, env=runner)
assert result.returncode == 1, (expected, result.returncode, result.stdout,
result.stderr)
assert f'install.sh: {expected}' in result.stderr, (expected, result.stderr)
assert not prefix.exists(), expected


def test_the_boost_patches_name_their_upstream_fix(_: Path) -> None:
# Each patch says, in its opening paragraph, which upstream change makes it unnecessary.
for patch in sorted((CI / 'actions/boost/patches').glob('*.patch')):
opening = patch.read_text().split('\ndiff --git ', 1)[0]
assert re.search(r'https://github\.com/boostorg/[\w-]+/(pull|issues|commit)/\w+',
opening), patch


def place_helpers(scratch: Path) -> None:
"""tools/ci/helpers.sh in the scratch superproject, where every action sources it."""
(scratch / 'tools/ci').mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -1579,6 +1697,10 @@ def test_third_party_key_names_the_configurations(scratch: Path) -> None:
test_boost_source_fills_a_directory_alone,
test_boost_source_refuses_a_directory_it_did_not_write,
test_boost_source_that_fails_leaves_the_tree_and_no_files,
test_boost_installs_patched_headers,
test_boost_key_changes_with_the_patches,
test_boost_fails_on_a_patch_that_does_not_apply,
test_the_boost_patches_name_their_upstream_fix,
test_wit_bindgen_installs_the_runners_build_alone,
test_wit_bindgen_refuses_a_runner_it_pins_no_build_for,
test_wasi_sdk_installs_the_platform_independent_sysroot_and_builtins,
Expand Down
Loading