diff --git a/bin/check-tools.sh b/bin/check-tools.sh index 5164df625e..716d5cf723 100755 --- a/bin/check-tools.sh +++ b/bin/check-tools.sh @@ -20,9 +20,11 @@ # development setups, but not in the macOS CI environment. They are checked # everywhere except when running in CI on macOS. # -# Tools that Nix also exposes under a version-suffixed name (`clang-tidy-22`, -# `g++-15`, ...) are probed under both names: a suffixed name can break while -# the plain one still works (see mkVersionedToolLinks in nix/packages.nix). +# Tools that Nix also exposes under a version-suffixed name +# (`clang-tidy-`, `g++-`, ...) are probed under both names: +# a suffixed name can break while the plain one still works +# (see mkVersionedToolLinks in nix/packages.nix). +# The suffix is the major version of the plain `clang` / `gcc` on PATH. # # Tools scoped to a single dev shell rather than to commonPackages are checked # only in that shell, keyed off XRPL_DEVSHELL. @@ -34,9 +36,16 @@ set -uo pipefail -# Version suffixes of the Nix tool links, tracking nix/packages.nix. -gcc_version=15 -llvm_version=22 +# major_version +# Major version of a compiler on PATH, or "unknown" when it isn't there. +major_version() { + local version + version="$("$1" -dumpversion 2>/dev/null)" || version="" + version="${version%%.*}" + printf '%s' "${version:-unknown}" +} + +llvm_version="$(major_version clang)" missing=() checked=0 @@ -181,6 +190,7 @@ fi if [ "${os}" = "linux" ]; then echo echo "GCC toolchain:" + gcc_version="$(major_version gcc)" check gcc check "gcc-${gcc_version}" check g++ diff --git a/bin/pre-commit/clang_tidy_check.py b/bin/pre-commit/clang_tidy_check.py index 118d9619e2..730f979231 100755 --- a/bin/pre-commit/clang_tidy_check.py +++ b/bin/pre-commit/clang_tidy_check.py @@ -26,8 +26,6 @@ import sys import tempfile from pathlib import Path -CLANG_TIDY_VERSION = 22 - # Extensions run-clang-tidy can analyse: `.cpp` translation units and, thanks to # the `verify_headers` build option, `.h`/`.hpp` headers (each has its own # compile_commands.json entry). `.ipp` fragments have no entry and are skipped. @@ -39,8 +37,21 @@ TIDY_EXTENSIONS = {".cpp", ".h", ".hpp"} FILEPATH_RE = re.compile(r"^(\s*(?:-\s+)?FilePath:\s*)'((?:[^']|'')*)'\s*$") -def find_tool(name: str) -> str | None: - for candidate in (f"{name}-{CLANG_TIDY_VERSION}", name): +def clang_tidy_major() -> str | None: + """Major version of the `clang-tidy` on PATH, which run-clang-tidy invokes.""" + if not (clang_tidy := shutil.which("clang-tidy")): + return None + output = subprocess.run( + [clang_tidy, "--version"], capture_output=True, text=True + ).stdout + m = re.search(r"LLVM version (\d+)", output) + return m.group(1) if m else None + + +def find_tool(name: str, version: str | None) -> str | None: + """Prefer `-`, so a host tool of another version can't win.""" + candidates = ([f"{name}-{version}"] if version else []) + [name] + for candidate in candidates: if path := shutil.which(candidate): return path return None @@ -103,8 +114,9 @@ def main(): if not files: return 0 - run_clang_tidy = find_tool("run-clang-tidy") - clang_apply_replacements = find_tool("clang-apply-replacements") + version = clang_tidy_major() + run_clang_tidy = find_tool("run-clang-tidy", version) + clang_apply_replacements = find_tool("clang-apply-replacements", version) missing = [ name for name, path in ( @@ -114,9 +126,10 @@ def main(): if not path ] if missing: + tried = f" (tried the '-{version}' suffix too)" if version else "" print( f"clang-tidy check failed: TIDY is enabled but {' and '.join(missing)} " - f"was not found in PATH (tried the '-{CLANG_TIDY_VERSION}' suffix too).", + f"was not found in PATH{tried}.", file=sys.stderr, ) return 1 diff --git a/conan/profiles/default b/conan/profiles/default index 38ece7fa59..bb73ab3721 100644 --- a/conan/profiles/default +++ b/conan/profiles/default @@ -29,9 +29,9 @@ os.version={{ min_macos_version }} [conf] {# The Boost recipe builds with b2, which doesn't use Conan's toolchain files. #} {# Instead it hand-rolls the compiler for user-config.jam, #} -{# and its fallback probes a version-suffixed binary (e.g. `g++-15`) before plain `g++`. #} -{# Inside the Nix shell the wrapper only provides `g++`/`gcc` (no `-15` suffix), #} -{# so on a host that also has a system `g++-15` the probe escapes Nix #} +{# and its fallback probes a version-suffixed binary (e.g. `g++-`) before plain `g++`. #} +{# Inside the Nix shell the wrapper only provides `g++`/`gcc` (no `-` suffix), #} +{# so on a host that also has a system `g++-` the probe escapes Nix #} {# and picks the system compiler, which is mismatched with the Nix libraries #} {# and breaks the build (e.g. Boost.Stacktrace link checks fail). #} {# Pinning the executables here short-circuits that probe so Boost (and the rest of the toolchain) #} diff --git a/docs/build/environment.md b/docs/build/environment.md index 51580b12a5..829c528260 100644 --- a/docs/build/environment.md +++ b/docs/build/environment.md @@ -10,14 +10,15 @@ This document explains how to set one up. support it — see [compiler support for C++23][cpp23-support]. The versions currently tested in CI are: -| Compiler | Version | -| ----------- | ------------------ | -| GCC | 15.2 | -| Clang | 22 | -| Apple Clang | 21 | -| MSVC | Visual Studio 2026 | +| Compiler | Version | +| ----------- | ------------------------------- | +| GCC | `gccVersion` in [packages.nix] | +| Clang | `llvmVersion` in [packages.nix] | +| Apple Clang | 21 | +| MSVC | Visual Studio 2026 | -LLVM tools (`clang-tidy` and `clang-format`) are also pinned to version 22. +LLVM tools (`clang-tidy` and `clang-format`) +come from the same LLVM release as Clang. ### Older compilers @@ -156,3 +157,4 @@ version out of the box — run it via `run-clang-tidy`. No separate installation is needed. [cpp23-support]: https://en.cppreference.com/w/cpp/compiler_support/23 +[packages.nix]: ../../nix/packages.nix diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index a31a3f3ed0..c8eac8037e 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -17,7 +17,7 @@ namespace xrpl { template -static std::size_t +std::size_t extract(Key const& key) { return key; diff --git a/include/xrpl/beast/unit_test/suite.h b/include/xrpl/beast/unit_test/suite.h index 29e422c55e..47cb1b7d25 100644 --- a/include/xrpl/beast/unit_test/suite.h +++ b/include/xrpl/beast/unit_test/suite.h @@ -20,7 +20,7 @@ namespace beast::unit_test { namespace detail { template -static std::string +std::string makeReason(String const& reason, char const* file, int line) { std::string s(reason); diff --git a/nix/check-tools/macos.txt b/nix/check-tools/macos.txt index abc44606ae..b65cf64532 100644 --- a/nix/check-tools/macos.txt +++ b/nix/check-tools/macos.txt @@ -5,8 +5,8 @@ Core build tools: cmake version 4.4.3 /nix/store/q85csxf4s4shx89zif097h1ql4ax1rrz-cmake-4.4.3/bin/cmake ✅ conan - Conan version 2.32.0 - /nix/store/921jqsgbilixmr3xchj95si0jl8pi13z-conan-2.32.0/bin/conan + Conan version 2.33.0 + /nix/store/rp0zf22rx3iwnhxp4d53ncirn4lzg68j-conan-2.33.0/bin/conan ✅ git git version 2.55.0 /nix/store/gw7c7m0dwca5lg4152x9lpmxpj171bzw-git-2.55.0/bin/git @@ -19,17 +19,17 @@ Development tooling: ccache version 4.13.6 /nix/store/ydr5nlzxp1djb5256y0zzqa87vz55gsk-ccache-4.13.6/bin/ccache ✅ clang - clang version 22.1.8 - /nix/store/dakcxgwz4ixkk6ps50b7vn3dvblyzsnf-clang-wrapper-22.1.8/bin/clang - ✅ clang-22 - clang version 22.1.8 - /nix/store/w826sqb98nnym6kzackg829664iqdlxj-clang-22/bin/clang-22 + clang version 23.1.0 + /nix/store/2c16z6akvv65znb8330sl5qpklaf3194-clang-wrapper-23.1.0/bin/clang + ✅ clang-23 + clang version 23.1.0 + /nix/store/vfd0q2395vyn0bsjsh1b4068icy1x9ph-clang-23/bin/clang-23 ✅ clang++ - clang version 22.1.8 - /nix/store/dakcxgwz4ixkk6ps50b7vn3dvblyzsnf-clang-wrapper-22.1.8/bin/clang++ - ✅ clang++-22 - clang version 22.1.8 - /nix/store/wnwyw3yfqrhpxij65bl3pa1x65q2zg3m-clang++-22/bin/clang++-22 + clang version 23.1.0 + /nix/store/2c16z6akvv65znb8330sl5qpklaf3194-clang-wrapper-23.1.0/bin/clang++ + ✅ clang++-23 + clang version 23.1.0 + /nix/store/0i6kfnif2v4sqyv5fzfg8a9n09rw9lkp-clang++-23/bin/clang++-23 ✅ ClangBuildAnalyzer ClangBuildAnalyzer 1.6.0 /nix/store/c7jjnw29ra78jdlzjww2m374izhy05n8-clangbuildanalyzer-1.6.0/bin/ClangBuildAnalyzer @@ -67,23 +67,23 @@ Development tooling: Zip 3.0 /nix/store/dvawr36npnad4xa6dxi2ss0fw44aa82r-zip-3.0/bin/zip ✅ clang-apply-replacements - clang-apply-replacements version 22.1.8 - /nix/store/5bij4zn161lagwyndmrr21vmxjg054nv-clang-tools-22.1.8/bin/clang-apply-replacements - ✅ clang-apply-replacements-22 - clang-apply-replacements version 22.1.8 - /nix/store/w4bz034k4l0w719rrmbwnqcgyjbswy81-clang-apply-replacements-22/bin/clang-apply-replacements-22 + clang-apply-replacements version 23.1.0 + /nix/store/mva6ngy45m9in3m2lsfccj1y0z6n1f5s-clang-tools-23.1.0/bin/clang-apply-replacements + ✅ clang-apply-replacements-23 + clang-apply-replacements version 23.1.0 + /nix/store/872k02mqr21hxwcpfwaqkxljfj60aak0-clang-apply-replacements-23/bin/clang-apply-replacements-23 ✅ clang-format - clang-format version 22.1.8 - /nix/store/5bij4zn161lagwyndmrr21vmxjg054nv-clang-tools-22.1.8/bin/clang-format - ✅ clang-format-22 - clang-format version 22.1.8 - /nix/store/w7z346l0r8y36b6lc5i7jzj3w0581l2y-clang-format-22/bin/clang-format-22 + clang-format version 23.1.0 + /nix/store/mva6ngy45m9in3m2lsfccj1y0z6n1f5s-clang-tools-23.1.0/bin/clang-format + ✅ clang-format-23 + clang-format version 23.1.0 + /nix/store/wf30x6lcya44n2y1fagd6q7x7p4gyl6f-clang-format-23/bin/clang-format-23 ✅ clang-tidy - LLVM version 22.1.8 - /nix/store/5bij4zn161lagwyndmrr21vmxjg054nv-clang-tools-22.1.8/bin/clang-tidy - ✅ clang-tidy-22 - LLVM version 22.1.8 - /nix/store/0lv25qd3ddgjm3ndn70q61jfr6krlkl7-clang-tidy-22/bin/clang-tidy-22 + LLVM version 23.1.0 + /nix/store/mva6ngy45m9in3m2lsfccj1y0z6n1f5s-clang-tools-23.1.0/bin/clang-tidy + ✅ clang-tidy-23 + LLVM version 23.1.0 + /nix/store/kgx00aass66g02p1s4gqqf65kq39m4ci-clang-tidy-23/bin/clang-tidy-23 ✅ dot dot - graphviz version 15.1.1 (0) /nix/store/mc99a6bpbk2waym2cnw6ifmxli4ndb4x-graphviz-15.1.1/bin/dot @@ -110,10 +110,10 @@ Development tooling: /nix/store/ivh54xypg9qvd3ha9lis0i8p4nkf8n7a-pre-commit-4.6.2/bin/pre-commit ✅ run-clang-tidy usage: run-clang-tidy [-h] [-allow-enabling-alpha-checkers] - /nix/store/3xss1mm3mh1hzcmg182na6ki1p5rnxf1-run-clang-tidy/bin/run-clang-tidy - ✅ run-clang-tidy-22 + /nix/store/zjbzr154xan5xg9pmjiv0zkwklyb94wv-run-clang-tidy/bin/run-clang-tidy + ✅ run-clang-tidy-23 usage: run-clang-tidy [-h] [-allow-enabling-alpha-checkers] - /nix/store/w68r9z07hcq4fwbfyq3yvc7qxm8aqfbl-run-clang-tidy-22/bin/run-clang-tidy-22 + /nix/store/svhfrpgx2j581brsqmkpav9b286v22yy-run-clang-tidy-23/bin/run-clang-tidy-23 Rust toolchain: ✅ cargo diff --git a/nix/packages.nix b/nix/packages.nix index 9925c0201e..de2fcf0079 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -7,8 +7,11 @@ }: let # Compiler versions used across the dev shell and the CI environment. + # Docs link here and scripts read the version off the tools; + # only the clang-format rev in .pre-commit-config.yaml + # has to be bumped alongside llvmVersion. gccVersion = 15; - llvmVersion = 22; + llvmVersion = 23; gccPackage = pkgs."gcc${toString gccVersion}"; llvmPackages = pkgs."llvmPackages_${toString llvmVersion}"; @@ -27,6 +30,21 @@ let exec ${pkgs.python3}/bin/python3 ${llvmPackages.clang-unwrapped}/bin/run-clang-tidy "$@" ''; + # Conan 2.33 is the first release whose settings.yml accepts clang 23. + # TODO: drop once nixpkgs ships it. + conan = pkgs.conan.overridePythonAttrs (old: { + version = "2.33.0"; + src = pkgs.fetchFromGitHub { + owner = "conan-io"; + repo = "conan"; + tag = "2.33.0"; + hash = "sha256-FDJjesqvPiAUAEjeqQt088Vnet/KXHbUyEPytP9MyG4="; + }; + dependencies = old.dependencies ++ [ pkgs.python3Packages.truststore ]; + # The upstream test suite takes long and needs network access. + doCheck = false; + }); + rust = import ./rust.nix { inherit pkgs; }; # Nix wraps its toolchain so that binaries are exposed only under unsuffixed @@ -36,10 +54,11 @@ let # - Conan's Boost recipe looks up `g++-` before plain `g++`. # - bin/pre-commit/clang_tidy_check.py looks up `run-clang-tidy-` and # `clang-apply-replacements-` before the unsuffixed names. - # On a host that also has the matching system binary (e.g. Ubuntu's - # `/usr/bin/g++-15` or `clang-tidy-22`) the probe escapes Nix and mixes a - # system tool into the Nix environment. Generate version-suffixed symlinks - # next to a package's tools so those probes resolve to the Nix ones. + # On a host that also has the matching system binary + # (e.g. Ubuntu's `/usr/bin/g++-` or `clang-tidy-`), + # the probe escapes Nix and mixes a system tool into the Nix environment. + # Generate version-suffixed symlinks next to a package's tools + # so those probes resolve to the Nix ones. # # Compiler links must point at whichever compiler is active in a given # environment (the plain stdenv compiler in the dev shell, the custom-glibc diff --git a/src/libxrpl/tx/paths/AMMLiquidity.cpp b/src/libxrpl/tx/paths/AMMLiquidity.cpp index 1b38847d7b..007c02e044 100644 --- a/src/libxrpl/tx/paths/AMMLiquidity.cpp +++ b/src/libxrpl/tx/paths/AMMLiquidity.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -100,28 +99,6 @@ AMMLiquidity::generateFibSeqOffer(TAmounts const& balances } namespace { -template -constexpr T -maxAmount() -{ - if constexpr (std::is_same_v) - { - return XRPAmount(STAmount::kMaxNative); - } - else if constexpr (std::is_same_v) - { - return IOUAmount(STAmount::kMaxValue / 2, STAmount::kMaxOffset); - } - else if constexpr (std::is_same_v) - { - return STAmount(STAmount::kMaxValue / 2, STAmount::kMaxOffset); - } - else if constexpr (std::is_same_v) - { - return MPTAmount(kMaxMpTokenAmount); - } -} - template T maxOut(T const& out, Asset const& asset)