From e189a09fd7c4d63f85076fd012f2e24214be5c36 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 12 Jan 2026 15:42:32 +0530 Subject: [PATCH 01/60] build: add Rust to CI docker image, cross-compile targets --- .github/workflows/build-container.yml | 4 +++ contrib/containers/ci/ci.Dockerfile | 31 +++++++++++++++++++ contrib/containers/ci/config.toml | 28 +++++++++++++++++ contrib/containers/develop/docker-compose.yml | 2 ++ rust-toolchain.toml | 2 ++ 5 files changed, 67 insertions(+) create mode 100644 contrib/containers/ci/config.toml create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 078a3e84a5ec..11113c490d4f 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -67,6 +67,8 @@ jobs: uses: docker/build-push-action@v7 with: context: ${{ inputs.context }} + build-contexts: | + docker_root=${{ github.workspace }}/dash/contrib/containers/ci file: ${{ inputs.file }} push: true platforms: linux/amd64 @@ -113,6 +115,8 @@ jobs: uses: docker/build-push-action@v7 with: context: ${{ inputs.context }} + build-contexts: | + docker_root=${{ github.workspace }}/dash/contrib/containers/ci file: ${{ inputs.file }} push: true platforms: linux/arm64 diff --git a/contrib/containers/ci/ci.Dockerfile b/contrib/containers/ci/ci.Dockerfile index 42df9b08018c..e59fb9369b9c 100644 --- a/contrib/containers/ci/ci.Dockerfile +++ b/contrib/containers/ci/ci.Dockerfile @@ -58,6 +58,37 @@ RUN set -ex; \ # LD_LIBRARY_PATH is empty by default, this is the first entry ENV LD_LIBRARY_PATH="/usr/lib/llvm-${LLVM_VERSION}/lib" +# Install Rust +ARG RUSTUP_VERSION=1.28.2 \ + RUST_VERSION=1.82.0 +ENV RUSTUP_HOME="/opt/rust/rustup" \ + CARGO_HOME="/opt/rust/cargo" +ENV PATH="${CARGO_HOME}/bin:${PATH}" +RUN dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu';; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf';; \ + arm64) rustArch='aarch64-unknown-linux-gnu';; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + curl -fL "https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/${rustArch}/rustup-init" -o /tmp/rustup-init; \ + chmod +x /tmp/rustup-init; \ + /tmp/rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm /tmp/rustup-init; \ + chmod -R a+w "${RUSTUP_HOME}" "${CARGO_HOME}"; \ + rustup target add \ + # Linux + aarch64-unknown-linux-gnu \ + x86_64-unknown-linux-gnu \ + # Windows + x86_64-pc-windows-gnu; \ + rustup --version; \ + cargo --version; \ + rustc --version; \ + rm -rf "${CARGO_HOME}/registry/cache" +COPY --from=docker_root ./config.toml "${CARGO_HOME}/config.toml" + +# Install IWYU RUN set -ex; \ git clone --depth=1 "https://github.com/include-what-you-use/include-what-you-use" -b "clang_${LLVM_VERSION}" /opt/iwyu; \ cd /opt/iwyu; \ diff --git a/contrib/containers/ci/config.toml b/contrib/containers/ci/config.toml new file mode 100644 index 000000000000..caa3405606bb --- /dev/null +++ b/contrib/containers/ci/config.toml @@ -0,0 +1,28 @@ +# Commented out entries are not bundled in the container + +# Linux +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" + +# [target.armv7-unknown-linux-gnueabihf] +# linker = "arm-linux-gnueabihf-gcc" + +# [target.powerpc64le-unknown-linux-gnu] +# linker = "powerpc64le-linux-gnu-gcc" + +# [target.riscv64gc-unknown-linux-gnu] +# linker = "riscv64-linux-gnu-gcc" + +[target.x86_64-unknown-linux-gnu] +linker = "x86-64-linux-gnu-gcc" + +# Windows +[target.x86_64-pc-windows-gnu] +linker = "x86_64-w64-mingw32-gcc" + +# macOS +# [target.aarch64-apple-darwin] +# linker = "aarch64-apple-darwin-gcc" + +# [target.x86_64-apple-darwin] +# linker = "x86_64-apple-darwin-gcc" diff --git a/contrib/containers/develop/docker-compose.yml b/contrib/containers/develop/docker-compose.yml index c6f2cea70424..39238d6d4d0c 100644 --- a/contrib/containers/develop/docker-compose.yml +++ b/contrib/containers/develop/docker-compose.yml @@ -4,6 +4,8 @@ services: build: context: '..' dockerfile: './develop/Dockerfile' + additional_contexts: + - docker_root=../ci args: USER_ID: 1000 # set this to $(id -u) of the host GROUP_ID: 1000 # set this to $(id -g) of the host diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000000..2e2b8c8521ea --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.82.0" From 01fd416456f0eb89cfdd99189392f393b9a1bde9 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 16 Jan 2026 17:15:01 +0530 Subject: [PATCH 02/60] build: add minimal stub crate to validate Rust integration --- .gitignore | 23 ++++ rust/chirp/Cargo.lock | 297 ++++++++++++++++++++++++++++++++++++++++++ rust/chirp/Cargo.toml | 13 ++ rust/chirp/build.rs | 5 + rust/chirp/src/lib.rs | 19 +++ 5 files changed, 357 insertions(+) create mode 100644 rust/chirp/Cargo.lock create mode 100644 rust/chirp/Cargo.toml create mode 100644 rust/chirp/build.rs create mode 100644 rust/chirp/src/lib.rs diff --git a/.gitignore b/.gitignore index eab9f3f83ec1..e67bfd539a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -181,3 +181,26 @@ compile_commands.json # Linux perf profiling artifacts perf.data perf.data.old + +# Generated by Cargo +# will have compiled files and executables +debug +target + +# Cargo configuration +.cargo/.configured-for-* +.cargo/config +.cargo/config.toml + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Generated by cargo mutants +# Contains mutation testing data +**/mutants.out*/ + +# FFI bridge +gen diff --git a/rust/chirp/Cargo.lock b/rust/chirp/Cargo.lock new file mode 100644 index 000000000000..0baf0e1fce0a --- /dev/null +++ b/rust/chirp/Cargo.lock @@ -0,0 +1,297 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "built" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" + +[[package]] +name = "cc" +version = "1.2.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "chirp" +version = "0.1.0" +dependencies = [ + "built", + "cxx", +] + +[[package]] +name = "clap" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbda285ba6e5866529faf76352bdf73801d9b44a6308d7cd58ca2379f378e994" +dependencies = [ + "cc", + "cxx-build", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9efde466c5d532d57efd92f861da3bdb7f61e369128ce8b4c3fe0c9de4fa4d" +dependencies = [ + "cc", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3efb93799095bccd4f763ca07997dc39a69e5e61ab52d2c407d4988d21ce144d" +dependencies = [ + "clap", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3092010228026e143b32a4463ed9fa8f86dca266af4bf5f3b2a26e113dbe4e45" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31d72ebfcd351ae404fb00ff378dfc9571827a00722c9e735c9181aec320ba0a" +dependencies = [ + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "find-msvc-tools" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82" +dependencies = [ + "cc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "scratch" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/rust/chirp/Cargo.toml b/rust/chirp/Cargo.toml new file mode 100644 index 000000000000..fd9b62a4a9aa --- /dev/null +++ b/rust/chirp/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "chirp" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["staticlib"] + +[dependencies] +cxx = "1.0.192" + +[build-dependencies] +built = "0.8.0" diff --git a/rust/chirp/build.rs b/rust/chirp/build.rs new file mode 100644 index 000000000000..6840529bef3c --- /dev/null +++ b/rust/chirp/build.rs @@ -0,0 +1,5 @@ +fn main() { + built::write_built_file().expect("Failed to write build info"); + cxx_build::bridge("src/lib.rs").compile("chirp"); + println!("cargo::rerun-if-changed=src/lib.rs"); +} diff --git a/rust/chirp/src/lib.rs b/rust/chirp/src/lib.rs new file mode 100644 index 000000000000..1d27c03613f3 --- /dev/null +++ b/rust/chirp/src/lib.rs @@ -0,0 +1,19 @@ +mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + +#[cxx::bridge(namespace = "chirp")] +mod ffi { + extern "Rust" { + fn chirp() -> String; + } +} + +fn chirp() -> String { + format!( + "{} {} built with {} reports \"cheep cheep\"", + built_info::PKG_NAME, + built_info::PKG_VERSION, + built_info::RUSTC_VERSION, + ) +} From fc23f3602865c9bd4ba5d1dc310bb76cee7410c1 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 28 Feb 2026 22:46:35 +0530 Subject: [PATCH 03/60] lint: exclude `rust/` from linters Eventually, `rust/` will be hosting primarily subtrees, whose contents we cannot directly influence, so linting it makes little sense. --- test/lint/lint-files.py | 2 +- test/lint/lint-format-strings.py | 2 +- test/lint/lint-include-guards.py | 3 ++- test/lint/lint-includes.py | 3 ++- test/lint/lint-locale-dependence.py | 1 + test/lint/lint-python-utf8-encoding.py | 3 ++- test/lint/lint-python.py | 3 ++- test/lint/lint-shell-locale.py | 2 +- test/lint/lint-shell.py | 2 +- test/lint/lint-spelling.py | 2 +- test/lint/lint-whitespace.py | 1 + 11 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/lint/lint-files.py b/test/lint/lint-files.py index ee09cea93235..a53a060b550c 100755 --- a/test/lint/lint-files.py +++ b/test/lint/lint-files.py @@ -21,7 +21,7 @@ ALLOWED_FILENAME_REGEXP = "^[a-zA-Z0-9/_.@][a-zA-Z0-9/_.@-]*$" ALLOWED_SOURCE_FILENAME_REGEXP = "^[a-z0-9_./-]+$" ALLOWED_SOURCE_FILENAME_EXCEPTION_REGEXP = ( - "^src/(dashbls/|immer/|secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)" + "^rust/|src/(dashbls/|immer/|secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)" ) ALLOWED_PERMISSION_NON_EXECUTABLES = 0o644 ALLOWED_PERMISSION_EXECUTABLES = 0o755 diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py index 6992343d6cf6..11c5ffd51ed7 100755 --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -82,7 +82,7 @@ def main(): matching_files_filtered = [] for matching_file in matching_files: - if not re.search('^src/(dashbls|leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp|clientversion.cpp)', matching_file): + if not re.search('^rust/|src/(dashbls|leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp|clientversion.cpp)', matching_file): matching_files_filtered.append(matching_file) matching_files_filtered.sort() diff --git a/test/lint/lint-include-guards.py b/test/lint/lint-include-guards.py index 6e59c83f7dbc..24b6a6f4821a 100755 --- a/test/lint/lint-include-guards.py +++ b/test/lint/lint-include-guards.py @@ -17,7 +17,8 @@ HEADER_ID_PREFIX = 'BITCOIN_' HEADER_ID_SUFFIX = '_H' -EXCLUDE_FILES_WITH_PREFIX = ['src/crypto/ctaes', +EXCLUDE_FILES_WITH_PREFIX = ['rust/', + 'src/crypto/ctaes', 'src/leveldb', 'src/crc32c', 'src/secp256k1', diff --git a/test/lint/lint-includes.py b/test/lint/lint-includes.py index 9a0cfa127dde..ea31465f218e 100755 --- a/test/lint/lint-includes.py +++ b/test/lint/lint-includes.py @@ -15,7 +15,8 @@ from subprocess import check_output, CalledProcessError -EXCLUDED_DIRS = ["src/leveldb/", +EXCLUDED_DIRS = ["rust/", + "src/leveldb/", "src/crc32c/", "src/secp256k1/", "src/minisketch/", diff --git a/test/lint/lint-locale-dependence.py b/test/lint/lint-locale-dependence.py index 0ee4c4566b0a..5fa01662141e 100755 --- a/test/lint/lint-locale-dependence.py +++ b/test/lint/lint-locale-dependence.py @@ -56,6 +56,7 @@ ] REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS = [ + "rust/", "src/crypto/ctaes/", "src/leveldb/", "src/secp256k1/", diff --git a/test/lint/lint-python-utf8-encoding.py b/test/lint/lint-python-utf8-encoding.py index 0377e12701ed..fafdaf5cced7 100755 --- a/test/lint/lint-python-utf8-encoding.py +++ b/test/lint/lint-python-utf8-encoding.py @@ -12,7 +12,8 @@ from subprocess import check_output, CalledProcessError -EXCLUDED_DIRS = ["src/crc32c/", +EXCLUDED_DIRS = ["rust/", + "src/crc32c/", "src/secp256k1/"] diff --git a/test/lint/lint-python.py b/test/lint/lint-python.py index d4c750147e7a..fc4f31416127 100755 --- a/test/lint/lint-python.py +++ b/test/lint/lint-python.py @@ -21,7 +21,8 @@ DEPS = ['flake8', 'lief', 'mypy', 'pyzmq'] FILES_ARGS = ['git', 'ls-files', '--','test/functional/*.py', 'contrib/devtools/*.py', ':(exclude)contrib/devtools/github-merge.py'] -EXCLUDE_DIRS = ['src/dashbls/', +EXCLUDE_DIRS = ['rust/', + 'src/dashbls/', 'src/immer/'] ENABLED = ( diff --git a/test/lint/lint-shell-locale.py b/test/lint/lint-shell-locale.py index 77f6d79f3529..5b4ced04cf3a 100755 --- a/test/lint/lint-shell-locale.py +++ b/test/lint/lint-shell-locale.py @@ -41,7 +41,7 @@ def main(): exit_code = 0 shell_files = get_shell_files_list() for file_path in shell_files: - if re.search('src/(dashbls|secp256k1|minisketch)/', file_path): + if re.search('rust/|src/(dashbls|secp256k1|minisketch)/', file_path): continue with open(file_path, 'r', encoding='utf-8') as file_obj: diff --git a/test/lint/lint-shell.py b/test/lint/lint-shell.py index 4be1f297fa11..7c4584f5d062 100755 --- a/test/lint/lint-shell.py +++ b/test/lint/lint-shell.py @@ -68,7 +68,7 @@ def main(): ] files = get_files(files_cmd) # remove everything that doesn't match this regex - reg = re.compile(r'src/[dashbls,immer,leveldb,secp256k1,minisketch]') + reg = re.compile(r'rust|src/[dashbls,immer,leveldb,secp256k1,minisketch]') files[:] = [file for file in files if not reg.match(file)] # build the `shellcheck` command diff --git a/test/lint/lint-spelling.py b/test/lint/lint-spelling.py index fb4d2495c691..dac24b5612b8 100755 --- a/test/lint/lint-spelling.py +++ b/test/lint/lint-spelling.py @@ -12,7 +12,7 @@ from subprocess import check_output, STDOUT, CalledProcessError IGNORE_WORDS_FILE = 'test/lint/spelling.ignore-words.txt' -FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/dashbls/", ":(exclude)src/crc32c/", ":(exclude)src/crypto/", ":(exclude)src/ctpl_stl.h", ":(exclude)src/cxxtimer.hpp", ":(exclude)src/immer/", ":(exclude)src/leveldb/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/", ":(exclude)contrib/guix/patches", ":(exclude)src/util/subprocess.hpp", ":(exclude)src/wallet/bip39_english.h"] +FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)rust/", ":(exclude)src/dashbls/", ":(exclude)src/crc32c/", ":(exclude)src/crypto/", ":(exclude)src/ctpl_stl.h", ":(exclude)src/cxxtimer.hpp", ":(exclude)src/immer/", ":(exclude)src/leveldb/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/", ":(exclude)contrib/guix/patches", ":(exclude)src/util/subprocess.hpp", ":(exclude)src/wallet/bip39_english.h"] def check_codespell_install(): diff --git a/test/lint/lint-whitespace.py b/test/lint/lint-whitespace.py index 78c145bd004e..3d9208425720 100755 --- a/test/lint/lint-whitespace.py +++ b/test/lint/lint-whitespace.py @@ -18,6 +18,7 @@ EXCLUDED_DIRS = ["depends/patches/", "contrib/guix/patches/", + "rust/", "src/crypto/x11/", "src/leveldb/", "src/crc32c/", From 57c75bf9e74618747d594de1a791dc022dda8b43 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 25 Jan 2026 00:40:53 +0530 Subject: [PATCH 04/60] build: introduce barebones Autotools integration with Rust --- Makefile.am | 2 +- configure.ac | 72 +++++++++++++++++++++++++++++++++++- contrib/guix/symbol-check.py | 2 + rust/Makefile.am | 32 ++++++++++++++++ rust/Makefile.chirp.include | 49 ++++++++++++++++++++++++ rust/Makefile.libs.include | 50 +++++++++++++++++++++++++ rust/chirp/build.rs | 2 - src/Makefile.am | 49 +++++++++++++++++++----- src/Makefile.bench.include | 3 ++ src/Makefile.qt.include | 4 +- src/Makefile.qttest.include | 4 +- src/Makefile.test.include | 7 +++- 12 files changed, 255 insertions(+), 21 deletions(-) create mode 100644 rust/Makefile.am create mode 100644 rust/Makefile.chirp.include create mode 100644 rust/Makefile.libs.include diff --git a/Makefile.am b/Makefile.am index ea2cba9fd2fa..97a2fd35bea0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ print-%: FORCE @echo '$*'='$($*)' ACLOCAL_AMFLAGS = -I build-aux/m4 -SUBDIRS = src +SUBDIRS = rust src if ENABLE_MAN SUBDIRS += doc/man endif diff --git a/configure.ac b/configure.ac index d36f8046cfa2..51f7e4b02b4e 100644 --- a/configure.ac +++ b/configure.ac @@ -60,7 +60,9 @@ AM_INIT_AUTOMAKE([1.13 no-define subdir-objects foreign]) AM_MAINTAINER_MODE([enable]) dnl make the compilation flags quiet unless V=1 is used -AM_SILENT_RULES([yes]) +m4_pattern_allow([AM_DEFAULT_VERBOSITY]) +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],[AM_DEFAULT_VERBOSITY=1]) +AM_CONDITIONAL([SILENT_RULES], [test "$AM_DEFAULT_VERBOSITY" = '0']) dnl Compiler checks (here before libtool). if test "${CXXFLAGS+set}" = "set"; then @@ -125,6 +127,31 @@ AC_PATH_TOOL([DSYMUTIL], [dsymutil]) AC_PATH_PROG([DOXYGEN], [doxygen]) AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) +dnl Check/return PATH for Rust dependencies +AC_DEFUN( + RS_REQUIRE_PROG, + [ + AC_PATH_PROG($1, $2, $2_notfound) + if test x${$1} = x$2_notfound + then + AC_MSG_ERROR("Required program $2 was not found") + fi + ] +) +RS_REQUIRE_PROG([CARGO], cargo) +RS_REQUIRE_PROG([CXXBRIDGE], cxxbridge) +RS_REQUIRE_PROG([RUSTC], rustc) + +AC_ARG_VAR([CARGO_INCREMENTAL], [Enable incremental compilation for Rust]) +if test "${CARGO_INCREMENTAL+set}" != "set"; then + CARGO_INCREMENTAL="0" +fi + +AC_ARG_VAR([RUSTFLAGS], [Flags for Rust compiler]) +if test "${RUSTFLAGS+set}" != "set"; then + RUSTFLAGS="-C embed-bitcode=yes -C relocation-model=pic" +fi + AC_ARG_ENABLE([wallet], [AS_HELP_STRING([--disable-wallet], [disable wallet (enabled by default)])], @@ -1694,6 +1721,38 @@ if test "$use_zmq" = "yes"; then esac fi +RUST_LIBS="" +case $host in + *mingw*) + RUST_LIBS="$RUST_LIBS -luserenv -lntdll" + ;; + *) + RUST_LIBS="$RUST_LIBS -ldl" + ;; +esac + +RUST_TARGET="" +AC_MSG_CHECKING([for Rust target]) +case $host in + x86_64-*-freebsd*) RUST_TARGET="x86_64-unknown-freebsd" ;; + aarch64-*-linux*|arm64-*-linux*) + RUST_TARGET="aarch64-unknown-linux-gnu" ;; + arm-*-linux*) RUST_TARGET="armv7-unknown-linux-gnueabihf" ;; + powerpc64-*-linux*) RUST_TARGET="powerpc64-unknown-linux-gnu" ;; + powerpc64le-*-linux*) RUST_TARGET="powerpc64le-unknown-linux-gnu" ;; + riscv64-*-linux*) RUST_TARGET="riscv64gc-unknown-linux-gnu" ;; + x86_64-*-linux*) RUST_TARGET="x86_64-unknown-linux-gnu" ;; + x86_64-*-darwin*) RUST_TARGET="x86_64-apple-darwin" ;; + aarch64-*-darwin*|arm64-*-darwin*) + RUST_TARGET="aarch64-apple-darwin" ;; + x86_64-*-mingw*) RUST_TARGET="x86_64-pc-windows-gnu" ;; + *) + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Unsupported host for Rust: $host]) + ;; +esac +AC_MSG_RESULT([$RUST_TARGET]) + dnl check if libgmp is present TEMP_CPPFLAGS="$CPPFLAGS" TEMP_LDFLAGS="$LDFLAGS" @@ -1998,6 +2057,9 @@ AC_SUBST(BITCOIN_WALLET_TOOL_NAME) AC_SUBST(BITCOIN_MP_NODE_NAME) AC_SUBST(BITCOIN_MP_GUI_NAME) +AC_SUBST(RUST_LIBS) +AC_SUBST(RUST_TARGET) + AC_SUBST(RELDFLAGS) AC_SUBST(CORE_LDFLAGS) AC_SUBST(CORE_CPPFLAGS) @@ -2051,7 +2113,7 @@ AC_SUBST(HAVE_MM_PREFETCH) AC_SUBST(HAVE_STRONG_GETAUXVAL) AC_SUBST(ANDROID_ARCH) AC_SUBST(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR) -AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini]) +AC_CONFIG_FILES([Makefile rust/Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini]) AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh]) AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])]) AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py]) @@ -2145,3 +2207,9 @@ echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $CORE_LDFLAGS $BACKTRA echo " AR = $AR" echo " ARFLAGS = $ARFLAGS" echo +echo " CARGO = $CARGO" +echo " CARGO_INCREMENTAL = $CARGO_INCREMENTAL" +echo " CXXBRIDGE = $CXXBRIDGE" +echo " RUSTC = $RUSTC" +echo " RUSTFLAGS = $RUSTFLAGS" +echo diff --git a/contrib/guix/symbol-check.py b/contrib/guix/symbol-check.py index bca9029b24d8..b41cf4aaea69 100755 --- a/contrib/guix/symbol-check.py +++ b/contrib/guix/symbol-check.py @@ -150,10 +150,12 @@ PE_ALLOWED_LIBRARIES = { 'ADVAPI32.dll', # legacy security & registry +'api-ms-win-core-synch-l1-2-0.dll', # sync primitives (API set) 'bcrypt.dll', # newer security and identity API 'IPHLPAPI.DLL', # IP helper API 'KERNEL32.dll', # win32 base APIs 'msvcrt.dll', # C standard library for MSVC +'ntdll.dll', # NT kernel API 'SHELL32.dll', # shell API 'WS2_32.dll', # sockets 'dbghelp.dll', # debugging routines diff --git a/rust/Makefile.am b/rust/Makefile.am new file mode 100644 index 000000000000..b84eba45bddf --- /dev/null +++ b/rust/Makefile.am @@ -0,0 +1,32 @@ +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +CARGO_BUILD_OPTS = --release --locked --target $(RUST_TARGET) +CARGO_ENV = \ + AR="$(AR)" \ + CC="$(CC)" \ + CFLAGS="$(CFLAGS)" \ + CXX="$(CXX)" \ + CXXFLAGS="$(CXXFLAGS)" \ + CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ + RUSTC="$(RUSTC)" \ + RUSTFLAGS="$(RUSTFLAGS)" \ + TERM="dumb" + +if !SILENT_RULES +CARGO_BUILD_OPTS += --verbose +endif # !SILENT_RULES + +include $(top_srcdir)/rust/Makefile.libs.include + +all-local: cargo-build-chirp cxxbridge-chirp + +cargo-build: cargo-build-chirp + +cargo-clean: cargo-clean-chirp + +clean-local: cargo-clean-chirp cxxbridge-clean-chirp clean-librustdeps-la + +.PHONY: cargo-build cargo-clean diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include new file mode 100644 index 000000000000..44c5af3e49a7 --- /dev/null +++ b/rust/Makefile.chirp.include @@ -0,0 +1,49 @@ +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +LIBRUST_CHIRP_TARGET_DIR = $(abs_top_builddir)/rust/chirp/target +LIBRUST_CHIRP = $(LIBRUST_CHIRP_TARGET_DIR)/$(RUST_TARGET)/release/libchirp.a + +LIBRUST_CHIRP_CARGO_ENV = $(CARGO_ENV) CARGO_TARGET_DIR="$(LIBRUST_CHIRP_TARGET_DIR)" +LIBRUST_CHIRP_CRATE_DIR = $(top_srcdir)/rust/chirp +LIBRUST_CHIRP_GEN_DIR = $(abs_top_builddir)/rust/chirp/gen +LIBRUST_CHIRP_MANIFEST = $(LIBRUST_CHIRP_CRATE_DIR)/Cargo.toml +LIBRUST_CHIRP_CARGO_BUILD_OPTS = $(CARGO_BUILD_OPTS) --manifest-path $(LIBRUST_CHIRP_MANIFEST) + +LIBRUST_CHIRP_SRCS = \ + $(LIBRUST_CHIRP_CRATE_DIR)/src/lib.rs + +LIBRUST_CHIRP_BUILD = \ + $(LIBRUST_CHIRP_CRATE_DIR)/build.rs + +LIBRUST_CHIRP_CPP = \ + $(LIBRUST_CHIRP_GEN_DIR)/src/lib.cpp + +LIBRUST_CHIRP_H = \ + $(LIBRUST_CHIRP_GEN_DIR)/include/rust/chirp/lib.h + +LIBRUST_CHIRP_INCLUDES = \ + -I$(LIBRUST_CHIRP_GEN_DIR)/include + +$(LIBRUST_CHIRP_SRCS): ; + +$(LIBRUST_CHIRP_H) $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) + $(AM_V_at)$(MKDIR_P) $(@D) + $(AM_V_GEN)$(CXXBRIDGE) $< $(if $(filter %.h,$@),--header) -o $@ + +$(LIBRUST_CHIRP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_BUILD) $(LIBRUST_CHIRP_MANIFEST) + $(AM_V_GEN)$(LIBRUST_CHIRP_CARGO_ENV) $(CARGO) build $(LIBRUST_CHIRP_CARGO_BUILD_OPTS) + +cargo-build-chirp: $(LIBRUST_CHIRP) + +cargo-clean-chirp: + $(AM_V_at)rm -rf $(LIBRUST_CHIRP_TARGET_DIR) + +cxxbridge-clean-chirp: + $(AM_V_at)rm -rf $(LIBRUST_CHIRP_GEN_DIR) + +cxxbridge-chirp: $(LIBRUST_CHIRP_CPP) $(LIBRUST_CHIRP_H) + +.PHONY: cargo-build-chirp cargo-clean-chirp cxxbridge-chirp cxxbridge-clean-chirp diff --git a/rust/Makefile.libs.include b/rust/Makefile.libs.include new file mode 100644 index 000000000000..40772ba7b572 --- /dev/null +++ b/rust/Makefile.libs.include @@ -0,0 +1,50 @@ +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +include $(top_srcdir)/rust/Makefile.chirp.include + +LIBRUSTDEPS_A = \ + $(LIBRUST_CHIRP) + +LIBRUSTDEPS_INCLUDES = \ + $(LIBRUST_CHIRP_INCLUDES) + +LIBRUSTDEPS_CPP = \ + $(LIBRUST_CHIRP_CPP) + +LIBRUSTDEPS_H = \ + $(LIBRUST_CHIRP_H) + +# Libtool wrapper # +LIBRUSTDEPS = $(abs_top_builddir)/rust/librustdeps.la +LIBRUSTDEPS_LIBDIR = $(abs_top_builddir)/rust/.libs + +$(LIBRUSTDEPS): $(LIBRUSTDEPS_A) + $(AM_V_at)$(MKDIR_P) $(LIBRUSTDEPS_LIBDIR) + $(AM_V_at)rm -rf $(LIBRUSTDEPS_LIBDIR)/librustdeps.a $(LIBRUSTDEPS_LIBDIR)/objs + $(AM_V_at)$(MKDIR_P) $(LIBRUSTDEPS_LIBDIR)/objs + $(AM_V_at)for lib in $(LIBRUSTDEPS_A); do \ + cd $(LIBRUSTDEPS_LIBDIR)/objs && $(AR) -x $$lib; \ + done + $(AM_V_at)$(AR) crs $(LIBRUSTDEPS_LIBDIR)/librustdeps.a $(LIBRUSTDEPS_LIBDIR)/objs/*.o + $(AM_V_at)rm -rf $(LIBRUSTDEPS_LIBDIR)/objs + $(AM_V_at)$(RANLIB) $(LIBRUSTDEPS_LIBDIR)/librustdeps.a + $(AM_V_GEN)( \ + echo '# librustdeps.la - a libtool library file'; \ + echo '# Generated by Makefile.libs.include for libtool'; \ + echo "dlname=''"; \ + echo "library_names=''"; \ + echo "old_library='librustdeps.a'"; \ + echo "libdir='$(LIBRUSTDEPS_LIBDIR)'"; \ + echo "inherited_linker_flags=''"; \ + echo "installed=no"; \ + echo "shouldnotlink=no"; \ + ) > $@ + +clean-librustdeps-la: + rm -rf $(abs_top_builddir)/rust/.libs $(abs_top_builddir)/rust/librustdeps.la + +.PHONY: clean-librustdeps-la +# diff --git a/rust/chirp/build.rs b/rust/chirp/build.rs index 6840529bef3c..e57a97ad2171 100644 --- a/rust/chirp/build.rs +++ b/rust/chirp/build.rs @@ -1,5 +1,3 @@ fn main() { built::write_built_file().expect("Failed to write build info"); - cxx_build::bridge("src/lib.rs").compile("chirp"); - println!("cargo::rerun-if-changed=src/lib.rs"); } diff --git a/src/Makefile.am b/src/Makefile.am index fb1ffde2529a..ed415ded5dfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,6 @@ # Copyright (c) 2013-2016 The Bitcoin Core developers -# Copyright (c) 2014-2018 The Dash Core developers +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2014-2026 The Dash Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -7,6 +8,8 @@ print-%: FORCE @echo '$*'='$($*)' +include $(top_srcdir)/rust/Makefile.libs.include + DIST_SUBDIRS = secp256k1 AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(SANITIZER_LDFLAGS) $(CORE_LDFLAGS) $(BACKTRACE_LDFLAGS) @@ -21,6 +24,7 @@ AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) EXTRA_LIBRARIES = +BUILT_SOURCES = $(LIBRUSTDEPS_H) lib_LTLIBRARIES = noinst_LTLIBRARIES = @@ -48,6 +52,7 @@ endif # ENABLE_STACKTRACES BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) -I$(srcdir)/secp256k1/include -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(LEVELDB_CPPFLAGS) BITCOIN_INCLUDES+=-isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include BITCOIN_INCLUDES+=-isystem$(srcdir)/immer +BITCOIN_INCLUDES+=$(LIBRUSTDEPS_INCLUDES) LIBBITCOIN_NODE=libbitcoin_node.a LIBBITCOIN_COMMON=libbitcoin_common.a @@ -116,6 +121,8 @@ $(LIBDASHBLS): $(LIBSECP256K1): $(wildcard secp256k1/src/*.h) $(wildcard secp256k1/src/*.c) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) +LIBCXXBRIDGE=libcxxbridge.la + # Make is not made aware of per-object dependencies to avoid limiting building parallelization # But to build the less dependent modules first, we manually select their order here: EXTRA_LIBRARIES += \ @@ -129,6 +136,8 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_WALLET_TOOL) \ $(LIBBITCOIN_ZMQ) +noinst_LTLIBRARIES += $(LIBCXXBRIDGE) + if BUILD_BITCOIND bin_PROGRAMS += dashd endif @@ -1091,9 +1100,11 @@ bitcoin_bin_ldadd = \ $(LIBDASHBLS) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ - $(LIBSECP256K1) + $(LIBSECP256K1) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) -bitcoin_bin_ldadd += $(BACKTRACE_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(GMP_LIBS) +bitcoin_bin_ldadd += $(BACKTRACE_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(GMP_LIBS) $(RUST_LIBS) dashd_SOURCES = $(bitcoin_daemon_sources) init/bitcoind.cpp dashd_CPPFLAGS = $(bitcoin_bin_cppflags) @@ -1122,8 +1133,10 @@ dash_cli_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ - $(LIBBITCOIN_CRYPTO) -dash_cli_LDADD += $(BACKTRACE_LIBS) $(EVENT_LIBS) $(GMP_LIBS) + $(LIBBITCOIN_CRYPTO) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) +dash_cli_LDADD += $(BACKTRACE_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) # # dash-tx binary # @@ -1143,9 +1156,11 @@ dash_tx_LDADD = \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBDASHBLS) \ - $(LIBSECP256K1) + $(LIBSECP256K1) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) -dash_tx_LDADD += $(BACKTRACE_LIBS) $(GMP_LIBS) +dash_tx_LDADD += $(BACKTRACE_LIBS) $(GMP_LIBS) $(RUST_LIBS) # # dash-wallet binary # @@ -1164,11 +1179,14 @@ dash_wallet_LDADD = \ $(LIBBITCOIN_CRYPTO) \ $(LIBDASHBLS) \ $(LIBSECP256K1) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) \ $(BACKTRACE_LIBS) \ $(BOOST_LIBS) \ $(BDB_LIBS) \ $(SQLITE_LIBS) \ - $(GMP_LIBS) + $(GMP_LIBS) \ + $(RUST_LIBS) if TARGET_WINDOWS dash_wallet_SOURCES += dash-wallet-res.rc @@ -1192,9 +1210,11 @@ dash_util_LDADD = \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBSECP256K1) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) \ $(BACKTRACE_LIBS) -dash_util_LDADD += $(BOOST_LIBS) +dash_util_LDADD += $(BOOST_LIBS) $(RUST_LIBS) # dash-chainstate binary # dash_chainstate_SOURCES = bitcoin-chainstate.cpp @@ -1398,7 +1418,7 @@ include_HEADERS = script/bitcoinconsensus.h libdashconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(crypto_libbitcoin_crypto_sph_la_SOURCES) $(libbitcoin_consensus_a_SOURCES) libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) -libdashconsensus_la_LIBADD = $(LIBDASHBLS) $(LIBSECP256K1) $(GMP_LIBS) +libdashconsensus_la_LIBADD = $(LIBDASHBLS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) $(GMP_LIBS) $(RUST_LIBS) libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -DDISABLE_OPTIMIZED_SHA256 libdashconsensus_la_CPPFLAGS += -isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include libdashconsensus_la_CPPFLAGS += -isystem$(srcdir)/immer @@ -1407,6 +1427,15 @@ libdashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) endif # +# CXX bridge library # +libcxxbridge_la_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(PIC_FLAGS) +libcxxbridge_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(PIC_FLAGS) -static +libcxxbridge_la_LDFLAGS = $(AM_LDFLAGS) -static +libcxxbridge_la_SOURCES = $(LIBRUSTDEPS_CPP) + +$(libcxxbridge_la_OBJECTS): $(LIBRUSTDEPS_H) +# + CTAES_DIST = crypto/ctaes/bench.c CTAES_DIST += crypto/ctaes/ctaes.c CTAES_DIST += crypto/ctaes/ctaes.h diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 7dec51f2b0c1..63c5cc0f0f08 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -77,12 +77,15 @@ bench_bench_dash_LDADD = \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) \ $(LIBUNIVALUE) \ $(EVENT_PTHREADS_LIBS) \ $(EVENT_LIBS) \ $(MINIUPNPC_LIBS) \ $(NATPMP_LIBS) \ $(GMP_LIBS) \ + $(RUST_LIBS) \ $(BACKTRACE_LIBS) if ENABLE_ZMQ diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 16296207eca1..999745ceebb1 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -462,8 +462,8 @@ if ENABLE_ZMQ bitcoin_qt_ldadd += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif bitcoin_qt_ldadd += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBDASHBLS) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ - $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) + $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) bitcoin_qt_ldflags = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) bitcoin_qt_libtoolflags = $(AM_LIBTOOLFLAGS) --tag CXX diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 62071d40e5a5..535f466f26ec 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -60,8 +60,8 @@ qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBDASHBLS) $(LIBUNIVALUE) $(LIBLEVELDB) \ $(LIBMEMENV) $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ - $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) + $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) qt_test_test_dash_qt_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qt_test_test_dash_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index f83e11e2895e..dcf8b685fa8c 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -56,10 +56,13 @@ FUZZ_SUITE_LD_COMMON = \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ + $(LIBCXXBRIDGE) \ + $(LIBRUSTDEPS) \ $(MINISKETCH_LIBS) \ $(EVENT_LIBS) \ $(EVENT_PTHREADS_LIBS) \ $(GMP_LIBS) \ + $(RUST_LIBS) \ $(BACKTRACE_LIBS) if USE_UPNP @@ -271,10 +274,10 @@ test_test_dash_LDADD += $(LIBBITCOIN_WALLET) test_test_dash_CPPFLAGS += $(BDB_CPPFLAGS) endif test_test_dash_LDADD += $(LIBBITCOIN_NODE) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ - $(LIBDASHBLS) $(LIBLEVELDB) $(LIBMEMENV) $(BACKTRACE_LIBS) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS) + $(LIBDASHBLS) $(LIBLEVELDB) $(LIBMEMENV) $(BACKTRACE_LIBS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS) test_test_dash_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_dash_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(SQLITE_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) +test_test_dash_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(SQLITE_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) test_test_dash_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) -static if ENABLE_ZMQ From 2c640abb82c8f80e123b6263aef8f71d4336b153 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 16 Jan 2026 04:14:16 +0530 Subject: [PATCH 05/60] build: propagate SDK version to Rust compiler --- configure.ac | 11 +++++++++++ depends/Makefile | 1 + depends/config.site.in | 4 ++++ rust/Makefile.am | 1 + 4 files changed, 17 insertions(+) diff --git a/configure.ac b/configure.ac index 51f7e4b02b4e..0e45623d2e72 100644 --- a/configure.ac +++ b/configure.ac @@ -1731,6 +1731,15 @@ case $host in ;; esac +RUST_MACOS_DEPLOYMENT_TARGET="" +case $host in + *darwin*) + AC_MSG_CHECKING([for target macOS version]) + RUST_MACOS_DEPLOYMENT_TARGET="${OSX_MIN_VERSION:-$(sw_vers -productVersion)}" + AC_MSG_RESULT([$RUST_MACOS_DEPLOYMENT_TARGET]) + ;; +esac + RUST_TARGET="" AC_MSG_CHECKING([for Rust target]) case $host in @@ -2058,6 +2067,7 @@ AC_SUBST(BITCOIN_MP_NODE_NAME) AC_SUBST(BITCOIN_MP_GUI_NAME) AC_SUBST(RUST_LIBS) +AC_SUBST(RUST_MACOS_DEPLOYMENT_TARGET) AC_SUBST(RUST_TARGET) AC_SUBST(RELDFLAGS) @@ -2212,4 +2222,5 @@ echo " CARGO_INCREMENTAL = $CARGO_INCREMENTAL" echo " CXXBRIDGE = $CXXBRIDGE" echo " RUSTC = $RUSTC" echo " RUSTFLAGS = $RUSTFLAGS" +echo " RUST_MACOS_DEPLOYMENT_TARGET = $RUST_MACOS_DEPLOYMENT_TARGET" echo diff --git a/depends/Makefile b/depends/Makefile index c8510f4cc010..3f76f049fc6c 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -239,6 +239,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@STRIP@|$(host_STRIP)|' \ -e 's|@OBJDUMP@|$(host_OBJDUMP)|' \ -e 's|@DSYMUTIL@|$(host_DSYMUTIL)|' \ + -e 's|@OSX_MIN_VERSION@|$(OSX_MIN_VERSION)|' \ -e 's|@WINDRES@|$(host_WINDRES)|' \ -e 's|@build_os@|$(build_os)|' \ -e 's|@host_os@|$(host_os)|' \ diff --git a/depends/config.site.in b/depends/config.site.in index 398a09b74c63..f5bf6312fdbb 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -129,6 +129,10 @@ if test "@host_os@" = darwin; then DSYMUTIL="@DSYMUTIL@" ac_cv_path_DSYMUTIL="${DSYMUTIL}" fi + + if test -n "@OSX_MIN_VERSION@"; then + OSX_MIN_VERSION="@OSX_MIN_VERSION@" + fi fi if test "@host_os@" = mingw32; then diff --git a/rust/Makefile.am b/rust/Makefile.am index b84eba45bddf..e9cf2a8c1af3 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -10,6 +10,7 @@ CARGO_ENV = \ CFLAGS="$(CFLAGS)" \ CXX="$(CXX)" \ CXXFLAGS="$(CXXFLAGS)" \ + MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ RUSTC="$(RUSTC)" \ RUSTFLAGS="$(RUSTFLAGS)" \ From d5cc4575dfa37082d20cf1d816d6a7967f47368c Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 18 Jan 2026 09:23:15 +0530 Subject: [PATCH 06/60] build: propagate macOS SDK path to Rust compiler --- configure.ac | 16 ++++++++++++++++ depends/Makefile | 1 + depends/config.site.in | 4 ++++ rust/Makefile.am | 3 ++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0e45623d2e72..1addb7de7289 100644 --- a/configure.ac +++ b/configure.ac @@ -1762,6 +1762,20 @@ case $host in esac AC_MSG_RESULT([$RUST_TARGET]) +RUST_OSX_SDK="" +case $host in + *darwin*) + AC_MSG_CHECKING([for Xcode SDK]) + if test -z "$OSX_SDK"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires OSX_SDK to be set to path of Xcode SDK, cannot continue!]) + fi + fi + RUST_OSX_SDK="${OSX_SDK:-$(xcrun --sdk macosx --show-sdk-path)}" + AC_MSG_RESULT([$RUST_OSX_SDK]) + ;; +esac + dnl check if libgmp is present TEMP_CPPFLAGS="$CPPFLAGS" TEMP_LDFLAGS="$LDFLAGS" @@ -2068,6 +2082,7 @@ AC_SUBST(BITCOIN_MP_GUI_NAME) AC_SUBST(RUST_LIBS) AC_SUBST(RUST_MACOS_DEPLOYMENT_TARGET) +AC_SUBST(RUST_OSX_SDK) AC_SUBST(RUST_TARGET) AC_SUBST(RELDFLAGS) @@ -2223,4 +2238,5 @@ echo " CXXBRIDGE = $CXXBRIDGE" echo " RUSTC = $RUSTC" echo " RUSTFLAGS = $RUSTFLAGS" echo " RUST_MACOS_DEPLOYMENT_TARGET = $RUST_MACOS_DEPLOYMENT_TARGET" +echo " RUST_OSX_SDK = $RUST_OSX_SDK" echo diff --git a/depends/Makefile b/depends/Makefile index 3f76f049fc6c..bc86d7243f53 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -240,6 +240,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@OBJDUMP@|$(host_OBJDUMP)|' \ -e 's|@DSYMUTIL@|$(host_DSYMUTIL)|' \ -e 's|@OSX_MIN_VERSION@|$(OSX_MIN_VERSION)|' \ + -e 's|@OSX_SDK@|$(OSX_SDK)|' \ -e 's|@WINDRES@|$(host_WINDRES)|' \ -e 's|@build_os@|$(build_os)|' \ -e 's|@host_os@|$(host_os)|' \ diff --git a/depends/config.site.in b/depends/config.site.in index f5bf6312fdbb..6fdad01f5624 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -133,6 +133,10 @@ if test "@host_os@" = darwin; then if test -n "@OSX_MIN_VERSION@"; then OSX_MIN_VERSION="@OSX_MIN_VERSION@" fi + + if test -n "@OSX_SDK@"; then + OSX_SDK="@OSX_SDK@" + fi fi if test "@host_os@" = mingw32; then diff --git a/rust/Makefile.am b/rust/Makefile.am index e9cf2a8c1af3..1b5e6927f9da 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -14,7 +14,8 @@ CARGO_ENV = \ CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ RUSTC="$(RUSTC)" \ RUSTFLAGS="$(RUSTFLAGS)" \ - TERM="dumb" + TERM="dumb" \ + ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} if !SILENT_RULES CARGO_BUILD_OPTS += --verbose From bc820fc2f71da68711095e719499bef3beeca11c Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:00:33 +0530 Subject: [PATCH 07/60] build: use debug profile for Rust components if `--enable-debug` set --- configure.ac | 1 + rust/Makefile.am | 6 +++++- rust/Makefile.chirp.include | 2 +- rust/Makefile.libs.include | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1addb7de7289..6d10fdde8d91 100644 --- a/configure.ac +++ b/configure.ac @@ -302,6 +302,7 @@ AC_ARG_ENABLE([debug], [use compiler flags and macros suited for debugging (default is no)])], [enable_debug=$enableval], [enable_debug=no]) +AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = "yes"]) dnl Enable exception stacktraces AC_ARG_ENABLE([stacktraces], diff --git a/rust/Makefile.am b/rust/Makefile.am index 1b5e6927f9da..1286ab37c4cc 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -3,7 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -CARGO_BUILD_OPTS = --release --locked --target $(RUST_TARGET) +CARGO_BUILD_OPTS = --locked --target $(RUST_TARGET) CARGO_ENV = \ AR="$(AR)" \ CC="$(CC)" \ @@ -17,6 +17,10 @@ CARGO_ENV = \ TERM="dumb" \ ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} +if !ENABLE_DEBUG +CARGO_BUILD_OPTS += --release +endif # !ENABLE_DEBUG + if !SILENT_RULES CARGO_BUILD_OPTS += --verbose endif # !SILENT_RULES diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 44c5af3e49a7..8e575a1c9704 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. LIBRUST_CHIRP_TARGET_DIR = $(abs_top_builddir)/rust/chirp/target -LIBRUST_CHIRP = $(LIBRUST_CHIRP_TARGET_DIR)/$(RUST_TARGET)/release/libchirp.a +LIBRUST_CHIRP = $(LIBRUST_CHIRP_TARGET_DIR)/$(RUST_TARGET)/$(CARGO_PROFILE)/libchirp.a LIBRUST_CHIRP_CARGO_ENV = $(CARGO_ENV) CARGO_TARGET_DIR="$(LIBRUST_CHIRP_TARGET_DIR)" LIBRUST_CHIRP_CRATE_DIR = $(top_srcdir)/rust/chirp diff --git a/rust/Makefile.libs.include b/rust/Makefile.libs.include index 40772ba7b572..f74839887523 100644 --- a/rust/Makefile.libs.include +++ b/rust/Makefile.libs.include @@ -3,6 +3,12 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +if ENABLE_DEBUG +CARGO_PROFILE=debug +else +CARGO_PROFILE=release +endif + include $(top_srcdir)/rust/Makefile.chirp.include LIBRUSTDEPS_A = \ From d546501484443ad442c44be5c5df7da5b2afbb01 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 17 Jan 2026 16:21:39 +0530 Subject: [PATCH 08/60] build: propagate target build variables to Rust components Co-authored-by: pasta --- rust/Makefile.am | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust/Makefile.am b/rust/Makefile.am index 1286ab37c4cc..daf1c3d52577 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -4,12 +4,20 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. CARGO_BUILD_OPTS = --locked --target $(RUST_TARGET) + +# 'cc' needs preserved case +RUST_TARGET_ENV_LOWER = $(shell echo '$(RUST_TARGET)' | tr '-' '_') CARGO_ENV = \ AR="$(AR)" \ + AR_$(RUST_TARGET_ENV_LOWER)="$(AR)" \ CC="$(CC)" \ + CC_$(RUST_TARGET_ENV_LOWER)="$(CC)" \ CFLAGS="$(CFLAGS)" \ + CFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CFLAGS)" \ CXX="$(CXX)" \ + CXX_$(RUST_TARGET_ENV_LOWER)="$(CXX)" \ CXXFLAGS="$(CXXFLAGS)" \ + CXXFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CXXFLAGS)" \ MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ RUSTC="$(RUSTC)" \ From 1190de30a92c7b9da7f5a34589cf189e8d508856 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 23 Jan 2026 01:07:43 +0530 Subject: [PATCH 09/60] build: propagate host build variables to Rust components Needed for cross-compilation to work correctly --- configure.ac | 90 +++++++++++++++++++++++++++-------- contrib/guix/libexec/build.sh | 5 ++ depends/Makefile | 3 ++ depends/config.site.in | 11 +++++ rust/Makefile.am | 31 +++++++----- 5 files changed, 109 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 6d10fdde8d91..0712f12de773 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,7 @@ if test "${ARFLAGS+set}" != "set"; then ARFLAGS="cr" fi +AC_CANONICAL_BUILD AC_CANONICAL_HOST AH_TOP([#ifndef DASH_CONFIG_H]) @@ -1741,26 +1742,30 @@ case $host in ;; esac -RUST_TARGET="" +AC_DEFUN([RS_SET_TRIPLE], [ + case $2 in + x86_64-*-freebsd*) $1="x86_64-unknown-freebsd" ;; + aarch64-*-linux*|arm64-*-linux*) + $1="aarch64-unknown-linux-gnu" ;; + arm-*-linux*) $1="armv7-unknown-linux-gnueabihf" ;; + powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; + powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-gnu" ;; + riscv64-*-linux*) $1="riscv64gc-unknown-linux-gnu" ;; + x86_64-*-linux*) $1="x86_64-unknown-linux-gnu" ;; + x86_64-*-darwin*) $1="x86_64-apple-darwin" ;; + aarch64-*-darwin*|arm64-*-darwin*) + $1="aarch64-apple-darwin" ;; + x86_64-*-mingw*) $1="x86_64-pc-windows-gnu" ;; + *) $1="" ;; + esac +]) + AC_MSG_CHECKING([for Rust target]) -case $host in - x86_64-*-freebsd*) RUST_TARGET="x86_64-unknown-freebsd" ;; - aarch64-*-linux*|arm64-*-linux*) - RUST_TARGET="aarch64-unknown-linux-gnu" ;; - arm-*-linux*) RUST_TARGET="armv7-unknown-linux-gnueabihf" ;; - powerpc64-*-linux*) RUST_TARGET="powerpc64-unknown-linux-gnu" ;; - powerpc64le-*-linux*) RUST_TARGET="powerpc64le-unknown-linux-gnu" ;; - riscv64-*-linux*) RUST_TARGET="riscv64gc-unknown-linux-gnu" ;; - x86_64-*-linux*) RUST_TARGET="x86_64-unknown-linux-gnu" ;; - x86_64-*-darwin*) RUST_TARGET="x86_64-apple-darwin" ;; - aarch64-*-darwin*|arm64-*-darwin*) - RUST_TARGET="aarch64-apple-darwin" ;; - x86_64-*-mingw*) RUST_TARGET="x86_64-pc-windows-gnu" ;; - *) - AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Unsupported host for Rust: $host]) - ;; -esac +RS_SET_TRIPLE([RUST_TARGET], [$host]) +if test "$RUST_TARGET" = ""; then + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Unsupported target for Rust: $host]) +fi AC_MSG_RESULT([$RUST_TARGET]) RUST_OSX_SDK="" @@ -1777,6 +1782,44 @@ case $host in ;; esac +AC_MSG_CHECKING([for Rust host]) +RS_SET_TRIPLE([RUST_NATIVE], [$build]) +if test "$RUST_NATIVE" = ""; then + if test "$cross_compiling" = "yes"; then + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Unsupported host for Rust: $build]) + fi + RUST_NATIVE="$RUST_TARGET" +fi +AC_MSG_RESULT([$RUST_NATIVE]) + +AC_MSG_CHECKING([for host archiver]) +if test -z "$NATIVE_AR"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires NATIVE_AR to be set to host archiver, cannot continue!]) + fi + NATIVE_AR="$AR" +fi +AC_MSG_RESULT([$NATIVE_AR]) + +AC_MSG_CHECKING([for host C compiler]) +if test -z "$NATIVE_CC"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires NATIVE_CC to be set to host C compiler, cannot continue!]) + fi + NATIVE_CC="$CC" +fi +AC_MSG_RESULT([$NATIVE_CC]) + +AC_MSG_CHECKING([for host C++ compiler]) +if test -z "$NATIVE_CXX"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires NATIVE_CXX to be set to host C++ compiler, cannot continue!]) + fi + NATIVE_CXX="$CXX" +fi +AC_MSG_RESULT([$NATIVE_CXX]) + dnl check if libgmp is present TEMP_CPPFLAGS="$CPPFLAGS" TEMP_LDFLAGS="$LDFLAGS" @@ -2081,8 +2124,12 @@ AC_SUBST(BITCOIN_WALLET_TOOL_NAME) AC_SUBST(BITCOIN_MP_NODE_NAME) AC_SUBST(BITCOIN_MP_GUI_NAME) +AC_SUBST(NATIVE_AR) +AC_SUBST(NATIVE_CC) +AC_SUBST(NATIVE_CXX) AC_SUBST(RUST_LIBS) AC_SUBST(RUST_MACOS_DEPLOYMENT_TARGET) +AC_SUBST(RUST_NATIVE) AC_SUBST(RUST_OSX_SDK) AC_SUBST(RUST_TARGET) @@ -2236,8 +2283,13 @@ echo echo " CARGO = $CARGO" echo " CARGO_INCREMENTAL = $CARGO_INCREMENTAL" echo " CXXBRIDGE = $CXXBRIDGE" +echo " NATIVE_AR = $NATIVE_AR" +echo " NATIVE_CC = $NATIVE_CC" +echo " NATIVE_CXX = $NATIVE_CXX" echo " RUSTC = $RUSTC" echo " RUSTFLAGS = $RUSTFLAGS" echo " RUST_MACOS_DEPLOYMENT_TARGET = $RUST_MACOS_DEPLOYMENT_TARGET" +echo " RUST_NATIVE = $RUST_NATIVE" echo " RUST_OSX_SDK = $RUST_OSX_SDK" +echo " RUST_TARGET = $RUST_TARGET" echo diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 0c9fda7ad11d..fd67e258a70d 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -249,6 +249,11 @@ case "$HOST" in *linux*) HOST_LDFLAGS+=" -static-libstdc++ -static-libgcc" ;; esac +case "$HOST" in + *darwin*) export NATIVE_AR="llvm-ar" NATIVE_CC="clang" NATIVE_CXX="clang++" ;; + *) export NATIVE_AR="ar" NATIVE_CC="gcc" NATIVE_CXX="g++" ;; +esac + mkdir -p "$DISTSRC" ( cd "$DISTSRC" diff --git a/depends/Makefile b/depends/Makefile index bc86d7243f53..8c3b0dc4362a 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -232,8 +232,11 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ @mkdir -p $(@D) sed -e 's|@HOST@|$(host)|' \ -e 's|@CC@|$(host_CC)|' \ + -e 's|@NATIVE_CC@|$(build_CC)|' \ -e 's|@CXX@|$(host_CXX)|' \ + -e 's|@NATIVE_CXX@|$(build_CXX)|' \ -e 's|@AR@|$(host_AR)|' \ + -e 's|@NATIVE_AR@|$(build_AR)|' \ -e 's|@RANLIB@|$(host_RANLIB)|' \ -e 's|@NM@|$(host_NM)|' \ -e 's|@STRIP@|$(host_STRIP)|' \ diff --git a/depends/config.site.in b/depends/config.site.in index 6fdad01f5624..f27691228ab1 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -95,14 +95,25 @@ LDFLAGS="-L${depends_prefix}/lib ${LDFLAGS}" if test -n "@CC@" -a -z "${CC}"; then CC="@CC@" fi +if test -n "@NATIVE_CC@" -a -z "${NATIVE_CC}"; then + NATIVE_CC="@NATIVE_CC@" +fi + if test -n "@CXX@" -a -z "${CXX}"; then CXX="@CXX@" fi +if test -n "@NATIVE_CXX@" -a -z "${NATIVE_CXX}"; then + NATIVE_CXX="@NATIVE_CXX@" +fi if test -n "@AR@"; then AR="@AR@" ac_cv_path_AR="${AR}" fi +if test -n "@NATIVE_AR@"; then + NATIVE_AR="@NATIVE_AR@" + ac_cv_path_NATIVE_AR="${NATIVE_AR}" +fi if test -n "@RANLIB@"; then RANLIB="@RANLIB@" diff --git a/rust/Makefile.am b/rust/Makefile.am index daf1c3d52577..10a5bd8d241a 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -4,26 +4,33 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. CARGO_BUILD_OPTS = --locked --target $(RUST_TARGET) +CARGO_ENV = \ + MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ + CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ + RUSTC="$(RUSTC)" \ + RUSTFLAGS="$(RUSTFLAGS)" \ + TERM="dumb" \ + ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} + +# 'cargo' needs uppercase +RUST_NATIVE_ENV_UPPER = $(shell echo '$(RUST_NATIVE)' | tr 'a-z-' 'A-Z_') +CARGO_ENV += \ + AR="$(NATIVE_AR)" \ + CC="$(NATIVE_CC)" \ + CXX="$(NATIVE_CXX)" \ + CARGO_TARGET_$(RUST_NATIVE_ENV_UPPER)_LINKER="$(NATIVE_CC)" # 'cc' needs preserved case RUST_TARGET_ENV_LOWER = $(shell echo '$(RUST_TARGET)' | tr '-' '_') -CARGO_ENV = \ - AR="$(AR)" \ +# 'cargo' needs uppercase +RUST_TARGET_ENV_UPPER = $(shell echo '$(RUST_TARGET_ENV_LOWER)' | tr 'a-z' 'A-Z') +CARGO_ENV += \ AR_$(RUST_TARGET_ENV_LOWER)="$(AR)" \ - CC="$(CC)" \ CC_$(RUST_TARGET_ENV_LOWER)="$(CC)" \ - CFLAGS="$(CFLAGS)" \ CFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CFLAGS)" \ - CXX="$(CXX)" \ CXX_$(RUST_TARGET_ENV_LOWER)="$(CXX)" \ - CXXFLAGS="$(CXXFLAGS)" \ CXXFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CXXFLAGS)" \ - MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ - CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ - RUSTC="$(RUSTC)" \ - RUSTFLAGS="$(RUSTFLAGS)" \ - TERM="dumb" \ - ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} + CARGO_TARGET_$(RUST_TARGET_ENV_UPPER)_LINKER="$(CC)" if !ENABLE_DEBUG CARGO_BUILD_OPTS += --release From 0c91bbbdcc7db39ce720fc14ee3c429f8aa81778 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 16 Jan 2026 02:53:18 +0530 Subject: [PATCH 10/60] debug: Add log that validates successful FFI invocation at init This can be removed alongside the whole minimal crate when we have actual crates to slot in. --- src/init.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 7bb5019fd4b4..b3c66f8e1a2f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -126,6 +126,8 @@ #include #endif // ENABLE_WALLET +#include + #include #include #include @@ -1476,6 +1478,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return false; } + LogPrintf("%s\n", std::string(chirp::chirp())); + LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); // Warn about relative -datadir path. From 5353138e0f8c44ebc43889ed48a29952ea39434a Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 17 Jan 2026 17:16:54 +0530 Subject: [PATCH 11/60] depends: integrate Rust and `cxxbridge` into depends --- contrib/devtools/update-native-cxxbridge.py | 93 ++++ contrib/devtools/update-rust-hashes.py | 107 ++++ depends/Makefile | 1 + depends/config.site.in | 10 + depends/funcs.mk | 12 + depends/packages/native_cxxbridge.mk | 28 + depends/packages/native_rust.mk | 105 ++++ depends/packages/packages.mk | 4 +- depends/packages/rustcxx.mk | 17 + depends/patches/native_cxxbridge/Cargo.lock | 584 ++++++++++++++++++++ 10 files changed, 960 insertions(+), 1 deletion(-) create mode 100755 contrib/devtools/update-native-cxxbridge.py create mode 100755 contrib/devtools/update-rust-hashes.py create mode 100644 depends/packages/native_cxxbridge.mk create mode 100644 depends/packages/native_rust.mk create mode 100644 depends/packages/rustcxx.mk create mode 100644 depends/patches/native_cxxbridge/Cargo.lock diff --git a/contrib/devtools/update-native-cxxbridge.py b/contrib/devtools/update-native-cxxbridge.py new file mode 100755 index 000000000000..2628912612e0 --- /dev/null +++ b/contrib/devtools/update-native-cxxbridge.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +import re +import shutil +import subprocess +import sys +import tarfile +import tempfile +from pathlib import Path + +def get_cxx_version(makefile_path: Path) -> str: + content = makefile_path.read_text() + match = re.search(r"\$\(package\)_version:=(.+)", content) + if not match: + raise RuntimeError("Could not find cxx version in makefile") + return match.group(1).strip() + + +def main() -> int: + script_dir = Path(__file__).resolve().parent + repo_root = script_dir / "../.." + repo_root = repo_root.resolve() + + makefile_path = repo_root / "depends/packages/native_cxxbridge.mk" + if not makefile_path.exists(): + print(f"Error: {makefile_path} not found", file=sys.stderr) + return 1 + + version = get_cxx_version(makefile_path) + print(f"cxx version: {version}") + + tarball_path = repo_root / f"depends/sources/native_cxxbridge-{version}.tar.gz" + if not tarball_path.exists(): + print(f"Error: {tarball_path} not found", file=sys.stderr) + print("Run 'make -C depends download-one PKG=native_cxxbridge' first", file=sys.stderr) + return 1 + + toolchain_path = repo_root / "rust-toolchain.toml" + if not toolchain_path.exists(): + print(f"Error: {toolchain_path} not found", file=sys.stderr) + return 1 + + with tempfile.TemporaryDirectory() as tmp_dir: + tmp_path = Path(tmp_dir) + print(f"Working in {tmp_path}") + + # Copy rust-toolchain.toml + shutil.copy(toolchain_path, tmp_path / "rust-toolchain.toml") + + # Extract tarball + print(f"Extracting {tarball_path}") + with tarfile.open(tarball_path, "r:gz") as tar: + tar.extractall(tmp_path) + + cxx_dir = tmp_path / f"cxx-{version}" + if not cxx_dir.exists(): + print(f"Error: Expected directory {cxx_dir} not found after extraction", file=sys.stderr) + return 1 + + # Copy rust-toolchain.toml into cxx directory + shutil.copy(toolchain_path, cxx_dir / "rust-toolchain.toml") + + # Run cargo check + print("Running cargo check --release --package=cxxbridge-cmd --bin=cxxbridge") + result = subprocess.run( + ["cargo", "check", "--release", "--package=cxxbridge-cmd", "--bin=cxxbridge"], + cwd=cxx_dir, + ) + if result.returncode != 0: + print("Error: cargo check failed", file=sys.stderr) + return 1 + + # Copy Cargo.lock to patches directory + cargo_lock_src = cxx_dir / "Cargo.lock" + cargo_lock_dst = repo_root / "depends/patches/native_cxxbridge/Cargo.lock" + if not cargo_lock_src.exists(): + print(f"Error: {cargo_lock_src} not found after cargo check", file=sys.stderr) + return 1 + + cargo_lock_dst.parent.mkdir(parents=True, exist_ok=True) + shutil.copy(cargo_lock_src, cargo_lock_dst) + print(f"Copied Cargo.lock to {cargo_lock_dst}") + + print("\nDone!") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py new file mode 100755 index 000000000000..87f0d4d53263 --- /dev/null +++ b/contrib/devtools/update-rust-hashes.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2021-2022 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +import hashlib +import re +import sys +import urllib.request +from pathlib import Path + +# Corresponds to 'hosts/*.mk' +CROSS_TARGETS = [ + # FreeBSD + "x86_64-unknown-freebsd", + # Linux + "aarch64-unknown-linux-gnu", + "armv7-unknown-linux-gnueabihf", + "powerpc64le-unknown-linux-gnu", + "riscv64gc-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + # Windows + "x86_64-pc-windows-gnu", + # macOS + "aarch64-apple-darwin", + "x86_64-apple-darwin", +] + +# Corresponds to 'builders/*.mk' +NATIVE_TARGETS = [ + # FreeBSD + ("x86_64-unknown-freebsd", "x86_64_freebsd"), + # Linux + ("aarch64-unknown-linux-gnu", "aarch64_linux"), + ("x86_64-unknown-linux-gnu", "x86_64_linux"), + # macOS + ("aarch64-apple-darwin", "aarch64_darwin"), + ("x86_64-apple-darwin", "x86_64_darwin"), +] + +def get_rust_version(makefile_path: Path) -> str: + content = makefile_path.read_text() + match = re.search(r"\$\(package\)_version:=(.+)", content) + if not match: + raise RuntimeError("Could not find Rust version in makefile") + return match.group(1).strip() + + +def compute_sha256(url: str) -> str: + hasher = hashlib.sha256() + with urllib.request.urlopen(url) as response: + while chunk := response.read(8192): + hasher.update(chunk) + return hasher.hexdigest() + + +def update_hash_in_file(makefile_path: Path, pattern: str, new_hash: str) -> None: + content = makefile_path.read_text() + regex = re.compile(rf"^(\$\(package\)_{pattern}:=).*$", re.MULTILINE) + if not regex.search(content): + raise RuntimeError(f"Could not find pattern {pattern} in makefile") + new_content = regex.sub(rf"\g<1>{new_hash}", content) + makefile_path.write_text(new_content) + + +def update_rust_hash(makefile_path: Path, rust_version: str, rust_target: str, makefile_id: str) -> None: + url = f"https://static.rust-lang.org/dist/rust-{rust_version}-{rust_target}.tar.gz" + hash_value = compute_sha256(url) + update_hash_in_file(makefile_path, f"sha256_hash_{makefile_id}", hash_value) + print(f" Updated sha256_hash_{makefile_id}") + + +def update_stdlib_hash(makefile_path: Path, rust_version: str, rust_target: str) -> None: + url = f"https://static.rust-lang.org/dist/rust-std-{rust_version}-{rust_target}.tar.gz" + hash_value = compute_sha256(url) + update_hash_in_file(makefile_path, f"rust_std_sha256_hash_{rust_target}", hash_value) + print(f" Updated rust_std_sha256_hash_{rust_target}") + + +def main() -> int: + script_dir = Path(__file__).resolve().parent + makefile_path = script_dir / "../../depends/packages/native_rust.mk" + makefile_path = makefile_path.resolve() + + if not makefile_path.exists(): + print(f"Error: {makefile_path} not found", file=sys.stderr) + return 1 + + rust_version = get_rust_version(makefile_path) + + print(f"Rust version: {rust_version}\n") + print("Updating native compiler hashes:") + + for rust_target, makefile_id in NATIVE_TARGETS: + update_rust_hash(makefile_path, rust_version, rust_target, makefile_id) + + for rust_target in CROSS_TARGETS: + update_stdlib_hash(makefile_path, rust_version, rust_target) + + print("\nDone!") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/depends/Makefile b/depends/Makefile index 8c3b0dc4362a..ff7b7bf98c64 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -179,6 +179,7 @@ usdt_packages_$(NO_USDT) = $(usdt_$(host_os)_packages) packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(boost_packages_) $(libevent_packages_) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) $(natpmp_packages_) $(usdt_packages_) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) +native_packages += $(rust_native_packages) ifneq ($(zmq_packages_),) packages += $(zmq_packages) diff --git a/depends/config.site.in b/depends/config.site.in index f27691228ab1..6eb88d8aaeb1 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -173,3 +173,13 @@ fi if test -n "@LDFLAGS@"; then LDFLAGS="@LDFLAGS@ ${LDFLAGS}" fi + +if test -x "${depends_prefix}/native/bin/cargo"; then + CARGO="${depends_prefix}/native/bin/cargo" +fi +if test -x "${depends_prefix}/native/bin/rustc"; then + RUSTC="${depends_prefix}/native/bin/rustc" +fi +if test -x "${depends_prefix}/native/bin/cxxbridge"; then + CXXBRIDGE="${depends_prefix}/native/bin/cxxbridge" +fi diff --git a/depends/funcs.mk b/depends/funcs.mk index 566f83a9868e..4a6150a5254f 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -197,6 +197,18 @@ $(1)_cmake += -DCMAKE_C_COMPILER_TARGET=$(host) $(1)_cmake += -DCMAKE_CXX_COMPILER_TARGET=$(host) endif endif + +$(1)_cargo=env CC="$$($(1)_cc)" \ + CXX="$$($(1)_cxx)" \ + CFLAGS="$$($(1)_cppflags) $$($(1)_cflags)" \ + CXXFLAGS="$$($(1)_cppflags) $$($(1)_cxxflags)" \ + LDFLAGS="$$($(1)_ldflags)" \ + RUSTFLAGS="-C linker=$$(firstword $($(1)_cc))" \ + LD_LIBRARY_PATH="$$($($(1)_type)_prefix)/lib" +ifeq ($(host_os),darwin) +$(1)_cargo += SDKROOT="$(OSX_SDK)" +endif +$(1)_cargo += cargo endef define int_add_cmds diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk new file mode 100644 index 000000000000..ca3580c38dff --- /dev/null +++ b/depends/packages/native_cxxbridge.mk @@ -0,0 +1,28 @@ +# Copyright (c) 2022-2025 The Zcash developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# To update the package, change the version below and then run the script +# ./contrib/devtools/update-native-cxxbridge.py + +package:=native_cxxbridge +$(package)_version:=1.0.192 +$(package)_download_path:=https://github.com/dtolnay/cxx/archive/refs/tags +$(package)_file_name:=native_cxxbridge-$($(package)_version).tar.gz +$(package)_download_file:=$($(package)_version).tar.gz +$(package)_sha256_hash:=d242dbfb6deb362c5a95fcb69aeb5f25228de75af3cced94c9f6c8e11019d30e +$(package)_build_subdir:=gen/cmd +$(package)_dependencies:=native_rust +$(package)_patches:=Cargo.lock + +define $(package)_preprocess_cmds + cp $($(package)_patch_dir)/Cargo.lock . +endef + +define $(package)_build_cmds + $($(package)_cargo) build --locked --release --package=cxxbridge-cmd --bin=cxxbridge +endef + +define $(package)_stage_cmds + $($(package)_cargo) install --locked --path=. --bin=cxxbridge --root=$($(package)_staging_prefix_dir) +endef diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk new file mode 100644 index 000000000000..54c293fe6508 --- /dev/null +++ b/depends/packages/native_rust.mk @@ -0,0 +1,105 @@ +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# To update the Rust compiler, change the version below and then run the script +# ./contrib/devtools/update-rust-hashes.py + +package:=native_rust +$(package)_version:=1.82.0 +$(package)_download_path:=https://static.rust-lang.org/dist + +# FreeBSD (x86_64) +$(package)_rust_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd +$(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz +$(package)_sha256_hash_x86_64_freebsd:=f7b51943dbed0af3387e3269c1767fee916fb22b8e7897b3594bf5e422403137 +$(package)_rust_std_sha256_hash_x86_64-unknown-freebsd:=be1acaf3c2f15d42b05b1f032db5ac3b11a0ac5a91c0efef26f2d8135d68a829 + +# Linux (ARMv8) +$(package)_rust_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-gnu +$(package)_file_name_aarch64_linux:=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz +$(package)_sha256_hash_aarch64_linux:=d7db04fce65b5f73282941f3f1df5893be9810af17eb7c65b2e614461fe31a48 +$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu:=82b2308ee531775bf4d1faa57bddfae85f363bec43ca36ba6db4ebad7c1450d4 + +# Linux (x86_64) +$(package)_rust_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-gnu +$(package)_file_name_x86_64_linux:=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz +$(package)_sha256_hash_x86_64_linux:=0265c08ae997c4de965048a244605fb1f24a600bbe35047b811c638b8fcf676b +$(package)_rust_std_sha256_hash_x86_64-unknown-linux-gnu:=e7e808b8745298369fa3bbc3c0b7af9ca0fb995661bd684a7022d14bc9ae0057 + +# macOS (x86_64) +$(package)_rust_target_x86_64-apple-darwin:=x86_64-apple-darwin +$(package)_file_name_x86_64_darwin:=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz +$(package)_sha256_hash_x86_64_darwin:=b1a289cabc523f259f65116a41374ac159d72fbbf6c373bd5e545c8e835ceb6a +$(package)_rust_std_sha256_hash_x86_64-apple-darwin:=52084c8cdb34ca139a00f9f03f1a582d96b677e9f223a8d1aa31ae575a06cc16 + +# macOS (ARMv8) +$(package)_rust_target_aarch64-apple-darwin:=aarch64-apple-darwin +$(package)_rust_target_arm64-apple-darwin:=aarch64-apple-darwin +$(package)_file_name_aarch64_darwin:=rust-$($(package)_version)-aarch64-apple-darwin.tar.gz +$(package)_sha256_hash_aarch64_darwin:=49b6d36b308addcfd21ae56c94957688338ba7b8985bff57fc626c8e1b32f62c +$(package)_rust_std_sha256_hash_aarch64-apple-darwin:=5ec28e75ed8715efaa2490d76ae026a34b13df6899d98b14d0a6995556f4e6b4 + +# Linux (ARMv7) - Cross only +$(package)_rust_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf +$(package)_rust_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf +$(package)_rust_std_sha256_hash_armv7-unknown-linux-gnueabihf:=5dd8b36467e03ba47bfa7ea5d7578c66bccb648dd2129d7cec6fb3ff00f81ca3 + +# Linux (PowerPC 64-bit) - Cross only +$(package)_rust_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-gnu +$(package)_rust_std_sha256_hash_powerpc64le-unknown-linux-gnu:=142c7c2896fa4596b5c4c35d9d5e4d80acd5a699e5fa0560d92a89eda035ece3 + +# Linux (RISCV64 GC) - Cross only +$(package)_rust_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu +$(package)_rust_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu +$(package)_rust_std_sha256_hash_riscv64gc-unknown-linux-gnu:=7b35c8207c77e3fc2f7f7a26dea989cc2cdc13a955851ff74d4882f96f4e14dd + +# Windows (x86_64) - Cross only +$(package)_rust_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu +$(package)_rust_target_x86_64-pc-windows-gnu:=x86_64-pc-windows-gnu +$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu:=32d42270b114c9341e5bc9b1d24f336024889ddd32a7d22e4700cc3c45fe9d3d + +### +$(package)_file_name:=$($(package)_file_name_$(build_arch)_$(build_os)) +$(package)_sha256_hash:=$($(package)_sha256_hash_$(build_arch)_$(build_os)) +$(package)_rust_target:=$(or $($(package)_rust_target_$(canonical_host)),$($(package)_rust_target_$(subst -pc-,-unknown-,$(canonical_host))),$($(package)_rust_target_$(subst -unknown-,-pc-,$(canonical_host)))) +### + +define $(package)_set_vars +$(package)_stage_opts=--disable-ldconfig +$(package)_stage_build_opts=--without=rust-docs-json-preview,rust-docs +endef + +ifneq ($(canonical_host),$(build)) +$(package)_exact_file_name:=rust-std-$($(package)_version)-$($(package)_rust_target).tar.gz +$(package)_exact_sha256_hash:=$($(package)_rust_std_sha256_hash_$($(package)_rust_target)) +$(package)_build_subdir:=buildos +$(package)_extra_sources:=$($(package)_exact_file_name) + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_exact_file_name),$($(package)_exact_file_name),$($(package)_exact_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_file_name_$(build_arch)_$(build_os)),$($(package)_file_name_$(build_arch)_$(build_os)),$($(package)_sha256_hash_$(build_arch)_$(build_os))) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_exact_sha256_hash) $($(package)_source_dir)/$($(package)_exact_file_name)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_sha256_hash_$(build_arch)_$(build_os)) $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os))" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir $(canonical_host) && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_exact_file_name) -C $(canonical_host) && \ + mkdir buildos && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os)) -C buildos +endef + +define $(package)_stage_cmds + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) $($(package)_stage_opts) $($(package)_stage_build_opts) && \ + bash ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) $($(package)_stage_opts) +endef +else + +define $(package)_stage_cmds + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) $($(package)_stage_opts) $($(package)_stage_build_opts) +endef +endif diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 7e0bb2633219..1062b6c6bbe5 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,7 +1,9 @@ -packages:=gmp backtrace +packages:=gmp backtrace rustcxx boost_packages = boost +rust_native_packages = native_rust native_cxxbridge + libevent_packages = libevent qrencode_linux_packages = qrencode diff --git a/depends/packages/rustcxx.mk b/depends/packages/rustcxx.mk new file mode 100644 index 000000000000..13125507f290 --- /dev/null +++ b/depends/packages/rustcxx.mk @@ -0,0 +1,17 @@ +# Copyright (c) 2022-2023 The Zcash developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +package:=rustcxx +$(package)_version:=$(native_cxxbridge_version) +$(package)_file_name:=$(native_cxxbridge_file_name) +$(package)_sha256_hash:=$(native_cxxbridge_sha256_hash) + +define $(package)_fetch_cmds + $(call native_cxxbridge_fetch_cmds,native_cxxbridge) +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/include/rust && \ + cp include/cxx.h $($(package)_staging_prefix_dir)/include/rust +endef diff --git a/depends/patches/native_cxxbridge/Cargo.lock b/depends/patches/native_cxxbridge/Cargo.lock new file mode 100644 index 000000000000..4a9a074e7d3c --- /dev/null +++ b/depends/patches/native_cxxbridge/Cargo.lock @@ -0,0 +1,584 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "cc" +version = "1.2.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "clap" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.192" +dependencies = [ + "cc", + "cxx-build", + "cxx-gen", + "cxx-test-suite", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash", + "indoc", + "link-cplusplus", + "proc-macro2", + "quote", + "rustversion", + "scratch", + "target-triple", + "tempfile", + "trybuild", +] + +[[package]] +name = "cxx-build" +version = "1.0.192" +dependencies = [ + "cc", + "codespan-reporting", + "cxx", + "cxx-gen", + "indexmap", + "pkg-config", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxx-gen" +version = "0.7.192" +dependencies = [ + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxx-test-suite" +version = "0.0.0" +dependencies = [ + "cxx", + "cxx-build", + "cxxbridge-flags", + "serde", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.192" +dependencies = [ + "clap", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.192" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.192" +dependencies = [ + "cxx", + "indexmap", + "prettyplease", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "demo" +version = "0.0.0" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "dissimilar" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "indoc" +version = "2.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" +dependencies = [ + "rustversion", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom", + "libc", +] + +[[package]] +name = "libc" +version = "0.2.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" + +[[package]] +name = "link-cplusplus" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rustix" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "scratch" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +dependencies = [ + "serde_core", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-triple" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "591ef38edfb78ca4771ee32cf494cb8771944bee237a9b91fc9c1424ac4b777b" + +[[package]] +name = "tempfile" +version = "3.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "toml" +version = "0.9.11+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" + +[[package]] +name = "trybuild" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17e807bff86d2a06b52bca4276746584a78375055b6e45843925ce2802b335" +dependencies = [ + "dissimilar", + "glob", + "serde", + "serde_derive", + "serde_json", + "target-triple", + "termcolor", + "toml", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "winnow" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "zmij" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac93432f5b761b22864c774aac244fa5c0fd877678a4c37ebf6cf42208f9c9ec" From 8e74d07df9f1ab93fce30ddfa539b8c4860623e4 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 12 Jan 2026 18:32:05 +0530 Subject: [PATCH 12/60] build: drop Rust from CI docker image We're using `depends` to provide us with the Rust compiler and `cxxbridge`, we can drop it from the CI container and save some space. --- {contrib/containers/ci => .cargo}/config.toml | 14 ++++----- .github/workflows/build-container.yml | 4 --- contrib/containers/ci/ci.Dockerfile | 30 ------------------- contrib/containers/develop/docker-compose.yml | 2 -- 4 files changed, 6 insertions(+), 44 deletions(-) rename {contrib/containers/ci => .cargo}/config.toml (56%) diff --git a/contrib/containers/ci/config.toml b/.cargo/config.toml similarity index 56% rename from contrib/containers/ci/config.toml rename to .cargo/config.toml index caa3405606bb..ed69fb10e6a1 100644 --- a/contrib/containers/ci/config.toml +++ b/.cargo/config.toml @@ -1,17 +1,15 @@ -# Commented out entries are not bundled in the container - # Linux [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" -# [target.armv7-unknown-linux-gnueabihf] -# linker = "arm-linux-gnueabihf-gcc" +[target.armv7-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" -# [target.powerpc64le-unknown-linux-gnu] -# linker = "powerpc64le-linux-gnu-gcc" +[target.powerpc64le-unknown-linux-gnu] +linker = "powerpc64le-linux-gnu-gcc" -# [target.riscv64gc-unknown-linux-gnu] -# linker = "riscv64-linux-gnu-gcc" +[target.riscv64gc-unknown-linux-gnu] +linker = "riscv64-linux-gnu-gcc" [target.x86_64-unknown-linux-gnu] linker = "x86-64-linux-gnu-gcc" diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 11113c490d4f..078a3e84a5ec 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -67,8 +67,6 @@ jobs: uses: docker/build-push-action@v7 with: context: ${{ inputs.context }} - build-contexts: | - docker_root=${{ github.workspace }}/dash/contrib/containers/ci file: ${{ inputs.file }} push: true platforms: linux/amd64 @@ -115,8 +113,6 @@ jobs: uses: docker/build-push-action@v7 with: context: ${{ inputs.context }} - build-contexts: | - docker_root=${{ github.workspace }}/dash/contrib/containers/ci file: ${{ inputs.file }} push: true platforms: linux/arm64 diff --git a/contrib/containers/ci/ci.Dockerfile b/contrib/containers/ci/ci.Dockerfile index e59fb9369b9c..49e6dc608940 100644 --- a/contrib/containers/ci/ci.Dockerfile +++ b/contrib/containers/ci/ci.Dockerfile @@ -58,36 +58,6 @@ RUN set -ex; \ # LD_LIBRARY_PATH is empty by default, this is the first entry ENV LD_LIBRARY_PATH="/usr/lib/llvm-${LLVM_VERSION}/lib" -# Install Rust -ARG RUSTUP_VERSION=1.28.2 \ - RUST_VERSION=1.82.0 -ENV RUSTUP_HOME="/opt/rust/rustup" \ - CARGO_HOME="/opt/rust/cargo" -ENV PATH="${CARGO_HOME}/bin:${PATH}" -RUN dpkgArch="$(dpkg --print-architecture)"; \ - case "${dpkgArch##*-}" in \ - amd64) rustArch='x86_64-unknown-linux-gnu';; \ - armhf) rustArch='armv7-unknown-linux-gnueabihf';; \ - arm64) rustArch='aarch64-unknown-linux-gnu';; \ - *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ - esac; \ - curl -fL "https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/${rustArch}/rustup-init" -o /tmp/rustup-init; \ - chmod +x /tmp/rustup-init; \ - /tmp/rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ - rm /tmp/rustup-init; \ - chmod -R a+w "${RUSTUP_HOME}" "${CARGO_HOME}"; \ - rustup target add \ - # Linux - aarch64-unknown-linux-gnu \ - x86_64-unknown-linux-gnu \ - # Windows - x86_64-pc-windows-gnu; \ - rustup --version; \ - cargo --version; \ - rustc --version; \ - rm -rf "${CARGO_HOME}/registry/cache" -COPY --from=docker_root ./config.toml "${CARGO_HOME}/config.toml" - # Install IWYU RUN set -ex; \ git clone --depth=1 "https://github.com/include-what-you-use/include-what-you-use" -b "clang_${LLVM_VERSION}" /opt/iwyu; \ diff --git a/contrib/containers/develop/docker-compose.yml b/contrib/containers/develop/docker-compose.yml index 39238d6d4d0c..c6f2cea70424 100644 --- a/contrib/containers/develop/docker-compose.yml +++ b/contrib/containers/develop/docker-compose.yml @@ -4,8 +4,6 @@ services: build: context: '..' dockerfile: './develop/Dockerfile' - additional_contexts: - - docker_root=../ci args: USER_ID: 1000 # set this to $(id -u) of the host GROUP_ID: 1000 # set this to $(id -g) of the host From e53ac71ffbada115e7c455b3ee049b69769bdd57 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 21 Feb 2026 16:29:22 +0530 Subject: [PATCH 13/60] depends: add support for vendored crates for offline builds --- .cargo/{config.toml => config.toml.offline} | 6 +++ rust/chirp/Cargo.lock => Cargo.lock | 0 Cargo.toml | 14 +++++ configure.ac | 9 ++++ contrib/guix/guix-build | 5 +- depends/Makefile | 52 +++++++++++++++++-- depends/config.site.in | 1 + depends/funcs.mk | 37 +++++++++++++ depends/packages/native_cxxbridge.mk | 4 +- depends/packages/native_rust.mk | 9 ++++ depends/packages/packages.mk | 2 +- .../native_cxxbridge/cargo-config.toml | 5 ++ rust/Makefile.am | 34 ++++++++++-- 13 files changed, 166 insertions(+), 12 deletions(-) rename .cargo/{config.toml => config.toml.offline} (78%) rename rust/chirp/Cargo.lock => Cargo.lock (100%) create mode 100644 Cargo.toml create mode 100644 depends/patches/native_cxxbridge/cargo-config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml.offline similarity index 78% rename from .cargo/config.toml rename to .cargo/config.toml.offline index ed69fb10e6a1..df54e6e30c49 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml.offline @@ -24,3 +24,9 @@ linker = "x86_64-w64-mingw32-gcc" # [target.x86_64-apple-darwin] # linker = "x86_64-apple-darwin-gcc" + +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +# The directory for this source is set to RUST_VENDORED_SOURCES by rust/Makefile.am diff --git a/rust/chirp/Cargo.lock b/Cargo.lock similarity index 100% rename from rust/chirp/Cargo.lock rename to Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000000..68133a4d0d6d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[workspace] +members = [ + "rust/chirp", +] +resolver = "2" + +[profile.release] +codegen-units = 1 +lto = true +panic = "abort" + +[profile.dev] +codegen-units = 1 +panic = "abort" diff --git a/configure.ac b/configure.ac index 0712f12de773..9d0219a2d04a 100644 --- a/configure.ac +++ b/configure.ac @@ -153,6 +153,13 @@ if test "${RUSTFLAGS+set}" != "set"; then RUSTFLAGS="-C embed-bitcode=yes -C relocation-model=pic" fi +AC_ARG_ENABLE([online-rust], + [AS_HELP_STRING([--enable-online-rust], + [allow Cargo to fetch Rust dependencies from the internet (default is no, using vendored dependencies offline)])], + [enable_online_rust=$enableval], + [enable_online_rust=no]) +AM_CONDITIONAL([ENABLE_ONLINE_RUST], [test "$enable_online_rust" != "no"]) + AC_ARG_ENABLE([wallet], [AS_HELP_STRING([--disable-wallet], [disable wallet (enabled by default)])], @@ -2132,6 +2139,7 @@ AC_SUBST(RUST_MACOS_DEPLOYMENT_TARGET) AC_SUBST(RUST_NATIVE) AC_SUBST(RUST_OSX_SDK) AC_SUBST(RUST_TARGET) +AC_SUBST(RUST_VENDORED_SOURCES) AC_SUBST(RELDFLAGS) AC_SUBST(CORE_LDFLAGS) @@ -2292,4 +2300,5 @@ echo " RUST_MACOS_DEPLOYMENT_TARGET = $RUST_MACOS_DEPLOYMENT_TARGET" echo " RUST_NATIVE = $RUST_NATIVE" echo " RUST_OSX_SDK = $RUST_OSX_SDK" echo " RUST_TARGET = $RUST_TARGET" +echo " RUST_VENDORED_SOURCES = $RUST_VENDORED_SOURCES" echo diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 80b719eb29d8..65ffbdfa2ed6 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -301,9 +301,12 @@ mkdir -p "$OUTDIR_BASE" # Download the depends sources now as we won't have internet access in the build # container +depends_cmds="download-rust-std vendor-crates" for host in $HOSTS; do - make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} + depends_cmds+=" download-$(host_to_commonname "$host")" done +# shellcheck disable=SC2086 +make -C "${PWD}/depends" -j"$JOBS" ${depends_cmds} ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} # Usage: outdir_for_host HOST SUFFIX # diff --git a/depends/Makefile b/depends/Makefile index ff7b7bf98c64..1b1bf8e47107 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -60,6 +60,9 @@ DOWNLOAD_RETRIES:=3 HOST_ID_SALT ?= salt BUILD_ID_SALT ?= salt +CRATE_REGISTRY := vendored-sources +CRATE_ARCHIVE = $(SOURCES_PATH)/vendored-crates.tar.gz + ifneq ($(DEBUG),) release_type=debug else @@ -179,7 +182,7 @@ usdt_packages_$(NO_USDT) = $(usdt_$(host_os)_packages) packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(boost_packages_) $(libevent_packages_) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) $(natpmp_packages_) $(usdt_packages_) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) -native_packages += $(rust_native_packages) +native_packages += native_rust $(native_cargo_packages) ifneq ($(zmq_packages_),) packages += $(zmq_packages) @@ -203,9 +206,37 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) mkdir -p $(@D) echo copying packages: $^ echo to: $(@D) - cd $(@D); $(foreach package,$^, $(build_TAR) xf $($(package)_cached); ) + cd $(@D); $(foreach package,$^, $(build_TAR) --no-same-owner -xf $($(package)_cached); ) touch $@ +# Vendors Rust crate dependencies for offline builds +# Uses pre-built archive if available, otherwise runs 'cargo vendor' +$(host_prefix)/$(CRATE_REGISTRY): $(host_prefix)/.stamp_$(final_build_id) + @if test -f $(CRATE_ARCHIVE); \ + then echo Extracting pre-vendored crates from $(CRATE_ARCHIVE)...; \ + $(build_TAR) --no-same-owner -xf $(CRATE_ARCHIVE) -C $(@D); \ + else echo Vendoring crates...; \ + $(@D)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $@; \ + fi + @touch $@ + +# Vendors crates for cargo packages +vendor-dep-crates: $(foreach package,$(native_cargo_packages),vendor-$(package)-crates) + +# Vendors project-wide cargo packages +vendor-all-crates: $(native_rust_cached) + @rm -rf $(WORK_PATH)/vendor-main + @mkdir -p $(WORK_PATH)/vendor-main + @$(build_TAR) --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-main + @echo "Vendoring main project crates..." + @$(WORK_PATH)/vendor-main/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(WORK_PATH)/vendor-main/$(CRATE_REGISTRY) + @cd $(WORK_PATH)/vendor-main; find $(CRATE_REGISTRY) | sort | $(build_TAR) --no-recursion -czf $(CRATE_ARCHIVE) -T - + @rm -rf $(WORK_PATH)/vendor-main + @echo "Created $(CRATE_ARCHIVE)" + +# Vendors everything +vendor-crates: vendor-dep-crates vendor-all-crates + # $PATH is not preserved between ./configure and make by convention. Its # modification and overriding at ./configure time is (as I understand it) # supposed to be captured by the AC_{PROG_{,OBJ}CXX,PATH_{PROG,TOOL}} macros, @@ -299,7 +330,7 @@ clean-all: clean clean: @rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) *.log -install: check-packages $(host_prefix)/share/config.site +install: check-packages $(host_prefix)/share/config.site $(host_prefix)/$(CRATE_REGISTRY) download-one: check-sources $(all_sources) @@ -310,10 +341,21 @@ download-linux: @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one download-win: @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one -download: download-osx download-linux download-win +download-rust-std: + @mkdir -p $(SOURCES_PATH) + @for target in $(native_rust_rust_std_targets); do \ + file="rust-std-$(native_rust_version)-$${target}.tar.gz"; \ + if [ ! -f "$(SOURCES_PATH)/$${file}" ]; then \ + echo "Downloading $${file}..."; \ + curl -L -o "$(SOURCES_PATH)/$${file}" "$(native_rust_download_path)/$${file}" || exit 1; \ + else \ + echo "Already have $${file}"; \ + fi; \ + done +download: download-osx download-linux download-win download-rust-std $(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package)))) -.PHONY: install cached clean clean-all download-one download-osx download-linux download-win download check-packages check-sources +.PHONY: install cached clean clean-all download-one download-osx download-linux download-win download download-rust-std check-packages check-sources vendor-crates vendor-dep-crates vendor-all-crates .PHONY: FORCE $(V).SILENT: diff --git a/depends/config.site.in b/depends/config.site.in index 6eb88d8aaeb1..a1ccdbcbd7bf 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -183,3 +183,4 @@ fi if test -x "${depends_prefix}/native/bin/cxxbridge"; then CXXBRIDGE="${depends_prefix}/native/bin/cxxbridge" fi +RUST_VENDORED_SOURCES="${depends_prefix}/vendored-sources" diff --git a/depends/funcs.mk b/depends/funcs.mk index 4a6150a5254f..7c5749774315 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -281,6 +281,28 @@ $(foreach stage,$(stages), .PHONY: $(1)_$(stage)) endef +# Template for vendoring a native package's Rust crate dependencies +# Packages opt-in by defining $(package)_vendored_file_name and $(package)_cargo_manifest +define int_vendor_crates +ifneq ($($(1)_vendored_file_name),) +$(1)_vendored_archive = $(SOURCES_PATH)/$($(1)_vendored_file_name) + +vendor-$(1)-crates: $(native_rust_cached) $($(1)_fetched) + @rm -rf $(WORK_PATH)/vendor-$(1) + @mkdir -p $(WORK_PATH)/vendor-$(1) + @$(build_TAR) --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-$(1) + @echo "Vendoring $(1) crates..." + @mkdir -p $(WORK_PATH)/vendor-$(1)/src + @cd $(WORK_PATH)/vendor-$(1)/src && $(build_TAR) --no-same-owner --strip-components=1 -xf $(SOURCES_PATH)/$($(1)_file_name) + @cp $(PATCHES_PATH)/$(1)/Cargo.lock $(WORK_PATH)/vendor-$(1)/src/ + @$(WORK_PATH)/vendor-$(1)/native/bin/cargo vendor --locked --manifest-path $(WORK_PATH)/vendor-$(1)/src/$($(1)_cargo_manifest) $(WORK_PATH)/vendor-$(1)/src/vendored + @cd $(WORK_PATH)/vendor-$(1)/src; find vendored | sort | $(build_TAR) --no-recursion -czf $$($(1)_vendored_archive) -T - + @rm -rf $(WORK_PATH)/vendor-$(1) + @echo "Created $$($(1)_vendored_archive)" +.PHONY: vendor-$(1)-crates +endif +endef + # These functions create the build targets for each package. They must be # broken down into small steps so that each part is done for all packages # before moving on to the next step. Otherwise, a package's info @@ -298,6 +320,18 @@ $(foreach package,$(all_packages),$(eval $(call int_vars,$(package)))) $(foreach native_package,$(native_packages),$(eval include packages/$(native_package).mk)) $(foreach package,$(packages),$(eval include packages/$(package).mk)) +# Extend preprocess_cmds for cargo packages to extract vendored crates +define int_cargo_preprocess_ext +$(1)_preprocess_cmds += && \ + if test -f $(SOURCES_PATH)/$($(1)_vendored_file_name); then \ + echo "Extracting vendored crates for $(1)..." && \ + $(build_TAR) xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ + mkdir -p .cargo && \ + cp $(PATCHES_PATH)/$(1)/cargo-config.toml .cargo/config.toml; \ + fi +endef +$(foreach cargo_package,$(native_cargo_packages),$(eval $(call int_cargo_preprocess_ext,$(cargo_package)))) + #compute a hash of all files that comprise this package's build recipe $(foreach package,$(all_packages),$(eval $(call int_get_build_recipe_hash,$(package)))) @@ -309,3 +343,6 @@ $(foreach package,$(all_packages),$(eval $(call int_config_attach_build_config,$ #create build targets $(foreach package,$(all_packages),$(eval $(call int_add_cmds,$(package)))) + +#create vendor targets for cargo packages +$(foreach cargo_package,$(native_cargo_packages),$(eval $(call int_vendor_crates,$(cargo_package)))) diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk index ca3580c38dff..c0d9963382c1 100644 --- a/depends/packages/native_cxxbridge.mk +++ b/depends/packages/native_cxxbridge.mk @@ -13,7 +13,9 @@ $(package)_download_file:=$($(package)_version).tar.gz $(package)_sha256_hash:=d242dbfb6deb362c5a95fcb69aeb5f25228de75af3cced94c9f6c8e11019d30e $(package)_build_subdir:=gen/cmd $(package)_dependencies:=native_rust -$(package)_patches:=Cargo.lock +$(package)_patches:=Cargo.lock cargo-config.toml +$(package)_vendored_file_name:=native_cxxbridge-$($(package)_version)-vendored.tar.gz +$(package)_cargo_manifest:=gen/cmd/Cargo.toml define $(package)_preprocess_cmds cp $($(package)_patch_dir)/Cargo.lock . diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 54c293fe6508..63170d040ab1 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -11,30 +11,35 @@ $(package)_version:=1.82.0 $(package)_download_path:=https://static.rust-lang.org/dist # FreeBSD (x86_64) +$(package)_rust_std_targets += x86_64-unknown-freebsd $(package)_rust_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd $(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz $(package)_sha256_hash_x86_64_freebsd:=f7b51943dbed0af3387e3269c1767fee916fb22b8e7897b3594bf5e422403137 $(package)_rust_std_sha256_hash_x86_64-unknown-freebsd:=be1acaf3c2f15d42b05b1f032db5ac3b11a0ac5a91c0efef26f2d8135d68a829 # Linux (ARMv8) +$(package)_rust_std_targets += aarch64-unknown-linux-gnu $(package)_rust_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-gnu $(package)_file_name_aarch64_linux:=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz $(package)_sha256_hash_aarch64_linux:=d7db04fce65b5f73282941f3f1df5893be9810af17eb7c65b2e614461fe31a48 $(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu:=82b2308ee531775bf4d1faa57bddfae85f363bec43ca36ba6db4ebad7c1450d4 # Linux (x86_64) +$(package)_rust_std_targets += x86_64-unknown-linux-gnu $(package)_rust_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-gnu $(package)_file_name_x86_64_linux:=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz $(package)_sha256_hash_x86_64_linux:=0265c08ae997c4de965048a244605fb1f24a600bbe35047b811c638b8fcf676b $(package)_rust_std_sha256_hash_x86_64-unknown-linux-gnu:=e7e808b8745298369fa3bbc3c0b7af9ca0fb995661bd684a7022d14bc9ae0057 # macOS (x86_64) +$(package)_rust_std_targets += x86_64-apple-darwin $(package)_rust_target_x86_64-apple-darwin:=x86_64-apple-darwin $(package)_file_name_x86_64_darwin:=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz $(package)_sha256_hash_x86_64_darwin:=b1a289cabc523f259f65116a41374ac159d72fbbf6c373bd5e545c8e835ceb6a $(package)_rust_std_sha256_hash_x86_64-apple-darwin:=52084c8cdb34ca139a00f9f03f1a582d96b677e9f223a8d1aa31ae575a06cc16 # macOS (ARMv8) +$(package)_rust_std_targets += aarch64-apple-darwin $(package)_rust_target_aarch64-apple-darwin:=aarch64-apple-darwin $(package)_rust_target_arm64-apple-darwin:=aarch64-apple-darwin $(package)_file_name_aarch64_darwin:=rust-$($(package)_version)-aarch64-apple-darwin.tar.gz @@ -42,20 +47,24 @@ $(package)_sha256_hash_aarch64_darwin:=49b6d36b308addcfd21ae56c94957688338ba7b89 $(package)_rust_std_sha256_hash_aarch64-apple-darwin:=5ec28e75ed8715efaa2490d76ae026a34b13df6899d98b14d0a6995556f4e6b4 # Linux (ARMv7) - Cross only +$(package)_rust_std_targets += armv7-unknown-linux-gnueabihf $(package)_rust_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf $(package)_rust_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf $(package)_rust_std_sha256_hash_armv7-unknown-linux-gnueabihf:=5dd8b36467e03ba47bfa7ea5d7578c66bccb648dd2129d7cec6fb3ff00f81ca3 # Linux (PowerPC 64-bit) - Cross only +$(package)_rust_std_targets += powerpc64le-unknown-linux-gnu $(package)_rust_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-gnu $(package)_rust_std_sha256_hash_powerpc64le-unknown-linux-gnu:=142c7c2896fa4596b5c4c35d9d5e4d80acd5a699e5fa0560d92a89eda035ece3 # Linux (RISCV64 GC) - Cross only +$(package)_rust_std_targets += riscv64gc-unknown-linux-gnu $(package)_rust_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu $(package)_rust_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu $(package)_rust_std_sha256_hash_riscv64gc-unknown-linux-gnu:=7b35c8207c77e3fc2f7f7a26dea989cc2cdc13a955851ff74d4882f96f4e14dd # Windows (x86_64) - Cross only +$(package)_rust_std_targets += x86_64-pc-windows-gnu $(package)_rust_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu $(package)_rust_target_x86_64-pc-windows-gnu:=x86_64-pc-windows-gnu $(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu:=32d42270b114c9341e5bc9b1d24f336024889ddd32a7d22e4700cc3c45fe9d3d diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 1062b6c6bbe5..ac4c9224c9c5 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -2,7 +2,7 @@ packages:=gmp backtrace rustcxx boost_packages = boost -rust_native_packages = native_rust native_cxxbridge +native_cargo_packages = native_cxxbridge libevent_packages = libevent diff --git a/depends/patches/native_cxxbridge/cargo-config.toml b/depends/patches/native_cxxbridge/cargo-config.toml new file mode 100644 index 000000000000..01ab67f3bd1f --- /dev/null +++ b/depends/patches/native_cxxbridge/cargo-config.toml @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "vendored" diff --git a/rust/Makefile.am b/rust/Makefile.am index 10a5bd8d241a..cf47dce453f7 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -40,14 +40,40 @@ if !SILENT_RULES CARGO_BUILD_OPTS += --verbose endif # !SILENT_RULES +if ENABLE_ONLINE_RUST +CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-online + +$(CARGO_CONFIGURED): + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config.toml + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config + $(AM_V_at)touch $@ +else +CARGO_BUILD_OPTS += --offline +CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-offline + +$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.toml.offline + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config + $(AM_V_at)cp $< $(top_srcdir)/.cargo/config.toml + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(top_srcdir)/.cargo/config.toml + $(AM_V_at)touch $@ +endif # ENABLE_ONLINE_RUST + include $(top_srcdir)/rust/Makefile.libs.include -all-local: cargo-build-chirp cxxbridge-chirp +all-local: $(CARGO_CONFIGURED) cargo-build-chirp cxxbridge-chirp -cargo-build: cargo-build-chirp +cargo-build: $(CARGO_CONFIGURED) cargo-build-chirp cargo-clean: cargo-clean-chirp -clean-local: cargo-clean-chirp cxxbridge-clean-chirp clean-librustdeps-la +cargo-clean-config: + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config.toml + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config + +clean-local: cargo-clean-chirp cxxbridge-clean-chirp clean-librustdeps-la cargo-clean-config -.PHONY: cargo-build cargo-clean +.PHONY: cargo-build cargo-clean cargo-clean-config From fb32452dabb8e7e6523071021a28ce40a2531bce Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:58:41 +0530 Subject: [PATCH 14/60] fix: avoid triggering `rustup` if building from depends --- configure.ac | 6 ++++++ rust/Makefile.am | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9d0219a2d04a..2510cb7ff90e 100644 --- a/configure.ac +++ b/configure.ac @@ -1827,6 +1827,11 @@ if test -z "$NATIVE_CXX"; then fi AC_MSG_RESULT([$NATIVE_CXX]) +if test -n "$depends_prefix"; then + RUSTUP_TOOLCHAIN="" +fi +AC_SUBST(RUSTUP_TOOLCHAIN) + dnl check if libgmp is present TEMP_CPPFLAGS="$CPPFLAGS" TEMP_LDFLAGS="$LDFLAGS" @@ -2140,6 +2145,7 @@ AC_SUBST(RUST_NATIVE) AC_SUBST(RUST_OSX_SDK) AC_SUBST(RUST_TARGET) AC_SUBST(RUST_VENDORED_SOURCES) +AC_SUBST(RUSTUP_TOOLCHAIN) AC_SUBST(RELDFLAGS) AC_SUBST(CORE_LDFLAGS) diff --git a/rust/Makefile.am b/rust/Makefile.am index cf47dce453f7..c01b61e07773 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -10,7 +10,8 @@ CARGO_ENV = \ RUSTC="$(RUSTC)" \ RUSTFLAGS="$(RUSTFLAGS)" \ TERM="dumb" \ - ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} + ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} \ + ${RUSTUP_TOOLCHAIN+RUSTUP_TOOLCHAIN="$(RUSTUP_TOOLCHAIN)"} # 'cargo' needs uppercase RUST_NATIVE_ENV_UPPER = $(shell echo '$(RUST_NATIVE)' | tr 'a-z-' 'A-Z_') From e1522496610c2e5a06e2308e9ccc75a98c4d1fe6 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 16 Jan 2026 06:40:45 +0530 Subject: [PATCH 15/60] fix: workaround `Directory renamed before its status could be extracted` --- depends/Makefile | 6 +++--- depends/funcs.mk | 8 ++++---- depends/packages/native_rust.mk | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/depends/Makefile b/depends/Makefile index 1b1bf8e47107..e0c5b7c80131 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -206,7 +206,7 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) mkdir -p $(@D) echo copying packages: $^ echo to: $(@D) - cd $(@D); $(foreach package,$^, $(build_TAR) --no-same-owner -xf $($(package)_cached); ) + cd $(@D); $(foreach package,$^, $(build_TAR) -P --no-same-owner -xf $($(package)_cached); ) touch $@ # Vendors Rust crate dependencies for offline builds @@ -214,7 +214,7 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) $(host_prefix)/$(CRATE_REGISTRY): $(host_prefix)/.stamp_$(final_build_id) @if test -f $(CRATE_ARCHIVE); \ then echo Extracting pre-vendored crates from $(CRATE_ARCHIVE)...; \ - $(build_TAR) --no-same-owner -xf $(CRATE_ARCHIVE) -C $(@D); \ + $(build_TAR) -P --no-same-owner -xf $(CRATE_ARCHIVE) -C $(@D); \ else echo Vendoring crates...; \ $(@D)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $@; \ fi @@ -227,7 +227,7 @@ vendor-dep-crates: $(foreach package,$(native_cargo_packages),vendor-$(package)- vendor-all-crates: $(native_rust_cached) @rm -rf $(WORK_PATH)/vendor-main @mkdir -p $(WORK_PATH)/vendor-main - @$(build_TAR) --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-main + @$(build_TAR) -P --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-main @echo "Vendoring main project crates..." @$(WORK_PATH)/vendor-main/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(WORK_PATH)/vendor-main/$(CRATE_REGISTRY) @cd $(WORK_PATH)/vendor-main; find $(CRATE_REGISTRY) | sort | $(build_TAR) --no-recursion -czf $(CRATE_ARCHIVE) -T - diff --git a/depends/funcs.mk b/depends/funcs.mk index 7c5749774315..d251333635f3 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -85,7 +85,7 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) #default commands # The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior $(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) -$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) --no-same-owner --strip-components=1 -xf $$($(1)_source) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) -P --no-same-owner --strip-components=1 -xf $$($(1)_source) $(1)_preprocess_cmds ?= true $(1)_build_cmds ?= true $(1)_config_cmds ?= true @@ -290,10 +290,10 @@ $(1)_vendored_archive = $(SOURCES_PATH)/$($(1)_vendored_file_name) vendor-$(1)-crates: $(native_rust_cached) $($(1)_fetched) @rm -rf $(WORK_PATH)/vendor-$(1) @mkdir -p $(WORK_PATH)/vendor-$(1) - @$(build_TAR) --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-$(1) + @$(build_TAR) -P --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-$(1) @echo "Vendoring $(1) crates..." @mkdir -p $(WORK_PATH)/vendor-$(1)/src - @cd $(WORK_PATH)/vendor-$(1)/src && $(build_TAR) --no-same-owner --strip-components=1 -xf $(SOURCES_PATH)/$($(1)_file_name) + @cd $(WORK_PATH)/vendor-$(1)/src && $(build_TAR) -P --no-same-owner --strip-components=1 -xf $(SOURCES_PATH)/$($(1)_file_name) @cp $(PATCHES_PATH)/$(1)/Cargo.lock $(WORK_PATH)/vendor-$(1)/src/ @$(WORK_PATH)/vendor-$(1)/native/bin/cargo vendor --locked --manifest-path $(WORK_PATH)/vendor-$(1)/src/$($(1)_cargo_manifest) $(WORK_PATH)/vendor-$(1)/src/vendored @cd $(WORK_PATH)/vendor-$(1)/src; find vendored | sort | $(build_TAR) --no-recursion -czf $$($(1)_vendored_archive) -T - @@ -325,7 +325,7 @@ define int_cargo_preprocess_ext $(1)_preprocess_cmds += && \ if test -f $(SOURCES_PATH)/$($(1)_vendored_file_name); then \ echo "Extracting vendored crates for $(1)..." && \ - $(build_TAR) xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ + $(build_TAR) -P -xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ mkdir -p .cargo && \ cp $(PATCHES_PATH)/$(1)/cargo-config.toml .cargo/config.toml; \ fi diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 63170d040ab1..32d044d91b75 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -97,9 +97,9 @@ define $(package)_extract_cmds echo "$($(package)_sha256_hash_$(build_arch)_$(build_os)) $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os))" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ mkdir $(canonical_host) && \ - $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_exact_file_name) -C $(canonical_host) && \ + $(build_TAR) -P --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_exact_file_name) -C $(canonical_host) && \ mkdir buildos && \ - $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os)) -C buildos + $(build_TAR) -P --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os)) -C buildos endef define $(package)_stage_cmds From 9c88a954a4ef3a7bd15945aa34a854a7985447a4 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 17 Jan 2026 16:26:26 +0530 Subject: [PATCH 16/60] fix: copy native binaries for access within Guix context --- contrib/guix/libexec/build.sh | 6 ++++++ depends/packages/native_cxxbridge.mk | 3 ++- depends/packages/native_rust.mk | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index fd67e258a70d..e5ff272f5657 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -86,6 +86,9 @@ case "$HOST" in ;; esac +# Rust build scripts need LD_LIBRARY_PATH to find libgcc_s.so.1 at runtime +export LD_LIBRARY_PATH="${LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + # Set environment variables to point the CROSS toolchain to the right # includes/libs for $HOST case "$HOST" in @@ -192,6 +195,9 @@ case "$HOST" in ;; esac +# Make $HOST-specific native binaries from depends available in $PATH +export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" + ########################### # Source Tarball Building # ########################### diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk index c0d9963382c1..e13d61cdba41 100644 --- a/depends/packages/native_cxxbridge.mk +++ b/depends/packages/native_cxxbridge.mk @@ -26,5 +26,6 @@ define $(package)_build_cmds endef define $(package)_stage_cmds - $($(package)_cargo) install --locked --path=. --bin=cxxbridge --root=$($(package)_staging_prefix_dir) + $($(package)_cargo) install --locked --path=. --bin=cxxbridge --root=$($(package)_staging_prefix_dir) && \ + mkdir -p $($(package)_staging_prefix_dir)/lib endef diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 32d044d91b75..7a81d9be9d2c 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -103,12 +103,24 @@ define $(package)_extract_cmds endef define $(package)_stage_cmds - bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) $($(package)_stage_opts) $($(package)_stage_build_opts) && \ - bash ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) $($(package)_stage_opts) + mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/bin && \ + mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib && \ + cp cargo/bin/cargo $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ + cp rustc/bin/rustc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ + cp rustc/bin/rustdoc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ + cp -r rustc/lib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/ && \ + cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ + cp -r ../$(canonical_host)/rust-std-$($(package)_rust_target)/lib/rustlib/$($(package)_rust_target) $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ endef else define $(package)_stage_cmds - bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(build_prefix) $($(package)_stage_opts) $($(package)_stage_build_opts) + mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/bin && \ + mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib && \ + cp cargo/bin/cargo $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ + cp rustc/bin/rustc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ + cp rustc/bin/rustdoc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ + cp -r rustc/lib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/ && \ + cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ endef endif From a1a681bd8fbe550f9ec3801cf1549264f9694a8e Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 23 Jan 2026 01:17:47 +0530 Subject: [PATCH 17/60] fix: patch loader paths to Guix store locations --- contrib/guix/manifest.scm | 2 + depends/packages/native_cxxbridge.mk | 5 +- depends/packages/native_rust.mk | 14 +++- .../native_rust/fix-elf-interpreter.sh | 77 +++++++++++++++++++ 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100755 depends/patches/native_rust/fix-elf-interpreter.sh diff --git a/contrib/guix/manifest.scm b/contrib/guix/manifest.scm index 2f21f5b58801..cc39854319b1 100644 --- a/contrib/guix/manifest.scm +++ b/contrib/guix/manifest.scm @@ -8,6 +8,7 @@ (gnu packages commencement) (gnu packages compression) (gnu packages cross-base) + ((gnu packages elf) #:select (patchelf)) (gnu packages file) (gnu packages gawk) (gnu packages gcc) @@ -533,6 +534,7 @@ inspecting signatures in Mach-O binaries.") libtool autoconf-2.71 automake + patchelf pkg-config ;; Scripting python-minimal ;; (3.10) diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk index e13d61cdba41..4f18d05fd8d6 100644 --- a/depends/packages/native_cxxbridge.mk +++ b/depends/packages/native_cxxbridge.mk @@ -27,5 +27,8 @@ endef define $(package)_stage_cmds $($(package)_cargo) install --locked --path=. --bin=cxxbridge --root=$($(package)_staging_prefix_dir) && \ - mkdir -p $($(package)_staging_prefix_dir)/lib + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + bash $(BASEDIR)/patches/native_rust/fix-elf-interpreter.sh \ + $($(package)_staging_prefix_dir)/lib \ + $($(package)_staging_prefix_dir)/bin/cxxbridge endef diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 7a81d9be9d2c..60379e8abca7 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -110,7 +110,12 @@ define $(package)_stage_cmds cp rustc/bin/rustdoc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ cp -r rustc/lib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/ && \ cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ - cp -r ../$(canonical_host)/rust-std-$($(package)_rust_target)/lib/rustlib/$($(package)_rust_target) $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ + cp -r ../$(canonical_host)/rust-std-$($(package)_rust_target)/lib/rustlib/$($(package)_rust_target) $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ + bash $(BASEDIR)/patches/native_rust/fix-elf-interpreter.sh \ + $($(package)_staging_dir)/$(host_prefix)/native/lib \ + $($(package)_staging_dir)/$(host_prefix)/native/bin/cargo \ + $($(package)_staging_dir)/$(host_prefix)/native/bin/rustc \ + $($(package)_staging_dir)/$(host_prefix)/native/bin/rustdoc endef else @@ -121,6 +126,11 @@ define $(package)_stage_cmds cp rustc/bin/rustc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ cp rustc/bin/rustdoc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ cp -r rustc/lib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/ && \ - cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ + cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ + bash $(BASEDIR)/patches/native_rust/fix-elf-interpreter.sh \ + $($(package)_staging_dir)/$(host_prefix)/native/lib \ + $($(package)_staging_dir)/$(host_prefix)/native/bin/cargo \ + $($(package)_staging_dir)/$(host_prefix)/native/bin/rustc \ + $($(package)_staging_dir)/$(host_prefix)/native/bin/rustdoc endef endif diff --git a/depends/patches/native_rust/fix-elf-interpreter.sh b/depends/patches/native_rust/fix-elf-interpreter.sh new file mode 100755 index 000000000000..b25f30db3c52 --- /dev/null +++ b/depends/patches/native_rust/fix-elf-interpreter.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +LIBDIR="$1" +shift + +if ! command -v patchelf >/dev/null 2>&1; then + echo "patchelf not found, skipping ELF fix" + exit 0 +fi + +# Get the interpreter from a known working binary (ls) +LS_PATH=$(command -v ls) +GUIX_INTERP=$(patchelf --print-interpreter "$LS_PATH" 2>/dev/null) + +if [ -z "$GUIX_INTERP" ]; then + echo "Could not detect interpreter, skipping" + exit 0 +fi + +echo "Detected interpreter: $GUIX_INTERP" + +# Find and copy libgcc_s.so.1 into our lib directory +LIBGCC_SRC="" + +# Method 1: Use gcc to find it +if command -v gcc >/dev/null 2>&1; then + GCC_LIBDIR=$(dirname "$(gcc -print-libgcc-file-name)" 2>/dev/null) + if [ -f "$GCC_LIBDIR/libgcc_s.so.1" ]; then + LIBGCC_SRC="$GCC_LIBDIR/libgcc_s.so.1" + else + GCC_PATH=$(command -v gcc) + GCC_PREFIX=$(dirname "$(dirname "$GCC_PATH")") + if [ -f "$GCC_PREFIX/lib/libgcc_s.so.1" ]; then + LIBGCC_SRC="$GCC_PREFIX/lib/libgcc_s.so.1" + fi + fi +fi + +# Method 2: Search LIBRARY_PATH +if [ -z "$LIBGCC_SRC" ] && [ -n "$LIBRARY_PATH" ]; then + IFS=':' read -ra LIB_PATHS <<< "$LIBRARY_PATH" + for libpath in "${LIB_PATHS[@]}"; do + if [ -f "$libpath/libgcc_s.so.1" ]; then + LIBGCC_SRC="$libpath/libgcc_s.so.1" + break + fi + done +fi + +if [ -n "$LIBGCC_SRC" ]; then + # Resolve symlinks and copy the actual file + LIBGCC_REAL=$(readlink -f "$LIBGCC_SRC") + echo "Copying libgcc_s.so.1 from: $LIBGCC_REAL" + cp "$LIBGCC_REAL" "$LIBDIR/libgcc_s.so.1" +else + echo "WARNING: Could not find libgcc_s.so.1 to copy" +fi + +# RPATH just needs $ORIGIN/../lib - everything is self-contained +GUIX_RPATH="\$ORIGIN/../lib" +echo "Using RPATH: $GUIX_RPATH" + +for binary in "$@"; do + if [ -f "$binary" ]; then + echo "Patching: $binary" + patchelf --set-interpreter "$GUIX_INTERP" "$binary" + patchelf --set-rpath "$GUIX_RPATH" "$binary" + fi +done + +echo "Verifying first binary:" +patchelf --print-interpreter "$1" +patchelf --print-rpath "$1" From 42e20d9da603cdd261011ff57e4cbd07c33dbe6a Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:06:50 +0530 Subject: [PATCH 18/60] refactor: split rust runner (builder) and standard library (cross) --- contrib/devtools/update-rust-hashes.py | 25 ++++--- depends/Makefile | 11 +--- depends/funcs.mk | 8 +++ depends/packages/native_rust.mk | 90 ++------------------------ depends/packages/packages.mk | 2 +- depends/packages/rust_stdlib.mk | 77 ++++++++++++++++++++++ 6 files changed, 110 insertions(+), 103 deletions(-) create mode 100644 depends/packages/rust_stdlib.mk diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 87f0d4d53263..5e8dd0bb83d5 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -75,29 +75,36 @@ def update_rust_hash(makefile_path: Path, rust_version: str, rust_target: str, m def update_stdlib_hash(makefile_path: Path, rust_version: str, rust_target: str) -> None: url = f"https://static.rust-lang.org/dist/rust-std-{rust_version}-{rust_target}.tar.gz" hash_value = compute_sha256(url) - update_hash_in_file(makefile_path, f"rust_std_sha256_hash_{rust_target}", hash_value) - print(f" Updated rust_std_sha256_hash_{rust_target}") + update_hash_in_file(makefile_path, f"sha256_hash_{rust_target}", hash_value) + print(f" Updated sha256_hash_{rust_target}") def main() -> int: script_dir = Path(__file__).resolve().parent - makefile_path = script_dir / "../../depends/packages/native_rust.mk" - makefile_path = makefile_path.resolve() + native_rust_path = script_dir / "../../depends/packages/native_rust.mk" + native_rust_path = native_rust_path.resolve() + rust_stdlib_path = script_dir / "../../depends/packages/rust_stdlib.mk" + rust_stdlib_path = rust_stdlib_path.resolve() - if not makefile_path.exists(): - print(f"Error: {makefile_path} not found", file=sys.stderr) + if not native_rust_path.exists(): + print(f"Error: {native_rust_path} not found", file=sys.stderr) return 1 - rust_version = get_rust_version(makefile_path) + if not rust_stdlib_path.exists(): + print(f"Error: {rust_stdlib_path} not found", file=sys.stderr) + return 1 + + rust_version = get_rust_version(native_rust_path) print(f"Rust version: {rust_version}\n") print("Updating native compiler hashes:") for rust_target, makefile_id in NATIVE_TARGETS: - update_rust_hash(makefile_path, rust_version, rust_target, makefile_id) + update_rust_hash(native_rust_path, rust_version, rust_target, makefile_id) + print("\nUpdating stdlib hashes:") for rust_target in CROSS_TARGETS: - update_stdlib_hash(makefile_path, rust_version, rust_target) + update_stdlib_hash(rust_stdlib_path, rust_version, rust_target) print("\nDone!") return 0 diff --git a/depends/Makefile b/depends/Makefile index e0c5b7c80131..ce65dece076e 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -343,15 +343,8 @@ download-win: @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one download-rust-std: @mkdir -p $(SOURCES_PATH) - @for target in $(native_rust_rust_std_targets); do \ - file="rust-std-$(native_rust_version)-$${target}.tar.gz"; \ - if [ ! -f "$(SOURCES_PATH)/$${file}" ]; then \ - echo "Downloading $${file}..."; \ - curl -L -o "$(SOURCES_PATH)/$${file}" "$(native_rust_download_path)/$${file}" || exit 1; \ - else \ - echo "Already have $${file}"; \ - fi; \ - done + @mkdir -p $(SOURCES_PATH)/download-stamps + @$(foreach target,$(rust_stdlib_targets),$(call download_rust_std_target,$(target)) && ) true download: download-osx download-linux download-win download-rust-std $(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package)))) diff --git a/depends/funcs.mk b/depends/funcs.mk index d251333635f3..296290f3630d 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -303,6 +303,14 @@ vendor-$(1)-crates: $(native_rust_cached) $($(1)_fetched) endif endef +define download_rust_std_target +([ -f "$(SOURCES_PATH)/rust-std-$(rust_stdlib_version)-$(1).tar.gz" ] && \ + echo "Already have rust-std-$(rust_stdlib_version)-$(1).tar.gz" || \ + (echo "Downloading rust-std-$(rust_stdlib_version)-$(1).tar.gz..." && \ + $(build_DOWNLOAD) "$(SOURCES_PATH)/rust-std-$(rust_stdlib_version)-$(1).tar.gz" "$(rust_stdlib_download_path)/rust-std-$(rust_stdlib_version)-$(1).tar.gz")) && \ +echo "$(rust_stdlib_sha256_hash_$(1)) rust-std-$(rust_stdlib_version)-$(1).tar.gz" > "$(SOURCES_PATH)/download-stamps/.stamp_fetched-rust_stdlib-$(rust_stdlib_version)-$(rust_stdlib_sha256_hash_$(1)).hash" +endef + # These functions create the build targets for each package. They must be # broken down into small steps so that each part is done for all packages # before moving on to the next step. Otherwise, a package's info diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 60379e8abca7..c48787da63f8 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -11,113 +11,36 @@ $(package)_version:=1.82.0 $(package)_download_path:=https://static.rust-lang.org/dist # FreeBSD (x86_64) -$(package)_rust_std_targets += x86_64-unknown-freebsd -$(package)_rust_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd $(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz $(package)_sha256_hash_x86_64_freebsd:=f7b51943dbed0af3387e3269c1767fee916fb22b8e7897b3594bf5e422403137 -$(package)_rust_std_sha256_hash_x86_64-unknown-freebsd:=be1acaf3c2f15d42b05b1f032db5ac3b11a0ac5a91c0efef26f2d8135d68a829 # Linux (ARMv8) -$(package)_rust_std_targets += aarch64-unknown-linux-gnu -$(package)_rust_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-gnu $(package)_file_name_aarch64_linux:=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz $(package)_sha256_hash_aarch64_linux:=d7db04fce65b5f73282941f3f1df5893be9810af17eb7c65b2e614461fe31a48 -$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu:=82b2308ee531775bf4d1faa57bddfae85f363bec43ca36ba6db4ebad7c1450d4 # Linux (x86_64) -$(package)_rust_std_targets += x86_64-unknown-linux-gnu -$(package)_rust_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-gnu $(package)_file_name_x86_64_linux:=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz $(package)_sha256_hash_x86_64_linux:=0265c08ae997c4de965048a244605fb1f24a600bbe35047b811c638b8fcf676b -$(package)_rust_std_sha256_hash_x86_64-unknown-linux-gnu:=e7e808b8745298369fa3bbc3c0b7af9ca0fb995661bd684a7022d14bc9ae0057 - -# macOS (x86_64) -$(package)_rust_std_targets += x86_64-apple-darwin -$(package)_rust_target_x86_64-apple-darwin:=x86_64-apple-darwin -$(package)_file_name_x86_64_darwin:=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_x86_64_darwin:=b1a289cabc523f259f65116a41374ac159d72fbbf6c373bd5e545c8e835ceb6a -$(package)_rust_std_sha256_hash_x86_64-apple-darwin:=52084c8cdb34ca139a00f9f03f1a582d96b677e9f223a8d1aa31ae575a06cc16 # macOS (ARMv8) -$(package)_rust_std_targets += aarch64-apple-darwin -$(package)_rust_target_aarch64-apple-darwin:=aarch64-apple-darwin -$(package)_rust_target_arm64-apple-darwin:=aarch64-apple-darwin $(package)_file_name_aarch64_darwin:=rust-$($(package)_version)-aarch64-apple-darwin.tar.gz $(package)_sha256_hash_aarch64_darwin:=49b6d36b308addcfd21ae56c94957688338ba7b8985bff57fc626c8e1b32f62c -$(package)_rust_std_sha256_hash_aarch64-apple-darwin:=5ec28e75ed8715efaa2490d76ae026a34b13df6899d98b14d0a6995556f4e6b4 - -# Linux (ARMv7) - Cross only -$(package)_rust_std_targets += armv7-unknown-linux-gnueabihf -$(package)_rust_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf -$(package)_rust_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf -$(package)_rust_std_sha256_hash_armv7-unknown-linux-gnueabihf:=5dd8b36467e03ba47bfa7ea5d7578c66bccb648dd2129d7cec6fb3ff00f81ca3 - -# Linux (PowerPC 64-bit) - Cross only -$(package)_rust_std_targets += powerpc64le-unknown-linux-gnu -$(package)_rust_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-gnu -$(package)_rust_std_sha256_hash_powerpc64le-unknown-linux-gnu:=142c7c2896fa4596b5c4c35d9d5e4d80acd5a699e5fa0560d92a89eda035ece3 - -# Linux (RISCV64 GC) - Cross only -$(package)_rust_std_targets += riscv64gc-unknown-linux-gnu -$(package)_rust_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu -$(package)_rust_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu -$(package)_rust_std_sha256_hash_riscv64gc-unknown-linux-gnu:=7b35c8207c77e3fc2f7f7a26dea989cc2cdc13a955851ff74d4882f96f4e14dd -# Windows (x86_64) - Cross only -$(package)_rust_std_targets += x86_64-pc-windows-gnu -$(package)_rust_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu -$(package)_rust_target_x86_64-pc-windows-gnu:=x86_64-pc-windows-gnu -$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu:=32d42270b114c9341e5bc9b1d24f336024889ddd32a7d22e4700cc3c45fe9d3d +# macOS (x86_64) +$(package)_file_name_x86_64_darwin:=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz +$(package)_sha256_hash_x86_64_darwin:=b1a289cabc523f259f65116a41374ac159d72fbbf6c373bd5e545c8e835ceb6a -### -$(package)_file_name:=$($(package)_file_name_$(build_arch)_$(build_os)) -$(package)_sha256_hash:=$($(package)_sha256_hash_$(build_arch)_$(build_os)) -$(package)_rust_target:=$(or $($(package)_rust_target_$(canonical_host)),$($(package)_rust_target_$(subst -pc-,-unknown-,$(canonical_host))),$($(package)_rust_target_$(subst -unknown-,-pc-,$(canonical_host)))) -### +$(package)_file_name=$($(package)_file_name_$(build_arch)_$(build_os)) +$(package)_sha256_hash=$($(package)_sha256_hash_$(build_arch)_$(build_os)) define $(package)_set_vars $(package)_stage_opts=--disable-ldconfig $(package)_stage_build_opts=--without=rust-docs-json-preview,rust-docs endef -ifneq ($(canonical_host),$(build)) -$(package)_exact_file_name:=rust-std-$($(package)_version)-$($(package)_rust_target).tar.gz -$(package)_exact_sha256_hash:=$($(package)_rust_std_sha256_hash_$($(package)_rust_target)) -$(package)_build_subdir:=buildos -$(package)_extra_sources:=$($(package)_exact_file_name) - define $(package)_fetch_cmds -$(call fetch_file,$(package),$($(package)_download_path),$($(package)_exact_file_name),$($(package)_exact_file_name),$($(package)_exact_sha256_hash)) && \ -$(call fetch_file,$(package),$($(package)_download_path),$($(package)_file_name_$(build_arch)_$(build_os)),$($(package)_file_name_$(build_arch)_$(build_os)),$($(package)_sha256_hash_$(build_arch)_$(build_os))) -endef - -define $(package)_extract_cmds - mkdir -p $($(package)_extract_dir) && \ - echo "$($(package)_exact_sha256_hash) $($(package)_source_dir)/$($(package)_exact_file_name)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - echo "$($(package)_sha256_hash_$(build_arch)_$(build_os)) $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os))" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - mkdir $(canonical_host) && \ - $(build_TAR) -P --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_exact_file_name) -C $(canonical_host) && \ - mkdir buildos && \ - $(build_TAR) -P --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_file_name_$(build_arch)_$(build_os)) -C buildos -endef - -define $(package)_stage_cmds - mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/bin && \ - mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib && \ - cp cargo/bin/cargo $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ - cp rustc/bin/rustc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ - cp rustc/bin/rustdoc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ - cp -r rustc/lib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/ && \ - cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ - cp -r ../$(canonical_host)/rust-std-$($(package)_rust_target)/lib/rustlib/$($(package)_rust_target) $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ - bash $(BASEDIR)/patches/native_rust/fix-elf-interpreter.sh \ - $($(package)_staging_dir)/$(host_prefix)/native/lib \ - $($(package)_staging_dir)/$(host_prefix)/native/bin/cargo \ - $($(package)_staging_dir)/$(host_prefix)/native/bin/rustc \ - $($(package)_staging_dir)/$(host_prefix)/native/bin/rustdoc +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_file_name),$($(package)_file_name),$($(package)_sha256_hash)) endef -else define $(package)_stage_cmds mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/bin && \ @@ -133,4 +56,3 @@ define $(package)_stage_cmds $($(package)_staging_dir)/$(host_prefix)/native/bin/rustc \ $($(package)_staging_dir)/$(host_prefix)/native/bin/rustdoc endef -endif diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index ac4c9224c9c5..66ffa913b07c 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,4 +1,4 @@ -packages:=gmp backtrace rustcxx +packages:=gmp backtrace rustcxx rust_stdlib boost_packages = boost diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk new file mode 100644 index 000000000000..bebe886948af --- /dev/null +++ b/depends/packages/rust_stdlib.mk @@ -0,0 +1,77 @@ +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# To update the Rust stdlib, change the version below and then run the script +# ./contrib/devtools/update-rust-hashes.py + +package:=rust_stdlib +$(package)_version:=1.82.0 +$(package)_download_path:=https://static.rust-lang.org/dist +$(package)_dependencies:=native_rust +$(package)_target=$(or \ + $($(package)_target_$(canonical_host)),\ + $($(package)_target_$(subst -pc-,-unknown-,$(canonical_host))),\ + $($(package)_target_$(subst -unknown-,-pc-,$(canonical_host))),\ + $($(package)_target_$(subst -linux-,-unknown-linux-,$(canonical_host)))) + +# FreeBSD (x86_64) +$(package)_targets += x86_64-unknown-freebsd +$(package)_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd +$(package)_sha256_hash_x86_64-unknown-freebsd:=be1acaf3c2f15d42b05b1f032db5ac3b11a0ac5a91c0efef26f2d8135d68a829 + +# Linux (ARMv7) +$(package)_targets += armv7-unknown-linux-gnueabihf +$(package)_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf +$(package)_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf +$(package)_sha256_hash_armv7-unknown-linux-gnueabihf:=5dd8b36467e03ba47bfa7ea5d7578c66bccb648dd2129d7cec6fb3ff00f81ca3 + +# Linux (ARMv8) +$(package)_targets += aarch64-unknown-linux-gnu +$(package)_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-gnu +$(package)_sha256_hash_aarch64-unknown-linux-gnu:=82b2308ee531775bf4d1faa57bddfae85f363bec43ca36ba6db4ebad7c1450d4 + +# Linux (PowerPC 64-bit little-endian) +$(package)_targets += powerpc64le-unknown-linux-gnu +$(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-gnu +$(package)_sha256_hash_powerpc64le-unknown-linux-gnu:=142c7c2896fa4596b5c4c35d9d5e4d80acd5a699e5fa0560d92a89eda035ece3 + +# Linux (RISCV64GC) +$(package)_targets += riscv64gc-unknown-linux-gnu +$(package)_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu +$(package)_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu +$(package)_sha256_hash_riscv64gc-unknown-linux-gnu:=7b35c8207c77e3fc2f7f7a26dea989cc2cdc13a955851ff74d4882f96f4e14dd + +# Linux (x86_64) +$(package)_targets += x86_64-unknown-linux-gnu +$(package)_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-gnu +$(package)_sha256_hash_x86_64-unknown-linux-gnu:=e7e808b8745298369fa3bbc3c0b7af9ca0fb995661bd684a7022d14bc9ae0057 + +# macOS (ARMv8) +$(package)_targets += aarch64-apple-darwin +$(package)_target_aarch64-apple-darwin:=aarch64-apple-darwin +$(package)_target_arm64-apple-darwin:=aarch64-apple-darwin +$(package)_sha256_hash_aarch64-apple-darwin:=5ec28e75ed8715efaa2490d76ae026a34b13df6899d98b14d0a6995556f4e6b4 + +# macOS (x86_64) +$(package)_targets += x86_64-apple-darwin +$(package)_target_x86_64-apple-darwin:=x86_64-apple-darwin +$(package)_sha256_hash_x86_64-apple-darwin:=52084c8cdb34ca139a00f9f03f1a582d96b677e9f223a8d1aa31ae575a06cc16 + +# Windows (x86_64) +$(package)_targets += x86_64-pc-windows-gnu +$(package)_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu +$(package)_sha256_hash_x86_64-pc-windows-gnu:=32d42270b114c9341e5bc9b1d24f336024889ddd32a7d22e4700cc3c45fe9d3d + +$(package)_file_name=rust-std-$($(package)_version)-$($(package)_target).tar.gz +$(package)_sha256_hash=$($(package)_sha256_hash_$($(package)_target)) + +define $(package)_fetch_cmds + $(call fetch_file,$(package),$($(package)_download_path),$($(package)_file_name),$($(package)_file_name),$($(package)_sha256_hash)) +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib && \ + cp -r rust-std-$($(package)_target)/lib/rustlib/$($(package)_target) $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ +endef From a8016ed519eca35ac56649bfbd03c552f9715f57 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 18 Jan 2026 11:59:24 +0530 Subject: [PATCH 19/60] build: switch to Rust 1.85.1, use musl stdlib to avoid Guix glibc issues The conflict occurs due a difference in glibc version between the Guix environment and the targets compiled, this is only a problem for Linux targets so the issue doesn't extend to Windows --- .cargo/config.toml.offline | 10 +++--- configure.ac | 16 +++++----- contrib/devtools/update-rust-hashes.py | 10 +++--- depends/packages/native_rust.mk | 12 +++---- depends/packages/rust_stdlib.mk | 44 +++++++++++++------------- rust-toolchain.toml | 2 +- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.cargo/config.toml.offline b/.cargo/config.toml.offline index df54e6e30c49..82e141e0bcc4 100644 --- a/.cargo/config.toml.offline +++ b/.cargo/config.toml.offline @@ -1,17 +1,17 @@ # Linux -[target.aarch64-unknown-linux-gnu] +[target.aarch64-unknown-linux-musl] linker = "aarch64-linux-gnu-gcc" -[target.armv7-unknown-linux-gnueabihf] +[target.armv7-unknown-linux-musleabihf] linker = "arm-linux-gnueabihf-gcc" -[target.powerpc64le-unknown-linux-gnu] +[target.powerpc64le-unknown-linux-musl] linker = "powerpc64le-linux-gnu-gcc" -[target.riscv64gc-unknown-linux-gnu] +[target.riscv64gc-unknown-linux-musl] linker = "riscv64-linux-gnu-gcc" -[target.x86_64-unknown-linux-gnu] +[target.x86_64-unknown-linux-musl] linker = "x86-64-linux-gnu-gcc" # Windows diff --git a/configure.ac b/configure.ac index 2510cb7ff90e..f724137ec405 100644 --- a/configure.ac +++ b/configure.ac @@ -1753,12 +1753,12 @@ AC_DEFUN([RS_SET_TRIPLE], [ case $2 in x86_64-*-freebsd*) $1="x86_64-unknown-freebsd" ;; aarch64-*-linux*|arm64-*-linux*) - $1="aarch64-unknown-linux-gnu" ;; - arm-*-linux*) $1="armv7-unknown-linux-gnueabihf" ;; - powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; - powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-gnu" ;; - riscv64-*-linux*) $1="riscv64gc-unknown-linux-gnu" ;; - x86_64-*-linux*) $1="x86_64-unknown-linux-gnu" ;; + $1="aarch64-unknown-linux-$3" ;; + arm-*-linux*) $1="armv7-unknown-linux-$3eabihf" ;; + powerpc64-*-linux*) $1="powerpc64-unknown-linux-$3" ;; + powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-$3" ;; + riscv64-*-linux*) $1="riscv64gc-unknown-linux-$3" ;; + x86_64-*-linux*) $1="x86_64-unknown-linux-$3" ;; x86_64-*-darwin*) $1="x86_64-apple-darwin" ;; aarch64-*-darwin*|arm64-*-darwin*) $1="aarch64-apple-darwin" ;; @@ -1768,7 +1768,7 @@ AC_DEFUN([RS_SET_TRIPLE], [ ]) AC_MSG_CHECKING([for Rust target]) -RS_SET_TRIPLE([RUST_TARGET], [$host]) +RS_SET_TRIPLE([RUST_TARGET], [$host], [musl]) if test "$RUST_TARGET" = ""; then AC_MSG_RESULT([unknown]) AC_MSG_ERROR([Unsupported target for Rust: $host]) @@ -1790,7 +1790,7 @@ case $host in esac AC_MSG_CHECKING([for Rust host]) -RS_SET_TRIPLE([RUST_NATIVE], [$build]) +RS_SET_TRIPLE([RUST_NATIVE], [$build], [gnu]) if test "$RUST_NATIVE" = ""; then if test "$cross_compiling" = "yes"; then AC_MSG_RESULT([unknown]) diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 5e8dd0bb83d5..04fef67f9513 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -16,11 +16,11 @@ # FreeBSD "x86_64-unknown-freebsd", # Linux - "aarch64-unknown-linux-gnu", - "armv7-unknown-linux-gnueabihf", - "powerpc64le-unknown-linux-gnu", - "riscv64gc-unknown-linux-gnu", - "x86_64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", + "armv7-unknown-linux-musleabihf", + "powerpc64le-unknown-linux-musl", + "riscv64gc-unknown-linux-musl", + "x86_64-unknown-linux-musl", # Windows "x86_64-pc-windows-gnu", # macOS diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index c48787da63f8..961517b96ff1 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -7,28 +7,28 @@ # ./contrib/devtools/update-rust-hashes.py package:=native_rust -$(package)_version:=1.82.0 +$(package)_version:=1.85.1 $(package)_download_path:=https://static.rust-lang.org/dist # FreeBSD (x86_64) $(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz -$(package)_sha256_hash_x86_64_freebsd:=f7b51943dbed0af3387e3269c1767fee916fb22b8e7897b3594bf5e422403137 +$(package)_sha256_hash_x86_64_freebsd:=f905730e22a9a8a2dfce1ab0c50d427b7978c5b235c33018b09552041b6f6329 # Linux (ARMv8) $(package)_file_name_aarch64_linux:=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_aarch64_linux:=d7db04fce65b5f73282941f3f1df5893be9810af17eb7c65b2e614461fe31a48 +$(package)_sha256_hash_aarch64_linux:=d2609d8cd965060f0b4a8c509131066369e8d3d31a92fedce177b42b32af6b4d # Linux (x86_64) $(package)_file_name_x86_64_linux:=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_x86_64_linux:=0265c08ae997c4de965048a244605fb1f24a600bbe35047b811c638b8fcf676b +$(package)_sha256_hash_x86_64_linux:=b7202563a52b47f575b284a5a4794fafd688e39bfe8fd855b5e80129e671cb7f # macOS (ARMv8) $(package)_file_name_aarch64_darwin:=rust-$($(package)_version)-aarch64-apple-darwin.tar.gz -$(package)_sha256_hash_aarch64_darwin:=49b6d36b308addcfd21ae56c94957688338ba7b8985bff57fc626c8e1b32f62c +$(package)_sha256_hash_aarch64_darwin:=64b0341a47e684d648c9b7defd0b7ff9d5397a64718cf803c1e114544f94bbe9 # macOS (x86_64) $(package)_file_name_x86_64_darwin:=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_x86_64_darwin:=b1a289cabc523f259f65116a41374ac159d72fbbf6c373bd5e545c8e835ceb6a +$(package)_sha256_hash_x86_64_darwin:=6e321957b7301d48e5ecf61bdeea6560400a5948b3e72830348367a8a9696ad7 $(package)_file_name=$($(package)_file_name_$(build_arch)_$(build_os)) $(package)_sha256_hash=$($(package)_sha256_hash_$(build_arch)_$(build_os)) diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index bebe886948af..16e47c439434 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -7,7 +7,7 @@ # ./contrib/devtools/update-rust-hashes.py package:=rust_stdlib -$(package)_version:=1.82.0 +$(package)_version:=1.85.1 $(package)_download_path:=https://static.rust-lang.org/dist $(package)_dependencies:=native_rust $(package)_target=$(or \ @@ -19,50 +19,50 @@ $(package)_target=$(or \ # FreeBSD (x86_64) $(package)_targets += x86_64-unknown-freebsd $(package)_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd -$(package)_sha256_hash_x86_64-unknown-freebsd:=be1acaf3c2f15d42b05b1f032db5ac3b11a0ac5a91c0efef26f2d8135d68a829 +$(package)_sha256_hash_x86_64-unknown-freebsd:=08a691bcdb5bde37178368e9e49dbd822d9e39c68b9371191bd16ab7f8b321c4 # Linux (ARMv7) -$(package)_targets += armv7-unknown-linux-gnueabihf -$(package)_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf -$(package)_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-gnueabihf -$(package)_sha256_hash_armv7-unknown-linux-gnueabihf:=5dd8b36467e03ba47bfa7ea5d7578c66bccb648dd2129d7cec6fb3ff00f81ca3 +$(package)_targets += armv7-unknown-linux-musleabihf +$(package)_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf +$(package)_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf +$(package)_sha256_hash_armv7-unknown-linux-musleabihf:=fbdb48968dd7af3a862c29e4e3ff85bcf333d97d21d262f347106542cc08b96d # Linux (ARMv8) -$(package)_targets += aarch64-unknown-linux-gnu -$(package)_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-gnu -$(package)_sha256_hash_aarch64-unknown-linux-gnu:=82b2308ee531775bf4d1faa57bddfae85f363bec43ca36ba6db4ebad7c1450d4 +$(package)_targets += aarch64-unknown-linux-musl +$(package)_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-musl +$(package)_sha256_hash_aarch64-unknown-linux-musl:=991cc2f78d3db8fa1131ee2bb5807497e93e1efb9f447e2a7def0c4032ba4c54 # Linux (PowerPC 64-bit little-endian) -$(package)_targets += powerpc64le-unknown-linux-gnu -$(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-gnu -$(package)_sha256_hash_powerpc64le-unknown-linux-gnu:=142c7c2896fa4596b5c4c35d9d5e4d80acd5a699e5fa0560d92a89eda035ece3 +$(package)_targets += powerpc64le-unknown-linux-musl +$(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-musl +$(package)_sha256_hash_powerpc64le-unknown-linux-musl:=f6fad3f1c69acdd832ea2f487863f6428ba6e77b16c18e8db7fcd91b88e9e254 # Linux (RISCV64GC) -$(package)_targets += riscv64gc-unknown-linux-gnu -$(package)_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu -$(package)_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-gnu -$(package)_sha256_hash_riscv64gc-unknown-linux-gnu:=7b35c8207c77e3fc2f7f7a26dea989cc2cdc13a955851ff74d4882f96f4e14dd +$(package)_targets += riscv64gc-unknown-linux-musl +$(package)_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-musl +$(package)_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-musl +$(package)_sha256_hash_riscv64gc-unknown-linux-musl:=4a85e0c909d6a3202919638c3b95a496acdfec7e1245be1c406b7c1d26c32fba # Linux (x86_64) -$(package)_targets += x86_64-unknown-linux-gnu -$(package)_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-gnu -$(package)_sha256_hash_x86_64-unknown-linux-gnu:=e7e808b8745298369fa3bbc3c0b7af9ca0fb995661bd684a7022d14bc9ae0057 +$(package)_targets += x86_64-unknown-linux-musl +$(package)_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-musl +$(package)_sha256_hash_x86_64-unknown-linux-musl:=3035f0c3ea9ae10ba1c21871c7a53cdb54a398616febffd42825965627a77216 # macOS (ARMv8) $(package)_targets += aarch64-apple-darwin $(package)_target_aarch64-apple-darwin:=aarch64-apple-darwin $(package)_target_arm64-apple-darwin:=aarch64-apple-darwin -$(package)_sha256_hash_aarch64-apple-darwin:=5ec28e75ed8715efaa2490d76ae026a34b13df6899d98b14d0a6995556f4e6b4 +$(package)_sha256_hash_aarch64-apple-darwin:=5d2fd6b5c3c482750074b6ab04443b1ec41ca824fddc814aab6a1fbcf5cfb53a # macOS (x86_64) $(package)_targets += x86_64-apple-darwin $(package)_target_x86_64-apple-darwin:=x86_64-apple-darwin -$(package)_sha256_hash_x86_64-apple-darwin:=52084c8cdb34ca139a00f9f03f1a582d96b677e9f223a8d1aa31ae575a06cc16 +$(package)_sha256_hash_x86_64-apple-darwin:=b5111b105cfeb2772d92ca54e6f1c01d11def9c675c633f7d1ebdd09b83b0139 # Windows (x86_64) $(package)_targets += x86_64-pc-windows-gnu $(package)_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu -$(package)_sha256_hash_x86_64-pc-windows-gnu:=32d42270b114c9341e5bc9b1d24f336024889ddd32a7d22e4700cc3c45fe9d3d +$(package)_sha256_hash_x86_64-pc-windows-gnu:=ae5c8942b3ccab5841c9ea65d1ac839c62553a763512799eb4c89de2ffad3d3e $(package)_file_name=rust-std-$($(package)_version)-$($(package)_target).tar.gz $(package)_sha256_hash=$($(package)_sha256_hash_$($(package)_target)) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2e2b8c8521ea..00822fdf5828 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.82.0" +channel = "1.85.1" From dedefddb30220aab272ea6ae0fffebbb58058161 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 25 Jan 2026 00:30:04 +0530 Subject: [PATCH 20/60] fix: resolve issues with dist builds --- Makefile.am | 7 ++++++- rust/Makefile.am | 3 +++ rust/Makefile.chirp.include | 28 ++++++++++++++++++++++++++-- src/Makefile.am | 2 +- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 97a2fd35bea0..9e7ff1064f30 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,11 @@ WINDOWS_PACKAGING = $(top_srcdir)/share/pixmaps/dash.ico \ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_INSTALLER_ICONS) \ $(top_srcdir)/contrib/macdeploy/detached-sig-create.sh +CARGO_FILES = \ + $(top_srcdir)/.cargo/config.toml.offline \ + $(top_srcdir)/Cargo.lock \ + $(top_srcdir)/Cargo.toml + COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \ test_dash_filtered.info total_coverage.info \ baseline_filtered.info functional_test.info functional_test_filtered.info \ @@ -249,7 +254,7 @@ endif dist_noinst_SCRIPTS = autogen.sh -EXTRA_DIST = $(DIST_SHARE) $(DIST_CONTRIB) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) $(BIN_CHECKS) +EXTRA_DIST = $(DIST_SHARE) $(DIST_CONTRIB) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) $(BIN_CHECKS) $(CARGO_FILES) EXTRA_DIST += \ test/functional \ diff --git a/rust/Makefile.am b/rust/Makefile.am index c01b61e07773..247add8b3219 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -63,6 +63,9 @@ endif # ENABLE_ONLINE_RUST include $(top_srcdir)/rust/Makefile.libs.include +EXTRA_DIST = \ + $(LIBRUST_CHIRP_FILES) + all-local: $(CARGO_CONFIGURED) cargo-build-chirp cxxbridge-chirp cargo-build: $(CARGO_CONFIGURED) cargo-build-chirp diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 8e575a1c9704..42820ce6c98d 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -9,6 +9,7 @@ LIBRUST_CHIRP = $(LIBRUST_CHIRP_TARGET_DIR)/$(RUST_TARGET)/$(CARGO_PROFILE)/libc LIBRUST_CHIRP_CARGO_ENV = $(CARGO_ENV) CARGO_TARGET_DIR="$(LIBRUST_CHIRP_TARGET_DIR)" LIBRUST_CHIRP_CRATE_DIR = $(top_srcdir)/rust/chirp LIBRUST_CHIRP_GEN_DIR = $(abs_top_builddir)/rust/chirp/gen +LIBRUST_CHIRP_GEN_SRCDIR = $(top_srcdir)/rust/chirp/gen LIBRUST_CHIRP_MANIFEST = $(LIBRUST_CHIRP_CRATE_DIR)/Cargo.toml LIBRUST_CHIRP_CARGO_BUILD_OPTS = $(CARGO_BUILD_OPTS) --manifest-path $(LIBRUST_CHIRP_MANIFEST) @@ -27,11 +28,28 @@ LIBRUST_CHIRP_H = \ LIBRUST_CHIRP_INCLUDES = \ -I$(LIBRUST_CHIRP_GEN_DIR)/include +LIBRUST_CHIRP_FILES = \ + $(LIBRUST_CHIRP_BUILD) \ + $(LIBRUST_CHIRP_MANIFEST) \ + $(LIBRUST_CHIRP_SRCS) + $(LIBRUST_CHIRP_SRCS): ; -$(LIBRUST_CHIRP_H) $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) +$(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) + $(AM_V_at)$(MKDIR_P) $(@D) + $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp; then \ + cp $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp $@; \ + else \ + $(CXXBRIDGE) $< -o $@; \ + fi + +$(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(AM_V_at)$(MKDIR_P) $(@D) - $(AM_V_GEN)$(CXXBRIDGE) $< $(if $(filter %.h,$@),--header) -o $@ + $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h; then \ + cp $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h $@; \ + else \ + $(CXXBRIDGE) $< --header -o $@; \ + fi $(LIBRUST_CHIRP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_BUILD) $(LIBRUST_CHIRP_MANIFEST) $(AM_V_GEN)$(LIBRUST_CHIRP_CARGO_ENV) $(CARGO) build $(LIBRUST_CHIRP_CARGO_BUILD_OPTS) @@ -46,4 +64,10 @@ cxxbridge-clean-chirp: cxxbridge-chirp: $(LIBRUST_CHIRP_CPP) $(LIBRUST_CHIRP_H) +dist-hook: cxxbridge-chirp + $(MKDIR_P) $(distdir)/chirp/gen/src + $(MKDIR_P) $(distdir)/chirp/gen/include/rust/chirp + cp $(LIBRUST_CHIRP_CPP) $(distdir)/chirp/gen/src/ + cp $(LIBRUST_CHIRP_H) $(distdir)/chirp/gen/include/rust/chirp/ + .PHONY: cargo-build-chirp cargo-clean-chirp cxxbridge-chirp cxxbridge-clean-chirp diff --git a/src/Makefile.am b/src/Makefile.am index ed415ded5dfc..615ea344fd53 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1431,7 +1431,7 @@ endif libcxxbridge_la_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(PIC_FLAGS) libcxxbridge_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(PIC_FLAGS) -static libcxxbridge_la_LDFLAGS = $(AM_LDFLAGS) -static -libcxxbridge_la_SOURCES = $(LIBRUSTDEPS_CPP) +nodist_libcxxbridge_la_SOURCES = $(LIBRUSTDEPS_CPP) $(libcxxbridge_la_OBJECTS): $(LIBRUSTDEPS_H) # From a48f5c4c0928e61ad3cd83c21e5cb16ba576f3e7 Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 7 Aug 2026 12:00:56 -0500 Subject: [PATCH 21/60] build: aggregate Rust components via umbrella crate instead of ar-merging Merging per-crate staticlibs with 'ar -x' into a flat directory silently drops object files once member basenames collide, which happens as soon as two crates share dependencies (measured: 373 of 374 members collide between two crates built from one workspace). Replace the merge with an umbrella staticlib crate, rust/dashrust, that depends on each component as an rlib: cargo deduplicates shared dependencies, applies LTO across the whole graph, and emits a single archive. Component crates keep their own cxx bridges and codegen; per-crate Makefile includes now contribute only cxxbridge artifacts. Optional components become cargo features on the umbrella crate, plumbed from configure via RUST_CRATE_FEATURES. Per-crate dist-hook recipes are replaced by an aggregate dist-hook so additional crates do not collide on automake's one-recipe-per-Makefile rule. --- Cargo.lock | 97 ++++++++++++++++++++----------------- Cargo.toml | 1 + configure.ac | 7 +++ rust/Makefile.am | 14 ++++-- rust/Makefile.chirp.include | 21 +++----- rust/Makefile.libs.include | 74 +++++++++++++++------------- rust/chirp/Cargo.toml | 2 +- rust/dashrust/Cargo.toml | 16 ++++++ rust/dashrust/src/lib.rs | 11 +++++ 9 files changed, 145 insertions(+), 98 deletions(-) create mode 100644 rust/dashrust/Cargo.toml create mode 100644 rust/dashrust/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 0baf0e1fce0a..1a4a89d2d32e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,24 +1,24 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anstyle" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "built" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" +checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" [[package]] name = "cc" -version = "1.2.52" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +checksum = "9066c49992464636f92905fa096ec58baaa4d57ec19a5c096c68d3e25ef3d136" dependencies = [ "find-msvc-tools", "shlex", @@ -34,18 +34,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.54" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.54" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889" dependencies = [ "anstyle", "clap_lex", @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.7" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "codespan-reporting" @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.192" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbda285ba6e5866529faf76352bdf73801d9b44a6308d7cd58ca2379f378e994" +checksum = "6fe442a792c7c736eea18b32a7f8a3b63cf8aafabda6760042dc2fdeda456291" dependencies = [ "cc", "cxx-build", @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.192" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af9efde466c5d532d57efd92f861da3bdb7f61e369128ce8b4c3fe0c9de4fa4d" +checksum = "e3184a94384c663718698311a78a51ac00c484c10b4eeac06fb0a068c5f64fa2" dependencies = [ "cc", "codespan-reporting", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "cxxbridge-cmd" -version = "1.0.192" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efb93799095bccd4f763ca07997dc39a69e5e61ab52d2c407d4988d21ce144d" +checksum = "0148d8fd1199329ddf1d157a5e134e51ceff37c6a7ddd38615c399d81cb05d8d" dependencies = [ "clap", "codespan-reporting", @@ -115,15 +115,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.192" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092010228026e143b32a4463ed9fa8f86dca266af4bf5f3b2a26e113dbe4e45" +checksum = "52850339faed2eaadd24e286dc1d8268cc6f8a7bd9524d713adc9099566b4c89" [[package]] name = "cxxbridge-macro" -version = "1.0.192" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d72ebfcd351ae404fb00ff378dfc9571827a00722c9e735c9181aec320ba0a" +checksum = "2c77c856545d886c9bd5215409ebb63b925e262135248b50c79e5a5f194ee47c" dependencies = [ "indexmap", "proc-macro2", @@ -131,6 +131,13 @@ dependencies = [ "syn", ] +[[package]] +name = "dashrust" +version = "0.1.0" +dependencies = [ + "chirp", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -139,9 +146,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "find-msvc-tools" -version = "0.1.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" +checksum = "26b73573e6edcd2af0cdf47bd6cb58f0b3839491263c314eaad1ccf24430e1de" [[package]] name = "foldhash" @@ -151,15 +158,15 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "hashbrown" -version = "0.16.1" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "indexmap" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", "hashbrown", @@ -176,18 +183,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.43" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -200,9 +207,9 @@ checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -210,18 +217,18 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", @@ -230,9 +237,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "strsim" @@ -242,9 +249,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.114" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" dependencies = [ "proc-macro2", "quote", @@ -262,9 +269,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-width" diff --git a/Cargo.toml b/Cargo.toml index 68133a4d0d6d..7defb05f6393 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "rust/chirp", + "rust/dashrust", ] resolver = "2" diff --git a/configure.ac b/configure.ac index f724137ec405..87953940888f 100644 --- a/configure.ac +++ b/configure.ac @@ -160,6 +160,12 @@ AC_ARG_ENABLE([online-rust], [enable_online_rust=no]) AM_CONDITIONAL([ENABLE_ONLINE_RUST], [test "$enable_online_rust" != "no"]) +dnl Cargo features enabling optional components of the umbrella crate +dnl (rust/dashrust). Populated by feature-specific configure flags below; +dnl empty means only the always-on components are built. +RUST_CRATE_FEATURES="" +AC_SUBST(RUST_CRATE_FEATURES) + AC_ARG_ENABLE([wallet], [AS_HELP_STRING([--disable-wallet], [disable wallet (enabled by default)])], @@ -2091,6 +2097,7 @@ AM_CONDITIONAL([USE_QRCODE], [test "$use_qr" = "yes"]) AM_CONDITIONAL([USE_LCOV], [test "$use_lcov" = "yes"]) AM_CONDITIONAL([USE_LIBEVENT], [test "$use_libevent" = "yes"]) AM_CONDITIONAL([HARDEN], [test "$use_hardening" = "yes"]) +AM_CONDITIONAL([ENABLE_RUST_FEATURES], [test -n "$RUST_CRATE_FEATURES"]) AM_CONDITIONAL([ENABLE_SSSE3], [test "$enable_ssse3" = "yes"]) AM_CONDITIONAL([ENABLE_SSE42], [test "$enable_sse42" = "yes"]) AM_CONDITIONAL([ENABLE_SSE41], [test "$enable_sse41" = "yes"]) diff --git a/rust/Makefile.am b/rust/Makefile.am index 247add8b3219..2d587a26941f 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -64,13 +64,19 @@ endif # ENABLE_ONLINE_RUST include $(top_srcdir)/rust/Makefile.libs.include EXTRA_DIST = \ + $(LIBRUSTDEPS_FILES) \ $(LIBRUST_CHIRP_FILES) -all-local: $(CARGO_CONFIGURED) cargo-build-chirp cxxbridge-chirp +all-local: $(CARGO_CONFIGURED) cargo-build-dashrust cxxbridge-chirp -cargo-build: $(CARGO_CONFIGURED) cargo-build-chirp +cargo-build: $(CARGO_CONFIGURED) cargo-build-dashrust -cargo-clean: cargo-clean-chirp +cargo-clean: cargo-clean-dashrust + +# Aggregate dist hook: per-crate includes define dist- targets; new +# crates append here instead of defining their own dist-hook (automake allows +# only one dist-hook recipe per Makefile). +dist-hook: dist-chirp cargo-clean-config: $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online @@ -78,6 +84,6 @@ cargo-clean-config: $(AM_V_at)rm -f $(top_srcdir)/.cargo/config.toml $(AM_V_at)rm -f $(top_srcdir)/.cargo/config -clean-local: cargo-clean-chirp cxxbridge-clean-chirp clean-librustdeps-la cargo-clean-config +clean-local: cargo-clean-dashrust cxxbridge-clean-chirp cargo-clean-config .PHONY: cargo-build cargo-clean cargo-clean-config diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 42820ce6c98d..bb57cdc99e0f 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -3,15 +3,14 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -LIBRUST_CHIRP_TARGET_DIR = $(abs_top_builddir)/rust/chirp/target -LIBRUST_CHIRP = $(LIBRUST_CHIRP_TARGET_DIR)/$(RUST_TARGET)/$(CARGO_PROFILE)/libchirp.a +# cxxbridge codegen for the `chirp` component. Compilation happens through +# the umbrella crate `dashrust` (see Makefile.libs.include); this file only +# generates and distributes the C++ side of the bridge. -LIBRUST_CHIRP_CARGO_ENV = $(CARGO_ENV) CARGO_TARGET_DIR="$(LIBRUST_CHIRP_TARGET_DIR)" LIBRUST_CHIRP_CRATE_DIR = $(top_srcdir)/rust/chirp LIBRUST_CHIRP_GEN_DIR = $(abs_top_builddir)/rust/chirp/gen LIBRUST_CHIRP_GEN_SRCDIR = $(top_srcdir)/rust/chirp/gen LIBRUST_CHIRP_MANIFEST = $(LIBRUST_CHIRP_CRATE_DIR)/Cargo.toml -LIBRUST_CHIRP_CARGO_BUILD_OPTS = $(CARGO_BUILD_OPTS) --manifest-path $(LIBRUST_CHIRP_MANIFEST) LIBRUST_CHIRP_SRCS = \ $(LIBRUST_CHIRP_CRATE_DIR)/src/lib.rs @@ -48,26 +47,18 @@ $(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h $@; \ else \ - $(CXXBRIDGE) $< --header -o $@; \ + $(CXXBRIDGE) $< --header -o $@; \ fi -$(LIBRUST_CHIRP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_BUILD) $(LIBRUST_CHIRP_MANIFEST) - $(AM_V_GEN)$(LIBRUST_CHIRP_CARGO_ENV) $(CARGO) build $(LIBRUST_CHIRP_CARGO_BUILD_OPTS) - -cargo-build-chirp: $(LIBRUST_CHIRP) - -cargo-clean-chirp: - $(AM_V_at)rm -rf $(LIBRUST_CHIRP_TARGET_DIR) - cxxbridge-clean-chirp: $(AM_V_at)rm -rf $(LIBRUST_CHIRP_GEN_DIR) cxxbridge-chirp: $(LIBRUST_CHIRP_CPP) $(LIBRUST_CHIRP_H) -dist-hook: cxxbridge-chirp +dist-chirp: cxxbridge-chirp $(MKDIR_P) $(distdir)/chirp/gen/src $(MKDIR_P) $(distdir)/chirp/gen/include/rust/chirp cp $(LIBRUST_CHIRP_CPP) $(distdir)/chirp/gen/src/ cp $(LIBRUST_CHIRP_H) $(distdir)/chirp/gen/include/rust/chirp/ -.PHONY: cargo-build-chirp cargo-clean-chirp cxxbridge-chirp cxxbridge-clean-chirp +.PHONY: cxxbridge-chirp cxxbridge-clean-chirp dist-chirp diff --git a/rust/Makefile.libs.include b/rust/Makefile.libs.include index f74839887523..cee9c0832082 100644 --- a/rust/Makefile.libs.include +++ b/rust/Makefile.libs.include @@ -9,11 +9,14 @@ else CARGO_PROFILE=release endif +# Per-crate includes contribute cxxbridge codegen artifacts (generated C++ +# sources/headers and dist file lists). Compilation is NOT per-crate: all +# component crates are rlib dependencies of the umbrella crate `dashrust`, +# which cargo builds in one invocation into a single deduplicated staticlib. +# This avoids merging per-crate archives with `ar -x`, which silently drops +# object files with colliding member names once two crates share dependencies. include $(top_srcdir)/rust/Makefile.chirp.include -LIBRUSTDEPS_A = \ - $(LIBRUST_CHIRP) - LIBRUSTDEPS_INCLUDES = \ $(LIBRUST_CHIRP_INCLUDES) @@ -23,34 +26,39 @@ LIBRUSTDEPS_CPP = \ LIBRUSTDEPS_H = \ $(LIBRUST_CHIRP_H) -# Libtool wrapper # -LIBRUSTDEPS = $(abs_top_builddir)/rust/librustdeps.la -LIBRUSTDEPS_LIBDIR = $(abs_top_builddir)/rust/.libs - -$(LIBRUSTDEPS): $(LIBRUSTDEPS_A) - $(AM_V_at)$(MKDIR_P) $(LIBRUSTDEPS_LIBDIR) - $(AM_V_at)rm -rf $(LIBRUSTDEPS_LIBDIR)/librustdeps.a $(LIBRUSTDEPS_LIBDIR)/objs - $(AM_V_at)$(MKDIR_P) $(LIBRUSTDEPS_LIBDIR)/objs - $(AM_V_at)for lib in $(LIBRUSTDEPS_A); do \ - cd $(LIBRUSTDEPS_LIBDIR)/objs && $(AR) -x $$lib; \ - done - $(AM_V_at)$(AR) crs $(LIBRUSTDEPS_LIBDIR)/librustdeps.a $(LIBRUSTDEPS_LIBDIR)/objs/*.o - $(AM_V_at)rm -rf $(LIBRUSTDEPS_LIBDIR)/objs - $(AM_V_at)$(RANLIB) $(LIBRUSTDEPS_LIBDIR)/librustdeps.a - $(AM_V_GEN)( \ - echo '# librustdeps.la - a libtool library file'; \ - echo '# Generated by Makefile.libs.include for libtool'; \ - echo "dlname=''"; \ - echo "library_names=''"; \ - echo "old_library='librustdeps.a'"; \ - echo "libdir='$(LIBRUSTDEPS_LIBDIR)'"; \ - echo "inherited_linker_flags=''"; \ - echo "installed=no"; \ - echo "shouldnotlink=no"; \ - ) > $@ - -clean-librustdeps-la: - rm -rf $(abs_top_builddir)/rust/.libs $(abs_top_builddir)/rust/librustdeps.la - -.PHONY: clean-librustdeps-la +# Umbrella staticlib # +LIBRUSTDEPS_TARGET_DIR = $(abs_top_builddir)/rust/target +LIBRUSTDEPS_CRATE_DIR = $(top_srcdir)/rust/dashrust +LIBRUSTDEPS_MANIFEST = $(LIBRUSTDEPS_CRATE_DIR)/Cargo.toml +LIBRUSTDEPS = $(LIBRUSTDEPS_TARGET_DIR)/$(RUST_TARGET)/$(CARGO_PROFILE)/libdashrust.a + +LIBRUSTDEPS_CARGO_ENV = $(CARGO_ENV) CARGO_TARGET_DIR="$(LIBRUSTDEPS_TARGET_DIR)" +LIBRUSTDEPS_CARGO_BUILD_OPTS = $(CARGO_BUILD_OPTS) --manifest-path $(LIBRUSTDEPS_MANIFEST) + +# Cargo features enabling optional components, provided by configure. +if ENABLE_RUST_FEATURES +LIBRUSTDEPS_CARGO_BUILD_OPTS += --features "$(RUST_CRATE_FEATURES)" +endif + +LIBRUSTDEPS_SRCS = \ + $(LIBRUSTDEPS_CRATE_DIR)/src/lib.rs + +$(LIBRUSTDEPS_SRCS): ; + +LIBRUSTDEPS_FILES = \ + $(LIBRUSTDEPS_MANIFEST) \ + $(LIBRUSTDEPS_SRCS) + +LIBRUSTDEPS_COMPONENT_SRCS = \ + $(LIBRUST_CHIRP_FILES) + +$(LIBRUSTDEPS): $(LIBRUSTDEPS_SRCS) $(LIBRUSTDEPS_MANIFEST) $(LIBRUSTDEPS_COMPONENT_SRCS) + $(AM_V_GEN)$(LIBRUSTDEPS_CARGO_ENV) $(CARGO) build $(LIBRUSTDEPS_CARGO_BUILD_OPTS) + +cargo-build-dashrust: $(LIBRUSTDEPS) + +cargo-clean-dashrust: + $(AM_V_at)rm -rf $(LIBRUSTDEPS_TARGET_DIR) + +.PHONY: cargo-build-dashrust cargo-clean-dashrust # diff --git a/rust/chirp/Cargo.toml b/rust/chirp/Cargo.toml index fd9b62a4a9aa..a886c80bab5d 100644 --- a/rust/chirp/Cargo.toml +++ b/rust/chirp/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [lib] -crate-type = ["staticlib"] +crate-type = ["rlib"] [dependencies] cxx = "1.0.192" diff --git a/rust/dashrust/Cargo.toml b/rust/dashrust/Cargo.toml new file mode 100644 index 000000000000..3f8ccfa6c7c4 --- /dev/null +++ b/rust/dashrust/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "dashrust" +version = "0.1.0" +edition = "2021" + +# Umbrella crate: the single staticlib linked into Dash Core binaries. +# Individual Rust components are rlib dependencies re-exported here, so cargo +# performs deduplication and LTO across the whole graph and emits one archive +# with no colliding object names. Optional components are cargo features so +# the build system can enable them per configure flags. + +[lib] +crate-type = ["staticlib"] + +[dependencies] +chirp = { path = "../chirp" } diff --git a/rust/dashrust/src/lib.rs b/rust/dashrust/src/lib.rs new file mode 100644 index 000000000000..b1107c19d269 --- /dev/null +++ b/rust/dashrust/src/lib.rs @@ -0,0 +1,11 @@ +// Copyright (c) 2026 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +//! Umbrella crate bundling all Rust components linked into Dash Core. +//! +//! Each component keeps its own `#[cxx::bridge]`; the explicit `extern crate` +//! declarations root the component crates so their exported bridge symbols +//! survive into the staticlib. + +extern crate chirp; From aed498f4482b7d9e2e09b5d929e789cfcefc7bac Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 7 Aug 2026 12:01:16 -0500 Subject: [PATCH 22/60] build: bump pinned Rust toolchain from 1.85.1 to 1.92.0 The dashpay/platform v4.1.0 workspace declares rust-version 1.92; rustc 1.85.1 refuses nine of its crates by name. Hashes regenerated with contrib/devtools/update-rust-hashes.py. cxx/cxxbridge stay at 1.0.192, which compiles unchanged under 1.92. --- depends/packages/native_rust.mk | 12 ++++++------ depends/packages/rust_stdlib.mk | 20 ++++++++++---------- rust-toolchain.toml | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 961517b96ff1..f7528d65f5b1 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -7,28 +7,28 @@ # ./contrib/devtools/update-rust-hashes.py package:=native_rust -$(package)_version:=1.85.1 +$(package)_version:=1.92.0 $(package)_download_path:=https://static.rust-lang.org/dist # FreeBSD (x86_64) $(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz -$(package)_sha256_hash_x86_64_freebsd:=f905730e22a9a8a2dfce1ab0c50d427b7978c5b235c33018b09552041b6f6329 +$(package)_sha256_hash_x86_64_freebsd:=f32b7d8d5ad5c186fa496dd0b7202899f89e93870940e41c37e576f324494189 # Linux (ARMv8) $(package)_file_name_aarch64_linux:=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_aarch64_linux:=d2609d8cd965060f0b4a8c509131066369e8d3d31a92fedce177b42b32af6b4d +$(package)_sha256_hash_aarch64_linux:=c812028423c3d7dd7ba99f66101e9e1aa3f66eab44a1285f41c363825d49dca4 # Linux (x86_64) $(package)_file_name_x86_64_linux:=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_x86_64_linux:=b7202563a52b47f575b284a5a4794fafd688e39bfe8fd855b5e80129e671cb7f +$(package)_sha256_hash_x86_64_linux:=6e5efd6c25953b2732d4e6b1842512536650c68cf72a8b99a0fc566012dd6ca5 # macOS (ARMv8) $(package)_file_name_aarch64_darwin:=rust-$($(package)_version)-aarch64-apple-darwin.tar.gz -$(package)_sha256_hash_aarch64_darwin:=64b0341a47e684d648c9b7defd0b7ff9d5397a64718cf803c1e114544f94bbe9 +$(package)_sha256_hash_aarch64_darwin:=235a6cca2dd4881130a9ae61ad1149bbf28bba184dd4621700f0c98c97457716 # macOS (x86_64) $(package)_file_name_x86_64_darwin:=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_x86_64_darwin:=6e321957b7301d48e5ecf61bdeea6560400a5948b3e72830348367a8a9696ad7 +$(package)_sha256_hash_x86_64_darwin:=fc6868991e61e9262272effbb8956b23428430f5f4300c1b48eaae3969f8af2a $(package)_file_name=$($(package)_file_name_$(build_arch)_$(build_os)) $(package)_sha256_hash=$($(package)_sha256_hash_$(build_arch)_$(build_os)) diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index 16e47c439434..0a148fdeb476 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -7,7 +7,7 @@ # ./contrib/devtools/update-rust-hashes.py package:=rust_stdlib -$(package)_version:=1.85.1 +$(package)_version:=1.92.0 $(package)_download_path:=https://static.rust-lang.org/dist $(package)_dependencies:=native_rust $(package)_target=$(or \ @@ -19,50 +19,50 @@ $(package)_target=$(or \ # FreeBSD (x86_64) $(package)_targets += x86_64-unknown-freebsd $(package)_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd -$(package)_sha256_hash_x86_64-unknown-freebsd:=08a691bcdb5bde37178368e9e49dbd822d9e39c68b9371191bd16ab7f8b321c4 +$(package)_sha256_hash_x86_64-unknown-freebsd:=3616afb808cd030e65e66c51f6f0fb6a6fc52d877d0d70bb681b0c35238adbe8 # Linux (ARMv7) $(package)_targets += armv7-unknown-linux-musleabihf $(package)_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf $(package)_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf -$(package)_sha256_hash_armv7-unknown-linux-musleabihf:=fbdb48968dd7af3a862c29e4e3ff85bcf333d97d21d262f347106542cc08b96d +$(package)_sha256_hash_armv7-unknown-linux-musleabihf:=fc5c4ca757599caab8e93000becb9d57587088d32dab5c4f3b253f00ec3a2fd6 # Linux (ARMv8) $(package)_targets += aarch64-unknown-linux-musl $(package)_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-musl -$(package)_sha256_hash_aarch64-unknown-linux-musl:=991cc2f78d3db8fa1131ee2bb5807497e93e1efb9f447e2a7def0c4032ba4c54 +$(package)_sha256_hash_aarch64-unknown-linux-musl:=715fbcfd8712c723947a020d0371c8a1a21f7531f2b696aeaed50ac23ba675c9 # Linux (PowerPC 64-bit little-endian) $(package)_targets += powerpc64le-unknown-linux-musl $(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-musl -$(package)_sha256_hash_powerpc64le-unknown-linux-musl:=f6fad3f1c69acdd832ea2f487863f6428ba6e77b16c18e8db7fcd91b88e9e254 +$(package)_sha256_hash_powerpc64le-unknown-linux-musl:=696958d87842d877640140ddbbaa74d044374874dee9516e227a395b70bfb8d4 # Linux (RISCV64GC) $(package)_targets += riscv64gc-unknown-linux-musl $(package)_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-musl $(package)_target_riscv64gc-unknown-linux-gnu:=riscv64gc-unknown-linux-musl -$(package)_sha256_hash_riscv64gc-unknown-linux-musl:=4a85e0c909d6a3202919638c3b95a496acdfec7e1245be1c406b7c1d26c32fba +$(package)_sha256_hash_riscv64gc-unknown-linux-musl:=34f5722ff2a0940bcd7ff6603a7748d2b963de72f6f713579c39c74ead06a7a0 # Linux (x86_64) $(package)_targets += x86_64-unknown-linux-musl $(package)_target_x86_64-unknown-linux-gnu:=x86_64-unknown-linux-musl -$(package)_sha256_hash_x86_64-unknown-linux-musl:=3035f0c3ea9ae10ba1c21871c7a53cdb54a398616febffd42825965627a77216 +$(package)_sha256_hash_x86_64-unknown-linux-musl:=8bfd9a42c8295949d556587201acdb35d2bfb8b7ce55223845f337aa5614f9a3 # macOS (ARMv8) $(package)_targets += aarch64-apple-darwin $(package)_target_aarch64-apple-darwin:=aarch64-apple-darwin $(package)_target_arm64-apple-darwin:=aarch64-apple-darwin -$(package)_sha256_hash_aarch64-apple-darwin:=5d2fd6b5c3c482750074b6ab04443b1ec41ca824fddc814aab6a1fbcf5cfb53a +$(package)_sha256_hash_aarch64-apple-darwin:=b1f55aac4bc982ea67b68b262b711263005e470d31cab5d09d534bc1866d455a # macOS (x86_64) $(package)_targets += x86_64-apple-darwin $(package)_target_x86_64-apple-darwin:=x86_64-apple-darwin -$(package)_sha256_hash_x86_64-apple-darwin:=b5111b105cfeb2772d92ca54e6f1c01d11def9c675c633f7d1ebdd09b83b0139 +$(package)_sha256_hash_x86_64-apple-darwin:=1e5a8fee4e038ea2d35d82a680e2b9bf44ffccb3746aaf9dbdc56cb14152dcb8 # Windows (x86_64) $(package)_targets += x86_64-pc-windows-gnu $(package)_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu -$(package)_sha256_hash_x86_64-pc-windows-gnu:=ae5c8942b3ccab5841c9ea65d1ac839c62553a763512799eb4c89de2ffad3d3e +$(package)_sha256_hash_x86_64-pc-windows-gnu:=6256f3497e3b14b6650511e84fdfb51fc632db1908ae5a173dffcdc96c80b7ce $(package)_file_name=rust-std-$($(package)_version)-$($(package)_target).tar.gz $(package)_sha256_hash=$($(package)_sha256_hash_$($(package)_target)) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 00822fdf5828..f19782d3c556 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.85.1" +channel = "1.92.0" From 8258d25f770f6c1486c62b30e539f5fc81c49d4a Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 7 Aug 2026 12:02:12 -0500 Subject: [PATCH 23/60] build: write cargo config and sentinels to builddir, not srcdir The offline cargo configuration was generated into the source tree, which pollutes srcdir and races when multiple out-of-tree builds for different hosts share one checkout. Cargo discovers .cargo/config.toml by walking up from its invocation directory, so a config under the build tree's root works for both in-tree and out-of-tree builds. --- rust/Makefile.am | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/rust/Makefile.am b/rust/Makefile.am index 2d587a26941f..120d7d9b68df 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -42,22 +42,23 @@ CARGO_BUILD_OPTS += --verbose endif # !SILENT_RULES if ENABLE_ONLINE_RUST -CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-online +CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-online $(CARGO_CONFIGURED): - $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline - $(AM_V_at)rm -f $(top_srcdir)/.cargo/config.toml - $(AM_V_at)rm -f $(top_srcdir)/.cargo/config + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config $(AM_V_at)touch $@ else CARGO_BUILD_OPTS += --offline -CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-offline +CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-offline $(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.toml.offline - $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online - $(AM_V_at)rm -f $(top_srcdir)/.cargo/config - $(AM_V_at)cp $< $(top_srcdir)/.cargo/config.toml - $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(top_srcdir)/.cargo/config.toml + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)cp $< $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)touch $@ endif # ENABLE_ONLINE_RUST @@ -79,10 +80,10 @@ cargo-clean: cargo-clean-dashrust dist-hook: dist-chirp cargo-clean-config: - $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online - $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline - $(AM_V_at)rm -f $(top_srcdir)/.cargo/config.toml - $(AM_V_at)rm -f $(top_srcdir)/.cargo/config + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config clean-local: cargo-clean-dashrust cxxbridge-clean-chirp cargo-clean-config From e94961ce86ebd16100de22f9e412aaaa9fb1e43b Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 7 Aug 2026 12:03:00 -0500 Subject: [PATCH 24/60] build: support git-sourced crates in offline vendored builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cargo vendor handles git dependencies, but consuming the vendor directory offline requires per-git-source replacement stanzas in .cargo/config.toml, which the build system previously did not generate (only crates.io was redirected). Derive the stanzas deterministically from Cargo.lock with contrib/devtools/cargo-vendor-git-sources.sh — output verified byte-identical to what cargo vendor itself prints — and append them when generating the offline config. Git dependencies are unavoidable for upcoming components: crates.io copies of the dashpay/platform crates are stale or name-squatted. --- contrib/devtools/cargo-vendor-git-sources.sh | 37 ++++++++++++++++++++ rust/Makefile.am | 3 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 contrib/devtools/cargo-vendor-git-sources.sh diff --git a/contrib/devtools/cargo-vendor-git-sources.sh b/contrib/devtools/cargo-vendor-git-sources.sh new file mode 100755 index 000000000000..3ad580b95a5d --- /dev/null +++ b/contrib/devtools/cargo-vendor-git-sources.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Emit cargo source-replacement stanzas for every git source in a Cargo.lock, +# for appending to an offline .cargo/config.toml whose vendored-sources +# directory holds the output of `cargo vendor`. `cargo vendor` prints these +# stanzas itself, but only at vendor time; deriving them from the lockfile +# lets the build system reconstruct the config without re-running vendor. +# +# usage: cargo-vendor-git-sources.sh path/to/Cargo.lock + +set -eu + +if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then + echo "usage: $0 path/to/Cargo.lock" >&2 + exit 1 +fi + +# Lockfile entries look like: +# source = "git+https://github.com/dashpay/platform?tag=v4.1.0#bfc80249..." +# The stanza key is the source without the fragment; the query parameter +# (tag=/branch=/rev=), when present, becomes a key of the same name. +grep '^source = "git+' "$1" | sed 's/^source = "//; s/"$//; s/#.*//' | sort -u | \ +while IFS= read -r src; do + url_query="${src#git+}" + url="${url_query%%\?*}" + printf '\n[source."%s"]\ngit = "%s"\n' "$src" "$url" + case "$url_query" in + *\?*) + query="${url_query#*\?}" + printf '%s = "%s"\n' "${query%%=*}" "${query#*=}" + ;; + esac + printf 'replace-with = "vendored-sources"\n' +done diff --git a/rust/Makefile.am b/rust/Makefile.am index 120d7d9b68df..3c8eb9cd4530 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -53,12 +53,13 @@ else CARGO_BUILD_OPTS += --offline CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-offline -$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.toml.offline +$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.toml.offline $(top_srcdir)/Cargo.lock $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo $(AM_V_at)cp $< $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)$(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh $(top_srcdir)/Cargo.lock >> $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)touch $@ endif # ENABLE_ONLINE_RUST From 6e286842c3d521b1db297d46f83f6fb7fa4f1045 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 11:07:04 -0500 Subject: [PATCH 25/60] build: make Rust integration optional and CI-covered --- .cargo/config.toml.offline | 2 +- .github/workflows/build.yml | 25 +++ .gitignore | 14 +- Makefile.am | 7 +- ci/dash/matrix.sh | 2 + ci/test/00_setup_env_native_rust.sh | 14 ++ configure.ac | 183 +++++++++------- contrib/containers/ci/ci.Dockerfile | 1 - contrib/devtools/cargo-vendor-git-sources.sh | 2 + contrib/devtools/update-native-cxxbridge.py | 2 +- contrib/devtools/update-rust-hashes.py | 5 + contrib/guix/guix-build | 5 +- contrib/guix/libexec/build.sh | 11 - contrib/guix/manifest.scm | 2 - contrib/guix/symbol-check.py | 2 - depends/Makefile | 16 +- depends/config.site.in | 4 + depends/funcs.mk | 3 +- depends/packages/native_cxxbridge.mk | 8 +- depends/packages/packages.mk | 5 +- depends/packages/rust_stdlib.mk | 17 +- depends/patches/native_cxxbridge/Cargo.lock | 202 ++++++++---------- .../native_rust/fix-elf-interpreter.sh | 9 +- rust/Makefile.am | 32 ++- src/Makefile.am | 43 ++-- src/Makefile.bench.include | 5 +- src/Makefile.qt.include | 4 +- src/Makefile.qttest.include | 4 +- src/Makefile.test.include | 9 +- src/init.cpp | 6 +- test/lint/lint-files.py | 2 +- test/lint/lint-format-strings.py | 2 +- test/lint/lint-include-guards.py | 3 +- test/lint/lint-includes.py | 3 +- test/lint/lint-locale-dependence.py | 1 - test/lint/lint-python-utf8-encoding.py | 3 +- test/lint/lint-python.py | 3 +- test/lint/lint-shell-locale.py | 2 +- test/lint/lint-shell.py | 2 +- test/lint/lint-spelling.py | 2 +- test/lint/lint-whitespace.py | 1 - 41 files changed, 380 insertions(+), 288 deletions(-) create mode 100755 ci/test/00_setup_env_native_rust.sh diff --git a/.cargo/config.toml.offline b/.cargo/config.toml.offline index 82e141e0bcc4..f98e1b632fa7 100644 --- a/.cargo/config.toml.offline +++ b/.cargo/config.toml.offline @@ -12,7 +12,7 @@ linker = "powerpc64le-linux-gnu-gcc" linker = "riscv64-linux-gnu-gcc" [target.x86_64-unknown-linux-musl] -linker = "x86-64-linux-gnu-gcc" +linker = "x86_64-linux-gnu-gcc" # Windows [target.x86_64-pc-windows-gnu] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce8191dc99ea..13fdf87119de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -141,6 +141,17 @@ jobs: base-image-digest: ${{ needs.check-skip.outputs.base-image-digest }} runs-on: ${{ needs.check-skip.outputs['runner-amd64'] }} + depends-linux64_rust: + name: x86_64-pc-linux-gnu_rust + uses: ./.github/workflows/build-depends.yml + needs: [check-skip, container, cache-sources] + if: ${{ vars.SKIP_LINUX64_RUST == '' }} + with: + build-target: linux64_rust + container-path: ${{ needs.container.outputs.path }} + base-image-digest: ${{ needs.check-skip.outputs.base-image-digest }} + runs-on: ${{ needs.check-skip.outputs['runner-amd64'] }} + depends-linux64_multiprocess: name: linux64_multiprocess uses: ./.github/workflows/build-depends.yml @@ -222,6 +233,20 @@ jobs: depends-artifact: ${{ needs.depends-linux64.outputs.built-artifact }} runs-on: ${{ needs.check-skip.outputs['runner-amd64'] }} + src-linux64_rust: + name: linux64_rust-build + uses: ./.github/workflows/build-src.yml + needs: [check-skip, container, depends-linux64_rust] + if: ${{ vars.SKIP_LINUX64_RUST == '' }} + with: + build-target: linux64_rust + container-path: ${{ needs.container.outputs.path }} + depends-key: ${{ needs.depends-linux64_rust.outputs.key }} + depends-host: ${{ needs.depends-linux64_rust.outputs.host }} + depends-dep-opts: ${{ needs.depends-linux64_rust.outputs.dep-opts }} + depends-artifact: ${{ needs.depends-linux64_rust.outputs.built-artifact }} + runs-on: ${{ needs.check-skip.outputs['runner-amd64'] }} + src-linux64_asan: name: linux64_asan-build uses: ./.github/workflows/build-src.yml diff --git a/.gitignore b/.gitignore index e67bfd539a6f..722e46abedfd 100644 --- a/.gitignore +++ b/.gitignore @@ -183,14 +183,14 @@ perf.data perf.data.old # Generated by Cargo -# will have compiled files and executables -debug -target +/target/ +/rust/target/ # Cargo configuration -.cargo/.configured-for-* -.cargo/config -.cargo/config.toml +/.cargo/.configured-for-* +/.cargo/config +/.cargo/config.toml +/.cargo/*-linker # These are backup files generated by rustfmt **/*.rs.bk @@ -203,4 +203,4 @@ target **/mutants.out*/ # FFI bridge -gen +/rust/*/gen/ diff --git a/Makefile.am b/Makefile.am index 9e7ff1064f30..1aaa33a66689 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,10 +8,15 @@ print-%: FORCE @echo '$*'='$($*)' ACLOCAL_AMFLAGS = -I build-aux/m4 -SUBDIRS = rust src +SUBDIRS = +if ENABLE_RUST +SUBDIRS += rust +endif +SUBDIRS += src if ENABLE_MAN SUBDIRS += doc/man endif +DIST_SUBDIRS = rust src doc/man .PHONY: deploy FORCE .INTERMEDIATE: $(COVERAGE_INFO) diff --git a/ci/dash/matrix.sh b/ci/dash/matrix.sh index 49117d71c82f..f75bbb1da650 100755 --- a/ci/dash/matrix.sh +++ b/ci/dash/matrix.sh @@ -20,6 +20,8 @@ if [ "$BUILD_TARGET" = "aarch64-linux" ]; then source ./ci/test/00_setup_env_aarch64.sh elif [ "$BUILD_TARGET" = "linux64" ]; then source ./ci/test/00_setup_env_native_qt5.sh +elif [ "$BUILD_TARGET" = "linux64_rust" ]; then + source ./ci/test/00_setup_env_native_rust.sh elif [ "$BUILD_TARGET" = "linux64_asan" ]; then source ./ci/test/00_setup_env_native_asan.sh elif [ "$BUILD_TARGET" = "linux64_fuzz" ]; then diff --git a/ci/test/00_setup_env_native_rust.sh b/ci/test/00_setup_env_native_rust.sh new file mode 100755 index 000000000000..fe12acd24db9 --- /dev/null +++ b/ci/test/00_setup_env_native_rust.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +export LC_ALL=C.UTF-8 + +export CONTAINER_NAME=ci_native_rust +export HOST=x86_64-pc-linux-gnu +export DEP_OPTS="RUST=1 NO_QT=1 NO_QR=1" +export RUN_FUNCTIONAL_TESTS="false" +export GOAL="install" +export BITCOIN_CONFIG="--enable-rust --with-gui=no --enable-reduce-exports" diff --git a/configure.ac b/configure.ac index 87953940888f..0515f273cc49 100644 --- a/configure.ac +++ b/configure.ac @@ -128,20 +128,11 @@ AC_PATH_TOOL([DSYMUTIL], [dsymutil]) AC_PATH_PROG([DOXYGEN], [doxygen]) AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) -dnl Check/return PATH for Rust dependencies -AC_DEFUN( - RS_REQUIRE_PROG, - [ - AC_PATH_PROG($1, $2, $2_notfound) - if test x${$1} = x$2_notfound - then - AC_MSG_ERROR("Required program $2 was not found") - fi - ] -) -RS_REQUIRE_PROG([CARGO], cargo) -RS_REQUIRE_PROG([CXXBRIDGE], cxxbridge) -RS_REQUIRE_PROG([RUSTC], rustc) +dnl Rust toolchain detection. These programs are required only when a +dnl Rust-dependent component is explicitly enabled. +AC_PATH_PROG([CARGO], [cargo]) +AC_PATH_PROG([CXXBRIDGE], [cxxbridge]) +AC_PATH_PROG([RUSTC], [rustc]) AC_ARG_VAR([CARGO_INCREMENTAL], [Enable incremental compilation for Rust]) if test "${CARGO_INCREMENTAL+set}" != "set"; then @@ -153,6 +144,12 @@ if test "${RUSTFLAGS+set}" != "set"; then RUSTFLAGS="-C embed-bitcode=yes -C relocation-model=pic" fi +AC_ARG_ENABLE([rust], + [AS_HELP_STRING([--enable-rust], + [build the Rust/C++ bridge smoke component (default is no)])], + [enable_rust=$enableval], + [enable_rust=no]) + AC_ARG_ENABLE([online-rust], [AS_HELP_STRING([--enable-online-rust], [allow Cargo to fetch Rust dependencies from the internet (default is no, using vendored dependencies offline)])], @@ -1736,27 +1733,16 @@ if test "$use_zmq" = "yes"; then esac fi -RUST_LIBS="" -case $host in - *mingw*) - RUST_LIBS="$RUST_LIBS -luserenv -lntdll" - ;; - *) - RUST_LIBS="$RUST_LIBS -ldl" - ;; -esac - -RUST_MACOS_DEPLOYMENT_TARGET="" -case $host in - *darwin*) - AC_MSG_CHECKING([for target macOS version]) - RUST_MACOS_DEPLOYMENT_TARGET="${OSX_MIN_VERSION:-$(sw_vers -productVersion)}" - AC_MSG_RESULT([$RUST_MACOS_DEPLOYMENT_TARGET]) - ;; -esac - AC_DEFUN([RS_SET_TRIPLE], [ case $2 in + aarch64-*-linux-android*) + $1="aarch64-linux-android" ;; + arm*-*-linux-android*) + $1="armv7-linux-androideabi" ;; + i?86-*-linux-android*) + $1="i686-linux-android" ;; + x86_64-*-linux-android*) + $1="x86_64-linux-android" ;; x86_64-*-freebsd*) $1="x86_64-unknown-freebsd" ;; aarch64-*-linux*|arm64-*-linux*) $1="aarch64-unknown-linux-$3" ;; @@ -1773,68 +1759,98 @@ AC_DEFUN([RS_SET_TRIPLE], [ esac ]) -AC_MSG_CHECKING([for Rust target]) -RS_SET_TRIPLE([RUST_TARGET], [$host], [musl]) -if test "$RUST_TARGET" = ""; then - AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Unsupported target for Rust: $host]) -fi -AC_MSG_RESULT([$RUST_TARGET]) - +RUST_LIBS="" +RUST_MACOS_DEPLOYMENT_TARGET="" RUST_OSX_SDK="" -case $host in - *darwin*) - AC_MSG_CHECKING([for Xcode SDK]) - if test -z "$OSX_SDK"; then - if test "$cross_compiling" = "yes"; then - AC_MSG_ERROR([Cross-compilation requires OSX_SDK to be set to path of Xcode SDK, cannot continue!]) +RUST_TARGET="" +RUST_NATIVE="" + +if test "$enable_rust" = "yes"; then + if test -z "$CARGO" || test -z "$RUSTC" || test -z "$CXXBRIDGE"; then + AC_MSG_ERROR([cargo, rustc and cxxbridge are required by --enable-rust]) + fi + AC_DEFINE([ENABLE_RUST], [1], [Define this symbol to enable Rust components]) + + case $host in + *mingw*) + RUST_LIBS="$RUST_LIBS -luserenv -lntdll" + ;; + *linux*) + RUST_LIBS="$RUST_LIBS -ldl" + ;; + esac + + case $host in + *darwin*) + AC_MSG_CHECKING([for target macOS version]) + if test -z "$OSX_MIN_VERSION" && test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires OSX_MIN_VERSION to be set, cannot continue!]) fi - fi - RUST_OSX_SDK="${OSX_SDK:-$(xcrun --sdk macosx --show-sdk-path)}" - AC_MSG_RESULT([$RUST_OSX_SDK]) - ;; -esac + RUST_MACOS_DEPLOYMENT_TARGET="${OSX_MIN_VERSION:-$(sw_vers -productVersion)}" + AC_MSG_RESULT([$RUST_MACOS_DEPLOYMENT_TARGET]) + ;; + esac -AC_MSG_CHECKING([for Rust host]) -RS_SET_TRIPLE([RUST_NATIVE], [$build], [gnu]) -if test "$RUST_NATIVE" = ""; then - if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING([for Rust target]) + RS_SET_TRIPLE([RUST_TARGET], [$host], [musl]) + if test "$RUST_TARGET" = ""; then AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Unsupported host for Rust: $build]) + AC_MSG_ERROR([Unsupported target for Rust: $host]) fi - RUST_NATIVE="$RUST_TARGET" -fi -AC_MSG_RESULT([$RUST_NATIVE]) + AC_MSG_RESULT([$RUST_TARGET]) -AC_MSG_CHECKING([for host archiver]) -if test -z "$NATIVE_AR"; then - if test "$cross_compiling" = "yes"; then - AC_MSG_ERROR([Cross-compilation requires NATIVE_AR to be set to host archiver, cannot continue!]) + case $host in + *darwin*) + AC_MSG_CHECKING([for Xcode SDK]) + if test -z "$OSX_SDK" && test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires OSX_SDK to be set to path of Xcode SDK, cannot continue!]) + fi + RUST_OSX_SDK="${OSX_SDK:-$(xcrun --sdk macosx --show-sdk-path)}" + AC_MSG_RESULT([$RUST_OSX_SDK]) + ;; + esac + + AC_MSG_CHECKING([for Rust host]) + RS_SET_TRIPLE([RUST_NATIVE], [$build], [gnu]) + if test "$RUST_NATIVE" = ""; then + if test "$cross_compiling" = "yes"; then + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Unsupported host for Rust: $build]) + fi + RUST_NATIVE="$RUST_TARGET" fi - NATIVE_AR="$AR" -fi -AC_MSG_RESULT([$NATIVE_AR]) + AC_MSG_RESULT([$RUST_NATIVE]) + + AC_MSG_CHECKING([for host archiver]) + if test -z "$NATIVE_AR"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires NATIVE_AR to be set to host archiver, cannot continue!]) + fi + NATIVE_AR="$AR" + fi + AC_MSG_RESULT([$NATIVE_AR]) -AC_MSG_CHECKING([for host C compiler]) -if test -z "$NATIVE_CC"; then - if test "$cross_compiling" = "yes"; then - AC_MSG_ERROR([Cross-compilation requires NATIVE_CC to be set to host C compiler, cannot continue!]) + AC_MSG_CHECKING([for host C compiler]) + if test -z "$NATIVE_CC"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires NATIVE_CC to be set to host C compiler, cannot continue!]) + fi + NATIVE_CC="$CC" fi - NATIVE_CC="$CC" -fi -AC_MSG_RESULT([$NATIVE_CC]) + AC_MSG_RESULT([$NATIVE_CC]) -AC_MSG_CHECKING([for host C++ compiler]) -if test -z "$NATIVE_CXX"; then - if test "$cross_compiling" = "yes"; then - AC_MSG_ERROR([Cross-compilation requires NATIVE_CXX to be set to host C++ compiler, cannot continue!]) + AC_MSG_CHECKING([for host C++ compiler]) + if test -z "$NATIVE_CXX"; then + if test "$cross_compiling" = "yes"; then + AC_MSG_ERROR([Cross-compilation requires NATIVE_CXX to be set to host C++ compiler, cannot continue!]) + fi + NATIVE_CXX="$CXX" fi - NATIVE_CXX="$CXX" -fi -AC_MSG_RESULT([$NATIVE_CXX]) + AC_MSG_RESULT([$NATIVE_CXX]) -if test -n "$depends_prefix"; then - RUSTUP_TOOLCHAIN="" + if test -n "$depends_prefix"; then + RUSTUP_TOOLCHAIN="" + fi fi AC_SUBST(RUSTUP_TOOLCHAIN) @@ -2097,6 +2113,7 @@ AM_CONDITIONAL([USE_QRCODE], [test "$use_qr" = "yes"]) AM_CONDITIONAL([USE_LCOV], [test "$use_lcov" = "yes"]) AM_CONDITIONAL([USE_LIBEVENT], [test "$use_libevent" = "yes"]) AM_CONDITIONAL([HARDEN], [test "$use_hardening" = "yes"]) +AM_CONDITIONAL([ENABLE_RUST], [test "$enable_rust" = "yes"]) AM_CONDITIONAL([ENABLE_RUST_FEATURES], [test -n "$RUST_CRATE_FEATURES"]) AM_CONDITIONAL([ENABLE_SSSE3], [test "$enable_ssse3" = "yes"]) AM_CONDITIONAL([ENABLE_SSE42], [test "$enable_sse42" = "yes"]) diff --git a/contrib/containers/ci/ci.Dockerfile b/contrib/containers/ci/ci.Dockerfile index 49e6dc608940..42df9b08018c 100644 --- a/contrib/containers/ci/ci.Dockerfile +++ b/contrib/containers/ci/ci.Dockerfile @@ -58,7 +58,6 @@ RUN set -ex; \ # LD_LIBRARY_PATH is empty by default, this is the first entry ENV LD_LIBRARY_PATH="/usr/lib/llvm-${LLVM_VERSION}/lib" -# Install IWYU RUN set -ex; \ git clone --depth=1 "https://github.com/include-what-you-use/include-what-you-use" -b "clang_${LLVM_VERSION}" /opt/iwyu; \ cd /opt/iwyu; \ diff --git a/contrib/devtools/cargo-vendor-git-sources.sh b/contrib/devtools/cargo-vendor-git-sources.sh index 3ad580b95a5d..7028a402bca4 100755 --- a/contrib/devtools/cargo-vendor-git-sources.sh +++ b/contrib/devtools/cargo-vendor-git-sources.sh @@ -1,4 +1,6 @@ #!/bin/sh +export LC_ALL=C + # Copyright (c) 2026 The Dash Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/contrib/devtools/update-native-cxxbridge.py b/contrib/devtools/update-native-cxxbridge.py index 2628912612e0..49fd9556e320 100755 --- a/contrib/devtools/update-native-cxxbridge.py +++ b/contrib/devtools/update-native-cxxbridge.py @@ -54,7 +54,7 @@ def main() -> int: # Extract tarball print(f"Extracting {tarball_path}") with tarfile.open(tarball_path, "r:gz") as tar: - tar.extractall(tmp_path) + tar.extractall(tmp_path, filter="data") cxx_dir = tmp_path / f"cxx-{version}" if not cxx_dir.exists(): diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 04fef67f9513..8cce3cbf068e 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -13,6 +13,11 @@ # Corresponds to 'hosts/*.mk' CROSS_TARGETS = [ + # Android + "aarch64-linux-android", + "armv7-linux-androideabi", + "i686-linux-android", + "x86_64-linux-android", # FreeBSD "x86_64-unknown-freebsd", # Linux diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 65ffbdfa2ed6..80b719eb29d8 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -301,12 +301,9 @@ mkdir -p "$OUTDIR_BASE" # Download the depends sources now as we won't have internet access in the build # container -depends_cmds="download-rust-std vendor-crates" for host in $HOSTS; do - depends_cmds+=" download-$(host_to_commonname "$host")" + make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} done -# shellcheck disable=SC2086 -make -C "${PWD}/depends" -j"$JOBS" ${depends_cmds} ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} # Usage: outdir_for_host HOST SUFFIX # diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index e5ff272f5657..0c9fda7ad11d 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -86,9 +86,6 @@ case "$HOST" in ;; esac -# Rust build scripts need LD_LIBRARY_PATH to find libgcc_s.so.1 at runtime -export LD_LIBRARY_PATH="${LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - # Set environment variables to point the CROSS toolchain to the right # includes/libs for $HOST case "$HOST" in @@ -195,9 +192,6 @@ case "$HOST" in ;; esac -# Make $HOST-specific native binaries from depends available in $PATH -export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" - ########################### # Source Tarball Building # ########################### @@ -255,11 +249,6 @@ case "$HOST" in *linux*) HOST_LDFLAGS+=" -static-libstdc++ -static-libgcc" ;; esac -case "$HOST" in - *darwin*) export NATIVE_AR="llvm-ar" NATIVE_CC="clang" NATIVE_CXX="clang++" ;; - *) export NATIVE_AR="ar" NATIVE_CC="gcc" NATIVE_CXX="g++" ;; -esac - mkdir -p "$DISTSRC" ( cd "$DISTSRC" diff --git a/contrib/guix/manifest.scm b/contrib/guix/manifest.scm index cc39854319b1..2f21f5b58801 100644 --- a/contrib/guix/manifest.scm +++ b/contrib/guix/manifest.scm @@ -8,7 +8,6 @@ (gnu packages commencement) (gnu packages compression) (gnu packages cross-base) - ((gnu packages elf) #:select (patchelf)) (gnu packages file) (gnu packages gawk) (gnu packages gcc) @@ -534,7 +533,6 @@ inspecting signatures in Mach-O binaries.") libtool autoconf-2.71 automake - patchelf pkg-config ;; Scripting python-minimal ;; (3.10) diff --git a/contrib/guix/symbol-check.py b/contrib/guix/symbol-check.py index b41cf4aaea69..bca9029b24d8 100755 --- a/contrib/guix/symbol-check.py +++ b/contrib/guix/symbol-check.py @@ -150,12 +150,10 @@ PE_ALLOWED_LIBRARIES = { 'ADVAPI32.dll', # legacy security & registry -'api-ms-win-core-synch-l1-2-0.dll', # sync primitives (API set) 'bcrypt.dll', # newer security and identity API 'IPHLPAPI.DLL', # IP helper API 'KERNEL32.dll', # win32 base APIs 'msvcrt.dll', # C standard library for MSVC -'ntdll.dll', # NT kernel API 'SHELL32.dll', # shell API 'WS2_32.dll', # sockets 'dbghelp.dll', # debugging routines diff --git a/depends/Makefile b/depends/Makefile index ce65dece076e..2eb9a87b929e 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -44,6 +44,7 @@ NO_UPNP ?= NO_USDT ?= NO_NATPMP ?= MULTIPROCESS ?= +RUST ?= LTO ?= NO_HARDEN ?= FALLBACK_DOWNLOAD_PATH ?= http://dash-depends-sources.s3-website-us-west-2.amazonaws.com @@ -182,7 +183,13 @@ usdt_packages_$(NO_USDT) = $(usdt_$(host_os)_packages) packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(boost_packages_) $(libevent_packages_) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) $(natpmp_packages_) $(usdt_packages_) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) -native_packages += native_rust $(native_cargo_packages) +ifeq ($(RUST),1) +packages += $(rust_packages) +native_packages += $(rust_native_packages) +rust_download_target = download-rust-std +endif + +native_cargo_packages = $(filter native_cxxbridge,$(native_packages)) ifneq ($(zmq_packages_),) packages += $(zmq_packages) @@ -294,6 +301,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@no_usdt@|$(NO_USDT)|' \ -e 's|@no_natpmp@|$(NO_NATPMP)|' \ -e 's|@multiprocess@|$(MULTIPROCESS)|' \ + -e 's|@rust@|$(RUST)|' \ -e 's|@lto@|$(LTO)|' \ -e 's|@no_harden@|$(NO_HARDEN)|' \ -e 's|@debug@|$(DEBUG)|' \ @@ -330,7 +338,11 @@ clean-all: clean clean: @rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) *.log +ifeq ($(RUST),1) install: check-packages $(host_prefix)/share/config.site $(host_prefix)/$(CRATE_REGISTRY) +else +install: check-packages $(host_prefix)/share/config.site +endif download-one: check-sources $(all_sources) @@ -345,7 +357,7 @@ download-rust-std: @mkdir -p $(SOURCES_PATH) @mkdir -p $(SOURCES_PATH)/download-stamps @$(foreach target,$(rust_stdlib_targets),$(call download_rust_std_target,$(target)) && ) true -download: download-osx download-linux download-win download-rust-std +download: download-osx download-linux download-win $(rust_download_target) $(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package)))) diff --git a/depends/config.site.in b/depends/config.site.in index a1ccdbcbd7bf..b92dd22bb3ba 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -50,6 +50,10 @@ if test -z "$enable_multiprocess" && test -n "@multiprocess@"; then enable_multiprocess=yes fi +if test -z "$enable_rust" && test -n "@rust@"; then + enable_rust=yes +fi + if test -z "$with_miniupnpc" && test -n "@no_upnp@"; then with_miniupnpc=no fi diff --git a/depends/funcs.mk b/depends/funcs.mk index 296290f3630d..b4d8353312e6 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -308,6 +308,7 @@ define download_rust_std_target echo "Already have rust-std-$(rust_stdlib_version)-$(1).tar.gz" || \ (echo "Downloading rust-std-$(rust_stdlib_version)-$(1).tar.gz..." && \ $(build_DOWNLOAD) "$(SOURCES_PATH)/rust-std-$(rust_stdlib_version)-$(1).tar.gz" "$(rust_stdlib_download_path)/rust-std-$(rust_stdlib_version)-$(1).tar.gz")) && \ +echo "$(rust_stdlib_sha256_hash_$(1)) $(SOURCES_PATH)/rust-std-$(rust_stdlib_version)-$(1).tar.gz" | $(build_SHA256SUM) -c - && \ echo "$(rust_stdlib_sha256_hash_$(1)) rust-std-$(rust_stdlib_version)-$(1).tar.gz" > "$(SOURCES_PATH)/download-stamps/.stamp_fetched-rust_stdlib-$(rust_stdlib_version)-$(rust_stdlib_sha256_hash_$(1)).hash" endef @@ -333,7 +334,7 @@ define int_cargo_preprocess_ext $(1)_preprocess_cmds += && \ if test -f $(SOURCES_PATH)/$($(1)_vendored_file_name); then \ echo "Extracting vendored crates for $(1)..." && \ - $(build_TAR) -P -xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ + $(build_TAR) -P --no-same-owner -xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ mkdir -p .cargo && \ cp $(PATCHES_PATH)/$(1)/cargo-config.toml .cargo/config.toml; \ fi diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk index 4f18d05fd8d6..11e9a91f0cd2 100644 --- a/depends/packages/native_cxxbridge.mk +++ b/depends/packages/native_cxxbridge.mk @@ -6,16 +6,16 @@ # ./contrib/devtools/update-native-cxxbridge.py package:=native_cxxbridge -$(package)_version:=1.0.192 +$(package)_version:=1.0.198 $(package)_download_path:=https://github.com/dtolnay/cxx/archive/refs/tags $(package)_file_name:=native_cxxbridge-$($(package)_version).tar.gz $(package)_download_file:=$($(package)_version).tar.gz -$(package)_sha256_hash:=d242dbfb6deb362c5a95fcb69aeb5f25228de75af3cced94c9f6c8e11019d30e -$(package)_build_subdir:=gen/cmd +$(package)_sha256_hash:=e8c54f11e12b00f80a7da8cc2eac55db5c4688cb2bc483f5e923261fa3a285bf +$(package)_build_subdir:=bridge/cmd $(package)_dependencies:=native_rust $(package)_patches:=Cargo.lock cargo-config.toml $(package)_vendored_file_name:=native_cxxbridge-$($(package)_version)-vendored.tar.gz -$(package)_cargo_manifest:=gen/cmd/Cargo.toml +$(package)_cargo_manifest:=bridge/cmd/Cargo.toml define $(package)_preprocess_cmds cp $($(package)_patch_dir)/Cargo.lock . diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 66ffa913b07c..f52ba3cd36ae 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,8 +1,9 @@ -packages:=gmp backtrace rustcxx rust_stdlib +packages:=gmp backtrace boost_packages = boost -native_cargo_packages = native_cxxbridge +rust_packages = rustcxx rust_stdlib +rust_native_packages = native_rust native_cxxbridge libevent_packages = libevent diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index 0a148fdeb476..2bf35b8ca239 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -14,7 +14,22 @@ $(package)_target=$(or \ $($(package)_target_$(canonical_host)),\ $($(package)_target_$(subst -pc-,-unknown-,$(canonical_host))),\ $($(package)_target_$(subst -unknown-,-pc-,$(canonical_host))),\ - $($(package)_target_$(subst -linux-,-unknown-linux-,$(canonical_host)))) + $($(package)_target_$(subst -linux-,-unknown-linux-,$(canonical_host))),\ + $(if $(findstring -apple-darwin,$(canonical_host)),$(host_arch)-apple-darwin)) + +# Android +$(package)_targets += aarch64-linux-android +$(package)_targets += armv7-linux-androideabi +$(package)_targets += i686-linux-android +$(package)_targets += x86_64-linux-android +$(package)_target_aarch64-unknown-linux-android:=aarch64-linux-android +$(package)_target_armv7a-unknown-linux-android:=armv7-linux-androideabi +$(package)_target_i686-pc-linux-android:=i686-linux-android +$(package)_target_x86_64-pc-linux-android:=x86_64-linux-android +$(package)_sha256_hash_aarch64-linux-android:=f6689cf5b71056e887261ec84ae1f499eeb42c67e5ae73e7c0e06065b6648c44 +$(package)_sha256_hash_armv7-linux-androideabi:=18f6e6903c5f4361efe8c8a1ea546303e4473e8b9cd1b11fcf4e5b170468d464 +$(package)_sha256_hash_i686-linux-android:=d994d70493ad68ced22a5269e41b9fa6f83af9f3adabade154860058bc2e18c0 +$(package)_sha256_hash_x86_64-linux-android:=b9074f6961baff09334afaff745fb16dbf9f05cdf856b17309d8e6232a281c40 # FreeBSD (x86_64) $(package)_targets += x86_64-unknown-freebsd diff --git a/depends/patches/native_cxxbridge/Cargo.lock b/depends/patches/native_cxxbridge/Cargo.lock index 4a9a074e7d3c..91f145808c7f 100644 --- a/depends/patches/native_cxxbridge/Cargo.lock +++ b/depends/patches/native_cxxbridge/Cargo.lock @@ -1,24 +1,24 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anstyle" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] name = "cc" -version = "1.2.52" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +checksum = "5d262e149917187838d5b42777c8253bcb64500067342904e7d429499a6f277e" dependencies = [ "find-msvc-tools", "jobserver", @@ -34,18 +34,18 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" -version = "4.5.54" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.54" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889" dependencies = [ "anstyle", "clap_lex", @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.6" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "codespan-reporting" @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.192" +version = "1.0.198" dependencies = [ "cc", "cxx-build", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.192" +version = "1.0.198" dependencies = [ "cc", "codespan-reporting", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "cxx-gen" -version = "0.7.192" +version = "0.7.198" dependencies = [ "codespan-reporting", "indexmap", @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cxxbridge-cmd" -version = "1.0.192" +version = "1.0.198" dependencies = [ "clap", "codespan-reporting", @@ -143,11 +143,11 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.192" +version = "1.0.198" [[package]] name = "cxxbridge-macro" -version = "1.0.192" +version = "1.0.198" dependencies = [ "cxx", "indexmap", @@ -167,9 +167,9 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921" +checksum = "aeda16ab4059c5fd2a83f2b9c9e9c981327b18aa8e3b313f7e6563799d4f093e" [[package]] name = "equivalent" @@ -189,15 +189,15 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" [[package]] name = "find-msvc-tools" -version = "0.1.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" +checksum = "26b73573e6edcd2af0cdf47bd6cb58f0b3839491263c314eaad1ccf24430e1de" [[package]] name = "foldhash" @@ -207,33 +207,32 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "getrandom" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", "r-efi", - "wasip2", ] [[package]] name = "glob" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" [[package]] name = "hashbrown" -version = "0.16.1" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "indexmap" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", "hashbrown", @@ -250,15 +249,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jobserver" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" dependencies = [ "getrandom", "libc", @@ -266,9 +265,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.180" +version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "link-cplusplus" @@ -281,33 +280,33 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "pkg-config" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" [[package]] name = "prettyplease" -version = "0.2.37" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" dependencies = [ "proc-macro2", "syn", @@ -315,33 +314,33 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.43" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.3.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rustix" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ "bitflags", "errno", @@ -352,9 +351,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "scratch" @@ -364,9 +363,9 @@ checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -374,18 +373,18 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", @@ -394,9 +393,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -407,18 +406,18 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.0.4" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" dependencies = [ "serde_core", ] [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "strsim" @@ -428,9 +427,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.114" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" dependencies = [ "proc-macro2", "quote", @@ -439,15 +438,15 @@ dependencies = [ [[package]] name = "target-triple" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591ef38edfb78ca4771ee32cf494cb8771944bee237a9b91fc9c1424ac4b777b" +checksum = "c3a6bfce3d99adfa72d24750a61f782f3036a81e7f86d8841ee1326deaebd171" [[package]] name = "tempfile" -version = "3.24.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom", @@ -467,9 +466,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.11+spec-1.1.0" +version = "1.1.4+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" dependencies = [ "indexmap", "serde_core", @@ -482,33 +481,33 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.5+spec-1.1.0" +version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" dependencies = [ "serde_core", ] [[package]] name = "toml_parser" -version = "1.0.6+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ "winnow", ] [[package]] name = "toml_writer" -version = "1.0.6+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "trybuild" -version = "1.0.114" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17e807bff86d2a06b52bca4276746584a78375055b6e45843925ce2802b335" +checksum = "4c5c9f7b7b1a048dd2bebdb7260b0cc71ec5587b19352fa5c3cd9e1c067103f0" dependencies = [ "dissimilar", "glob", @@ -522,9 +521,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-width" @@ -532,15 +531,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" -[[package]] -name = "wasip2" -version = "1.0.1+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "winapi-util" version = "0.1.11" @@ -567,18 +557,12 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" - -[[package]] -name = "wit-bindgen" -version = "0.46.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" [[package]] name = "zmij" -version = "1.0.13" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac93432f5b761b22864c774aac244fa5c0fd877678a4c37ebf6cf42208f9c9ec" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/depends/patches/native_rust/fix-elf-interpreter.sh b/depends/patches/native_rust/fix-elf-interpreter.sh index b25f30db3c52..cc8b186ee49a 100755 --- a/depends/patches/native_rust/fix-elf-interpreter.sh +++ b/depends/patches/native_rust/fix-elf-interpreter.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +export LC_ALL=C # Copyright (c) 2026 The Dash Core developers # Distributed under the MIT software license, see the accompanying @@ -72,6 +73,8 @@ for binary in "$@"; do fi done -echo "Verifying first binary:" -patchelf --print-interpreter "$1" -patchelf --print-rpath "$1" +if [ -n "$1" ]; then + echo "Verifying first binary:" + patchelf --print-interpreter "$1" + patchelf --print-rpath "$1" +fi diff --git a/rust/Makefile.am b/rust/Makefile.am index 3c8eb9cd4530..c25d03874fe0 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -15,23 +15,35 @@ CARGO_ENV = \ # 'cargo' needs uppercase RUST_NATIVE_ENV_UPPER = $(shell echo '$(RUST_NATIVE)' | tr 'a-z-' 'A-Z_') +RUST_NATIVE_LINKER = $(abs_top_builddir)/.cargo/native-linker CARGO_ENV += \ AR="$(NATIVE_AR)" \ CC="$(NATIVE_CC)" \ CXX="$(NATIVE_CXX)" \ - CARGO_TARGET_$(RUST_NATIVE_ENV_UPPER)_LINKER="$(NATIVE_CC)" + CARGO_TARGET_$(RUST_NATIVE_ENV_UPPER)_LINKER="$(RUST_NATIVE_LINKER)" # 'cc' needs preserved case RUST_TARGET_ENV_LOWER = $(shell echo '$(RUST_TARGET)' | tr '-' '_') # 'cargo' needs uppercase RUST_TARGET_ENV_UPPER = $(shell echo '$(RUST_TARGET_ENV_LOWER)' | tr 'a-z' 'A-Z') +RUST_TARGET_LINKER = $(abs_top_builddir)/.cargo/target-linker CARGO_ENV += \ AR_$(RUST_TARGET_ENV_LOWER)="$(AR)" \ CC_$(RUST_TARGET_ENV_LOWER)="$(CC)" \ CFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CFLAGS)" \ CXX_$(RUST_TARGET_ENV_LOWER)="$(CXX)" \ CXXFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CXXFLAGS)" \ - CARGO_TARGET_$(RUST_TARGET_ENV_UPPER)_LINKER="$(CC)" + CARGO_TARGET_$(RUST_TARGET_ENV_UPPER)_LINKER="$(RUST_TARGET_LINKER)" + +$(RUST_NATIVE_LINKER): Makefile + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)printf '%s\n' '#!/bin/sh' 'exec $(NATIVE_CC) "$$@"' > $@ + $(AM_V_at)chmod +x $@ + +$(RUST_TARGET_LINKER): Makefile + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)printf '%s\n' '#!/bin/sh' 'exec $(CC) "$$@"' > $@ + $(AM_V_at)chmod +x $@ if !ENABLE_DEBUG CARGO_BUILD_OPTS += --release @@ -44,20 +56,21 @@ endif # !SILENT_RULES if ENABLE_ONLINE_RUST CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-online -$(CARGO_CONFIGURED): +$(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo $(AM_V_at)touch $@ else CARGO_BUILD_OPTS += --offline CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-offline -$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.toml.offline $(top_srcdir)/Cargo.lock +$(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) $(top_srcdir)/.cargo/config.toml.offline $(top_srcdir)/Cargo.lock $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo - $(AM_V_at)cp $< $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)cp $(top_srcdir)/.cargo/config.toml.offline $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)$(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh $(top_srcdir)/Cargo.lock >> $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)touch $@ @@ -69,22 +82,31 @@ EXTRA_DIST = \ $(LIBRUSTDEPS_FILES) \ $(LIBRUST_CHIRP_FILES) +if ENABLE_RUST all-local: $(CARGO_CONFIGURED) cargo-build-dashrust cxxbridge-chirp cargo-build: $(CARGO_CONFIGURED) cargo-build-dashrust +else +all-local: + +cargo-build: +endif cargo-clean: cargo-clean-dashrust # Aggregate dist hook: per-crate includes define dist- targets; new # crates append here instead of defining their own dist-hook (automake allows # only one dist-hook recipe per Makefile). +if ENABLE_RUST dist-hook: dist-chirp +endif cargo-clean-config: $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)rm -f $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) clean-local: cargo-clean-dashrust cxxbridge-clean-chirp cargo-clean-config diff --git a/src/Makefile.am b/src/Makefile.am index 615ea344fd53..09ff23f21ba9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,10 @@ AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) EXTRA_LIBRARIES = -BUILT_SOURCES = $(LIBRUSTDEPS_H) +BUILT_SOURCES = +if ENABLE_RUST +BUILT_SOURCES += $(LIBRUSTDEPS_H) +endif lib_LTLIBRARIES = noinst_LTLIBRARIES = @@ -52,7 +55,9 @@ endif # ENABLE_STACKTRACES BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) -I$(srcdir)/secp256k1/include -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(LEVELDB_CPPFLAGS) BITCOIN_INCLUDES+=-isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include BITCOIN_INCLUDES+=-isystem$(srcdir)/immer +if ENABLE_RUST BITCOIN_INCLUDES+=$(LIBRUSTDEPS_INCLUDES) +endif LIBBITCOIN_NODE=libbitcoin_node.a LIBBITCOIN_COMMON=libbitcoin_common.a @@ -121,7 +126,11 @@ $(LIBDASHBLS): $(LIBSECP256K1): $(wildcard secp256k1/src/*.h) $(wildcard secp256k1/src/*.c) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) +if ENABLE_RUST LIBCXXBRIDGE=libcxxbridge.la +RUST_COMPONENT_LIBS=$(LIBCXXBRIDGE) $(LIBRUSTDEPS) +RUST_SYSTEM_LIBS=$(RUST_LIBS) +endif # Make is not made aware of per-object dependencies to avoid limiting building parallelization # But to build the less dependent modules first, we manually select their order here: @@ -136,7 +145,9 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_WALLET_TOOL) \ $(LIBBITCOIN_ZMQ) +if ENABLE_RUST noinst_LTLIBRARIES += $(LIBCXXBRIDGE) +endif if BUILD_BITCOIND bin_PROGRAMS += dashd @@ -1101,10 +1112,9 @@ bitcoin_bin_ldadd = \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) + $(RUST_COMPONENT_LIBS) -bitcoin_bin_ldadd += $(BACKTRACE_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(GMP_LIBS) $(RUST_LIBS) +bitcoin_bin_ldadd += $(BACKTRACE_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(GMP_LIBS) $(RUST_SYSTEM_LIBS) dashd_SOURCES = $(bitcoin_daemon_sources) init/bitcoind.cpp dashd_CPPFLAGS = $(bitcoin_bin_cppflags) @@ -1133,10 +1143,8 @@ dash_cli_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ - $(LIBBITCOIN_CRYPTO) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) -dash_cli_LDADD += $(BACKTRACE_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) + $(LIBBITCOIN_CRYPTO) +dash_cli_LDADD += $(BACKTRACE_LIBS) $(EVENT_LIBS) $(GMP_LIBS) # # dash-tx binary # @@ -1156,11 +1164,9 @@ dash_tx_LDADD = \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBDASHBLS) \ - $(LIBSECP256K1) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) + $(LIBSECP256K1) -dash_tx_LDADD += $(BACKTRACE_LIBS) $(GMP_LIBS) $(RUST_LIBS) +dash_tx_LDADD += $(BACKTRACE_LIBS) $(GMP_LIBS) # # dash-wallet binary # @@ -1179,14 +1185,11 @@ dash_wallet_LDADD = \ $(LIBBITCOIN_CRYPTO) \ $(LIBDASHBLS) \ $(LIBSECP256K1) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) \ $(BACKTRACE_LIBS) \ $(BOOST_LIBS) \ $(BDB_LIBS) \ $(SQLITE_LIBS) \ - $(GMP_LIBS) \ - $(RUST_LIBS) + $(GMP_LIBS) if TARGET_WINDOWS dash_wallet_SOURCES += dash-wallet-res.rc @@ -1210,11 +1213,9 @@ dash_util_LDADD = \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBSECP256K1) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) \ $(BACKTRACE_LIBS) -dash_util_LDADD += $(BOOST_LIBS) $(RUST_LIBS) +dash_util_LDADD += $(BOOST_LIBS) # dash-chainstate binary # dash_chainstate_SOURCES = bitcoin-chainstate.cpp @@ -1418,7 +1419,7 @@ include_HEADERS = script/bitcoinconsensus.h libdashconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(crypto_libbitcoin_crypto_sph_la_SOURCES) $(libbitcoin_consensus_a_SOURCES) libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) -libdashconsensus_la_LIBADD = $(LIBDASHBLS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) $(GMP_LIBS) $(RUST_LIBS) +libdashconsensus_la_LIBADD = $(LIBDASHBLS) $(LIBSECP256K1) $(GMP_LIBS) libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -DDISABLE_OPTIMIZED_SHA256 libdashconsensus_la_CPPFLAGS += -isystem$(srcdir)/dashbls/include -isystem$(srcdir)/dashbls/depends/relic/include -isystem$(srcdir)/dashbls/depends/minialloc/include libdashconsensus_la_CPPFLAGS += -isystem$(srcdir)/immer @@ -1428,12 +1429,14 @@ endif # # CXX bridge library # +if ENABLE_RUST libcxxbridge_la_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(PIC_FLAGS) libcxxbridge_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(PIC_FLAGS) -static libcxxbridge_la_LDFLAGS = $(AM_LDFLAGS) -static nodist_libcxxbridge_la_SOURCES = $(LIBRUSTDEPS_CPP) $(libcxxbridge_la_OBJECTS): $(LIBRUSTDEPS_H) +endif # CTAES_DIST = crypto/ctaes/bench.c diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 63c5cc0f0f08..78a51e5f5128 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -77,15 +77,14 @@ bench_bench_dash_LDADD = \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) \ + $(RUST_COMPONENT_LIBS) \ $(LIBUNIVALUE) \ $(EVENT_PTHREADS_LIBS) \ $(EVENT_LIBS) \ $(MINIUPNPC_LIBS) \ $(NATPMP_LIBS) \ $(GMP_LIBS) \ - $(RUST_LIBS) \ + $(RUST_SYSTEM_LIBS) \ $(BACKTRACE_LIBS) if ENABLE_ZMQ diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 999745ceebb1..7bfb3ae10980 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -462,8 +462,8 @@ if ENABLE_ZMQ bitcoin_qt_ldadd += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif bitcoin_qt_ldadd += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBDASHBLS) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ - $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) + $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) $(RUST_COMPONENT_LIBS) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_SYSTEM_LIBS) bitcoin_qt_ldflags = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) bitcoin_qt_libtoolflags = $(AM_LIBTOOLFLAGS) --tag CXX diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 535f466f26ec..c5e416bdfb67 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -60,8 +60,8 @@ qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBDASHBLS) $(LIBUNIVALUE) $(LIBLEVELDB) \ $(LIBMEMENV) $(BACKTRACE_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ - $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) + $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(SQLITE_LIBS) $(LIBSECP256K1) $(RUST_COMPONENT_LIBS) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_SYSTEM_LIBS) qt_test_test_dash_qt_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qt_test_test_dash_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index dcf8b685fa8c..94208fa2e99d 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -56,13 +56,12 @@ FUZZ_SUITE_LD_COMMON = \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ - $(LIBCXXBRIDGE) \ - $(LIBRUSTDEPS) \ + $(RUST_COMPONENT_LIBS) \ $(MINISKETCH_LIBS) \ $(EVENT_LIBS) \ $(EVENT_PTHREADS_LIBS) \ $(GMP_LIBS) \ - $(RUST_LIBS) \ + $(RUST_SYSTEM_LIBS) \ $(BACKTRACE_LIBS) if USE_UPNP @@ -274,10 +273,10 @@ test_test_dash_LDADD += $(LIBBITCOIN_WALLET) test_test_dash_CPPFLAGS += $(BDB_CPPFLAGS) endif test_test_dash_LDADD += $(LIBBITCOIN_NODE) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ - $(LIBDASHBLS) $(LIBLEVELDB) $(LIBMEMENV) $(BACKTRACE_LIBS) $(LIBSECP256K1) $(LIBCXXBRIDGE) $(LIBRUSTDEPS) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS) + $(LIBDASHBLS) $(LIBLEVELDB) $(LIBMEMENV) $(BACKTRACE_LIBS) $(LIBSECP256K1) $(RUST_COMPONENT_LIBS) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS) test_test_dash_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_dash_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(SQLITE_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_LIBS) +test_test_dash_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(SQLITE_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GMP_LIBS) $(RUST_SYSTEM_LIBS) test_test_dash_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) -static if ENABLE_ZMQ diff --git a/src/init.cpp b/src/init.cpp index b3c66f8e1a2f..14f14db2a13d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -126,7 +126,9 @@ #include #endif // ENABLE_WALLET +#ifdef ENABLE_RUST #include +#endif #include #include @@ -1478,7 +1480,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return false; } - LogPrintf("%s\n", std::string(chirp::chirp())); +#ifdef ENABLE_RUST + LogPrintf("Rust bridge: %s\n", std::string(chirp::chirp())); +#endif LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); diff --git a/test/lint/lint-files.py b/test/lint/lint-files.py index a53a060b550c..ee09cea93235 100755 --- a/test/lint/lint-files.py +++ b/test/lint/lint-files.py @@ -21,7 +21,7 @@ ALLOWED_FILENAME_REGEXP = "^[a-zA-Z0-9/_.@][a-zA-Z0-9/_.@-]*$" ALLOWED_SOURCE_FILENAME_REGEXP = "^[a-z0-9_./-]+$" ALLOWED_SOURCE_FILENAME_EXCEPTION_REGEXP = ( - "^rust/|src/(dashbls/|immer/|secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)" + "^src/(dashbls/|immer/|secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)" ) ALLOWED_PERMISSION_NON_EXECUTABLES = 0o644 ALLOWED_PERMISSION_EXECUTABLES = 0o755 diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py index 11c5ffd51ed7..6992343d6cf6 100755 --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -82,7 +82,7 @@ def main(): matching_files_filtered = [] for matching_file in matching_files: - if not re.search('^rust/|src/(dashbls|leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp|clientversion.cpp)', matching_file): + if not re.search('^src/(dashbls|leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp|clientversion.cpp)', matching_file): matching_files_filtered.append(matching_file) matching_files_filtered.sort() diff --git a/test/lint/lint-include-guards.py b/test/lint/lint-include-guards.py index 24b6a6f4821a..6e59c83f7dbc 100755 --- a/test/lint/lint-include-guards.py +++ b/test/lint/lint-include-guards.py @@ -17,8 +17,7 @@ HEADER_ID_PREFIX = 'BITCOIN_' HEADER_ID_SUFFIX = '_H' -EXCLUDE_FILES_WITH_PREFIX = ['rust/', - 'src/crypto/ctaes', +EXCLUDE_FILES_WITH_PREFIX = ['src/crypto/ctaes', 'src/leveldb', 'src/crc32c', 'src/secp256k1', diff --git a/test/lint/lint-includes.py b/test/lint/lint-includes.py index ea31465f218e..9a0cfa127dde 100755 --- a/test/lint/lint-includes.py +++ b/test/lint/lint-includes.py @@ -15,8 +15,7 @@ from subprocess import check_output, CalledProcessError -EXCLUDED_DIRS = ["rust/", - "src/leveldb/", +EXCLUDED_DIRS = ["src/leveldb/", "src/crc32c/", "src/secp256k1/", "src/minisketch/", diff --git a/test/lint/lint-locale-dependence.py b/test/lint/lint-locale-dependence.py index 5fa01662141e..0ee4c4566b0a 100755 --- a/test/lint/lint-locale-dependence.py +++ b/test/lint/lint-locale-dependence.py @@ -56,7 +56,6 @@ ] REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS = [ - "rust/", "src/crypto/ctaes/", "src/leveldb/", "src/secp256k1/", diff --git a/test/lint/lint-python-utf8-encoding.py b/test/lint/lint-python-utf8-encoding.py index fafdaf5cced7..0377e12701ed 100755 --- a/test/lint/lint-python-utf8-encoding.py +++ b/test/lint/lint-python-utf8-encoding.py @@ -12,8 +12,7 @@ from subprocess import check_output, CalledProcessError -EXCLUDED_DIRS = ["rust/", - "src/crc32c/", +EXCLUDED_DIRS = ["src/crc32c/", "src/secp256k1/"] diff --git a/test/lint/lint-python.py b/test/lint/lint-python.py index fc4f31416127..d4c750147e7a 100755 --- a/test/lint/lint-python.py +++ b/test/lint/lint-python.py @@ -21,8 +21,7 @@ DEPS = ['flake8', 'lief', 'mypy', 'pyzmq'] FILES_ARGS = ['git', 'ls-files', '--','test/functional/*.py', 'contrib/devtools/*.py', ':(exclude)contrib/devtools/github-merge.py'] -EXCLUDE_DIRS = ['rust/', - 'src/dashbls/', +EXCLUDE_DIRS = ['src/dashbls/', 'src/immer/'] ENABLED = ( diff --git a/test/lint/lint-shell-locale.py b/test/lint/lint-shell-locale.py index 5b4ced04cf3a..77f6d79f3529 100755 --- a/test/lint/lint-shell-locale.py +++ b/test/lint/lint-shell-locale.py @@ -41,7 +41,7 @@ def main(): exit_code = 0 shell_files = get_shell_files_list() for file_path in shell_files: - if re.search('rust/|src/(dashbls|secp256k1|minisketch)/', file_path): + if re.search('src/(dashbls|secp256k1|minisketch)/', file_path): continue with open(file_path, 'r', encoding='utf-8') as file_obj: diff --git a/test/lint/lint-shell.py b/test/lint/lint-shell.py index 7c4584f5d062..4be1f297fa11 100755 --- a/test/lint/lint-shell.py +++ b/test/lint/lint-shell.py @@ -68,7 +68,7 @@ def main(): ] files = get_files(files_cmd) # remove everything that doesn't match this regex - reg = re.compile(r'rust|src/[dashbls,immer,leveldb,secp256k1,minisketch]') + reg = re.compile(r'src/[dashbls,immer,leveldb,secp256k1,minisketch]') files[:] = [file for file in files if not reg.match(file)] # build the `shellcheck` command diff --git a/test/lint/lint-spelling.py b/test/lint/lint-spelling.py index dac24b5612b8..fb4d2495c691 100755 --- a/test/lint/lint-spelling.py +++ b/test/lint/lint-spelling.py @@ -12,7 +12,7 @@ from subprocess import check_output, STDOUT, CalledProcessError IGNORE_WORDS_FILE = 'test/lint/spelling.ignore-words.txt' -FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)rust/", ":(exclude)src/dashbls/", ":(exclude)src/crc32c/", ":(exclude)src/crypto/", ":(exclude)src/ctpl_stl.h", ":(exclude)src/cxxtimer.hpp", ":(exclude)src/immer/", ":(exclude)src/leveldb/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/", ":(exclude)contrib/guix/patches", ":(exclude)src/util/subprocess.hpp", ":(exclude)src/wallet/bip39_english.h"] +FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/dashbls/", ":(exclude)src/crc32c/", ":(exclude)src/crypto/", ":(exclude)src/ctpl_stl.h", ":(exclude)src/cxxtimer.hpp", ":(exclude)src/immer/", ":(exclude)src/leveldb/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/", ":(exclude)contrib/guix/patches", ":(exclude)src/util/subprocess.hpp", ":(exclude)src/wallet/bip39_english.h"] def check_codespell_install(): diff --git a/test/lint/lint-whitespace.py b/test/lint/lint-whitespace.py index 3d9208425720..78c145bd004e 100755 --- a/test/lint/lint-whitespace.py +++ b/test/lint/lint-whitespace.py @@ -18,7 +18,6 @@ EXCLUDED_DIRS = ["depends/patches/", "contrib/guix/patches/", - "rust/", "src/crypto/x11/", "src/leveldb/", "src/crc32c/", From fef0b06e27b741c59cc9737234301924e1051d83 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 12:23:23 -0500 Subject: [PATCH 26/60] build: harden optional Rust integration --- configure.ac | 16 ++++- contrib/devtools/update-native-cxxbridge.py | 5 +- contrib/devtools/update-rust-hashes.py | 1 + depends/Makefile | 14 ++-- depends/funcs.mk | 8 +-- depends/packages/rust_stdlib.mk | 5 ++ rust/Makefile.am | 74 +------------------- rust/Makefile.chirp.include | 6 +- rust/Makefile.common.include | 77 +++++++++++++++++++++ rust/Makefile.libs.include | 7 +- src/Makefile.am | 4 ++ src/test/system_tests.cpp | 13 ++++ 12 files changed, 141 insertions(+), 89 deletions(-) create mode 100644 rust/Makefile.common.include diff --git a/configure.ac b/configure.ac index 0515f273cc49..128c742fbded 100644 --- a/configure.ac +++ b/configure.ac @@ -1747,7 +1747,7 @@ AC_DEFUN([RS_SET_TRIPLE], [ aarch64-*-linux*|arm64-*-linux*) $1="aarch64-unknown-linux-$3" ;; arm-*-linux*) $1="armv7-unknown-linux-$3eabihf" ;; - powerpc64-*-linux*) $1="powerpc64-unknown-linux-$3" ;; + powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-$3" ;; riscv64-*-linux*) $1="riscv64gc-unknown-linux-$3" ;; x86_64-*-linux*) $1="x86_64-unknown-linux-$3" ;; @@ -1792,13 +1792,25 @@ if test "$enable_rust" = "yes"; then esac AC_MSG_CHECKING([for Rust target]) - RS_SET_TRIPLE([RUST_TARGET], [$host], [musl]) + rust_target_libc=gnu + if test -n "$depends_prefix"; then + rust_target_libc=musl + fi + RS_SET_TRIPLE([RUST_TARGET], [$host], [$rust_target_libc]) if test "$RUST_TARGET" = ""; then AC_MSG_RESULT([unknown]) AC_MSG_ERROR([Unsupported target for Rust: $host]) fi AC_MSG_RESULT([$RUST_TARGET]) + AC_MSG_CHECKING([for Rust target standard library]) + rust_target_libdir=`$RUSTC --print target-libdir --target "$RUST_TARGET" 2>/dev/null` + if test -z "$rust_target_libdir" || test ! -d "$rust_target_libdir"; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([Rust standard library for $RUST_TARGET is not installed]) + fi + AC_MSG_RESULT([$rust_target_libdir]) + case $host in *darwin*) AC_MSG_CHECKING([for Xcode SDK]) diff --git a/contrib/devtools/update-native-cxxbridge.py b/contrib/devtools/update-native-cxxbridge.py index 49fd9556e320..b056dac8d49c 100755 --- a/contrib/devtools/update-native-cxxbridge.py +++ b/contrib/devtools/update-native-cxxbridge.py @@ -54,7 +54,10 @@ def main() -> int: # Extract tarball print(f"Extracting {tarball_path}") with tarfile.open(tarball_path, "r:gz") as tar: - tar.extractall(tmp_path, filter="data") + # getattr keeps this compatible with the older tarfile type stubs + # used by the Python 3.10 lint environment. Supported Python 3.10 + # releases include the security filter at runtime. + getattr(tar, "extractall")(tmp_path, filter="data") cxx_dir = tmp_path / f"cxx-{version}" if not cxx_dir.exists(): diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 8cce3cbf068e..adb78a0948b0 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -23,6 +23,7 @@ # Linux "aarch64-unknown-linux-musl", "armv7-unknown-linux-musleabihf", + "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-musl", "x86_64-unknown-linux-musl", diff --git a/depends/Makefile b/depends/Makefile index 2eb9a87b929e..b9e050a01483 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -62,7 +62,9 @@ HOST_ID_SALT ?= salt BUILD_ID_SALT ?= salt CRATE_REGISTRY := vendored-sources -CRATE_ARCHIVE = $(SOURCES_PATH)/vendored-crates.tar.gz +CRATE_LOCK = $(BASEDIR)/../Cargo.lock +CRATE_LOCK_HASH = $(shell $(build_SHA256SUM) $(CRATE_LOCK) | cut -c-$(HASH_LENGTH)) +CRATE_ARCHIVE = $(SOURCES_PATH)/vendored-crates-$(CRATE_LOCK_HASH).tar.gz ifneq ($(DEBUG),) release_type=debug @@ -213,15 +215,15 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) mkdir -p $(@D) echo copying packages: $^ echo to: $(@D) - cd $(@D); $(foreach package,$^, $(build_TAR) -P --no-same-owner -xf $($(package)_cached); ) + cd $(@D); $(foreach package,$^, $(build_TAR) --no-same-owner -xf $($(package)_cached); ) touch $@ # Vendors Rust crate dependencies for offline builds # Uses pre-built archive if available, otherwise runs 'cargo vendor' -$(host_prefix)/$(CRATE_REGISTRY): $(host_prefix)/.stamp_$(final_build_id) +$(host_prefix)/$(CRATE_REGISTRY): $(host_prefix)/.stamp_$(final_build_id) $(CRATE_LOCK) @if test -f $(CRATE_ARCHIVE); \ then echo Extracting pre-vendored crates from $(CRATE_ARCHIVE)...; \ - $(build_TAR) -P --no-same-owner -xf $(CRATE_ARCHIVE) -C $(@D); \ + $(build_TAR) --no-same-owner -xf $(CRATE_ARCHIVE) -C $(@D); \ else echo Vendoring crates...; \ $(@D)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $@; \ fi @@ -231,10 +233,10 @@ $(host_prefix)/$(CRATE_REGISTRY): $(host_prefix)/.stamp_$(final_build_id) vendor-dep-crates: $(foreach package,$(native_cargo_packages),vendor-$(package)-crates) # Vendors project-wide cargo packages -vendor-all-crates: $(native_rust_cached) +vendor-all-crates: $(native_rust_cached) $(CRATE_LOCK) @rm -rf $(WORK_PATH)/vendor-main @mkdir -p $(WORK_PATH)/vendor-main - @$(build_TAR) -P --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-main + @$(build_TAR) --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-main @echo "Vendoring main project crates..." @$(WORK_PATH)/vendor-main/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(WORK_PATH)/vendor-main/$(CRATE_REGISTRY) @cd $(WORK_PATH)/vendor-main; find $(CRATE_REGISTRY) | sort | $(build_TAR) --no-recursion -czf $(CRATE_ARCHIVE) -T - diff --git a/depends/funcs.mk b/depends/funcs.mk index b4d8353312e6..4fa1585a883b 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -85,7 +85,7 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) #default commands # The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior $(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) -$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) -P --no-same-owner --strip-components=1 -xf $$($(1)_source) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) --no-same-owner --strip-components=1 -xf $$($(1)_source) $(1)_preprocess_cmds ?= true $(1)_build_cmds ?= true $(1)_config_cmds ?= true @@ -290,10 +290,10 @@ $(1)_vendored_archive = $(SOURCES_PATH)/$($(1)_vendored_file_name) vendor-$(1)-crates: $(native_rust_cached) $($(1)_fetched) @rm -rf $(WORK_PATH)/vendor-$(1) @mkdir -p $(WORK_PATH)/vendor-$(1) - @$(build_TAR) -P --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-$(1) + @$(build_TAR) --no-same-owner -xf $(native_rust_cached) -C $(WORK_PATH)/vendor-$(1) @echo "Vendoring $(1) crates..." @mkdir -p $(WORK_PATH)/vendor-$(1)/src - @cd $(WORK_PATH)/vendor-$(1)/src && $(build_TAR) -P --no-same-owner --strip-components=1 -xf $(SOURCES_PATH)/$($(1)_file_name) + @cd $(WORK_PATH)/vendor-$(1)/src && $(build_TAR) --no-same-owner --strip-components=1 -xf $(SOURCES_PATH)/$($(1)_file_name) @cp $(PATCHES_PATH)/$(1)/Cargo.lock $(WORK_PATH)/vendor-$(1)/src/ @$(WORK_PATH)/vendor-$(1)/native/bin/cargo vendor --locked --manifest-path $(WORK_PATH)/vendor-$(1)/src/$($(1)_cargo_manifest) $(WORK_PATH)/vendor-$(1)/src/vendored @cd $(WORK_PATH)/vendor-$(1)/src; find vendored | sort | $(build_TAR) --no-recursion -czf $$($(1)_vendored_archive) -T - @@ -334,7 +334,7 @@ define int_cargo_preprocess_ext $(1)_preprocess_cmds += && \ if test -f $(SOURCES_PATH)/$($(1)_vendored_file_name); then \ echo "Extracting vendored crates for $(1)..." && \ - $(build_TAR) -P --no-same-owner -xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ + $(build_TAR) --no-same-owner -xf $(SOURCES_PATH)/$($(1)_vendored_file_name) && \ mkdir -p .cargo && \ cp $(PATCHES_PATH)/$(1)/cargo-config.toml .cargo/config.toml; \ fi diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index 2bf35b8ca239..de7e0bcc3705 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -52,6 +52,11 @@ $(package)_targets += powerpc64le-unknown-linux-musl $(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-musl $(package)_sha256_hash_powerpc64le-unknown-linux-musl:=696958d87842d877640140ddbbaa74d044374874dee9516e227a395b70bfb8d4 +# Linux (PowerPC 64-bit big-endian) +$(package)_targets += powerpc64-unknown-linux-gnu +$(package)_target_powerpc64-unknown-linux-gnu:=powerpc64-unknown-linux-gnu +$(package)_sha256_hash_powerpc64-unknown-linux-gnu:=c47938c152f1b237c901090d69522ce1ccfa69a859ed10d634fe3083108c3017 + # Linux (RISCV64GC) $(package)_targets += riscv64gc-unknown-linux-musl $(package)_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-musl diff --git a/rust/Makefile.am b/rust/Makefile.am index c25d03874fe0..a007ff547599 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -3,79 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -CARGO_BUILD_OPTS = --locked --target $(RUST_TARGET) -CARGO_ENV = \ - MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ - CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ - RUSTC="$(RUSTC)" \ - RUSTFLAGS="$(RUSTFLAGS)" \ - TERM="dumb" \ - ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} \ - ${RUSTUP_TOOLCHAIN+RUSTUP_TOOLCHAIN="$(RUSTUP_TOOLCHAIN)"} - -# 'cargo' needs uppercase -RUST_NATIVE_ENV_UPPER = $(shell echo '$(RUST_NATIVE)' | tr 'a-z-' 'A-Z_') -RUST_NATIVE_LINKER = $(abs_top_builddir)/.cargo/native-linker -CARGO_ENV += \ - AR="$(NATIVE_AR)" \ - CC="$(NATIVE_CC)" \ - CXX="$(NATIVE_CXX)" \ - CARGO_TARGET_$(RUST_NATIVE_ENV_UPPER)_LINKER="$(RUST_NATIVE_LINKER)" - -# 'cc' needs preserved case -RUST_TARGET_ENV_LOWER = $(shell echo '$(RUST_TARGET)' | tr '-' '_') -# 'cargo' needs uppercase -RUST_TARGET_ENV_UPPER = $(shell echo '$(RUST_TARGET_ENV_LOWER)' | tr 'a-z' 'A-Z') -RUST_TARGET_LINKER = $(abs_top_builddir)/.cargo/target-linker -CARGO_ENV += \ - AR_$(RUST_TARGET_ENV_LOWER)="$(AR)" \ - CC_$(RUST_TARGET_ENV_LOWER)="$(CC)" \ - CFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CFLAGS)" \ - CXX_$(RUST_TARGET_ENV_LOWER)="$(CXX)" \ - CXXFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CXXFLAGS)" \ - CARGO_TARGET_$(RUST_TARGET_ENV_UPPER)_LINKER="$(RUST_TARGET_LINKER)" - -$(RUST_NATIVE_LINKER): Makefile - $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo - $(AM_V_at)printf '%s\n' '#!/bin/sh' 'exec $(NATIVE_CC) "$$@"' > $@ - $(AM_V_at)chmod +x $@ - -$(RUST_TARGET_LINKER): Makefile - $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo - $(AM_V_at)printf '%s\n' '#!/bin/sh' 'exec $(CC) "$$@"' > $@ - $(AM_V_at)chmod +x $@ - -if !ENABLE_DEBUG -CARGO_BUILD_OPTS += --release -endif # !ENABLE_DEBUG - -if !SILENT_RULES -CARGO_BUILD_OPTS += --verbose -endif # !SILENT_RULES - -if ENABLE_ONLINE_RUST -CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-online - -$(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config - $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo - $(AM_V_at)touch $@ -else -CARGO_BUILD_OPTS += --offline -CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-offline - -$(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) $(top_srcdir)/.cargo/config.toml.offline $(top_srcdir)/Cargo.lock - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config - $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo - $(AM_V_at)cp $(top_srcdir)/.cargo/config.toml.offline $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)$(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh $(top_srcdir)/Cargo.lock >> $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)touch $@ -endif # ENABLE_ONLINE_RUST - +include $(top_srcdir)/rust/Makefile.common.include include $(top_srcdir)/rust/Makefile.libs.include EXTRA_DIST = \ diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index bb57cdc99e0f..70df0962f79c 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -36,7 +36,8 @@ $(LIBRUST_CHIRP_SRCS): ; $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(AM_V_at)$(MKDIR_P) $(@D) - $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp; then \ + $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp && \ + test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp $@; \ else \ $(CXXBRIDGE) $< -o $@; \ @@ -44,7 +45,8 @@ $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(AM_V_at)$(MKDIR_P) $(@D) - $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h; then \ + $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h && \ + test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h $@; \ else \ $(CXXBRIDGE) $< --header -o $@; \ diff --git a/rust/Makefile.common.include b/rust/Makefile.common.include new file mode 100644 index 000000000000..eb64e2fa8055 --- /dev/null +++ b/rust/Makefile.common.include @@ -0,0 +1,77 @@ +# Copyright (c) 2016-2025 The Zcash developers +# Copyright (c) 2026 The Dash Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +CARGO_BUILD_OPTS = --locked --target $(RUST_TARGET) +CARGO_ENV = \ + MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ + CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ + RUSTC="$(RUSTC)" \ + RUSTFLAGS="$(RUSTFLAGS)" \ + TERM="dumb" \ + ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} \ + ${RUSTUP_TOOLCHAIN+RUSTUP_TOOLCHAIN="$(RUSTUP_TOOLCHAIN)"} + +# 'cargo' needs uppercase +RUST_NATIVE_ENV_UPPER = $(shell echo '$(RUST_NATIVE)' | tr 'a-z-' 'A-Z_') +RUST_NATIVE_LINKER = $(abs_top_builddir)/.cargo/native-linker +CARGO_ENV += \ + AR="$(NATIVE_AR)" \ + CC="$(NATIVE_CC)" \ + CXX="$(NATIVE_CXX)" \ + CARGO_TARGET_$(RUST_NATIVE_ENV_UPPER)_LINKER="$(RUST_NATIVE_LINKER)" + +# 'cc' needs preserved case +RUST_TARGET_ENV_LOWER = $(shell echo '$(RUST_TARGET)' | tr '-' '_') +# 'cargo' needs uppercase +RUST_TARGET_ENV_UPPER = $(shell echo '$(RUST_TARGET_ENV_LOWER)' | tr 'a-z' 'A-Z') +RUST_TARGET_LINKER = $(abs_top_builddir)/.cargo/target-linker +CARGO_ENV += \ + AR_$(RUST_TARGET_ENV_LOWER)="$(AR)" \ + CC_$(RUST_TARGET_ENV_LOWER)="$(CC)" \ + CFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CFLAGS)" \ + CXX_$(RUST_TARGET_ENV_LOWER)="$(CXX)" \ + CXXFLAGS_$(RUST_TARGET_ENV_LOWER)="$(CXXFLAGS)" \ + CARGO_TARGET_$(RUST_TARGET_ENV_UPPER)_LINKER="$(RUST_TARGET_LINKER)" + +$(RUST_NATIVE_LINKER): Makefile + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)printf '%s\n' '#!/bin/sh' 'exec $(NATIVE_CC) "$$@"' > $@ + $(AM_V_at)chmod +x $@ + +$(RUST_TARGET_LINKER): Makefile + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)printf '%s\n' '#!/bin/sh' 'exec $(CC) "$$@"' > $@ + $(AM_V_at)chmod +x $@ + +if !ENABLE_DEBUG +CARGO_BUILD_OPTS += --release +endif # !ENABLE_DEBUG + +if !SILENT_RULES +CARGO_BUILD_OPTS += --verbose +endif # !SILENT_RULES + +if ENABLE_ONLINE_RUST +CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-online + +$(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)touch $@ +else +CARGO_BUILD_OPTS += --offline +CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-offline + +$(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) $(top_srcdir)/.cargo/config.toml.offline $(top_srcdir)/Cargo.lock + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online + $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo + $(AM_V_at)cp $(top_srcdir)/.cargo/config.toml.offline $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)$(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh $(top_srcdir)/Cargo.lock >> $(abs_top_builddir)/.cargo/config.toml + $(AM_V_at)touch $@ +endif # ENABLE_ONLINE_RUST diff --git a/rust/Makefile.libs.include b/rust/Makefile.libs.include index cee9c0832082..b637dc1c0436 100644 --- a/rust/Makefile.libs.include +++ b/rust/Makefile.libs.include @@ -52,7 +52,12 @@ LIBRUSTDEPS_FILES = \ LIBRUSTDEPS_COMPONENT_SRCS = \ $(LIBRUST_CHIRP_FILES) -$(LIBRUSTDEPS): $(LIBRUSTDEPS_SRCS) $(LIBRUSTDEPS_MANIFEST) $(LIBRUSTDEPS_COMPONENT_SRCS) +$(LIBRUSTDEPS): $(CARGO_CONFIGURED) \ + $(top_srcdir)/Cargo.toml \ + $(top_srcdir)/Cargo.lock \ + $(LIBRUSTDEPS_SRCS) \ + $(LIBRUSTDEPS_MANIFEST) \ + $(LIBRUSTDEPS_COMPONENT_SRCS) $(AM_V_GEN)$(LIBRUSTDEPS_CARGO_ENV) $(CARGO) build $(LIBRUSTDEPS_CARGO_BUILD_OPTS) cargo-build-dashrust: $(LIBRUSTDEPS) diff --git a/src/Makefile.am b/src/Makefile.am index 09ff23f21ba9..e7065269bfe3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,7 @@ print-%: FORCE @echo '$*'='$($*)' +include $(top_srcdir)/rust/Makefile.common.include include $(top_srcdir)/rust/Makefile.libs.include DIST_SUBDIRS = secp256k1 @@ -27,6 +28,9 @@ EXTRA_LIBRARIES = BUILT_SOURCES = if ENABLE_RUST BUILT_SOURCES += $(LIBRUSTDEPS_H) + +libbitcoin_node_a-init.$(OBJEXT) \ +test/test_dash-system_tests.$(OBJEXT): $(LIBRUSTDEPS_H) endif lib_LTLIBRARIES = diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index ce7ed3912c79..e1a245dbc334 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef ENABLE_RUST +#include +#endif // ENABLE_RUST + #ifdef ENABLE_EXTERNAL_SIGNER #include #endif // ENABLE_EXTERNAL_SIGNER @@ -21,6 +25,15 @@ BOOST_AUTO_TEST_CASE(dummy) BOOST_CHECK(true); } +#ifdef ENABLE_RUST +BOOST_AUTO_TEST_CASE(rust_bridge) +{ + const std::string result{chirp::chirp()}; + BOOST_CHECK(result.starts_with("chirp 0.1.0 built with rustc ")); + BOOST_CHECK(result.ends_with(" reports \"cheep cheep\"")); +} +#endif // ENABLE_RUST + #ifdef ENABLE_EXTERNAL_SIGNER BOOST_AUTO_TEST_CASE(run_command) From 29add8a93f7ba6e747bbb4ce76d82384ca6c1ee7 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 12:26:38 -0500 Subject: [PATCH 27/60] build: distribute Rust vendor helper --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 1aaa33a66689..69d7dd6671d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,7 +73,8 @@ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_INSTALLER_ICONS) \ CARGO_FILES = \ $(top_srcdir)/.cargo/config.toml.offline \ $(top_srcdir)/Cargo.lock \ - $(top_srcdir)/Cargo.toml + $(top_srcdir)/Cargo.toml \ + $(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \ test_dash_filtered.info total_coverage.info \ From 61f9b7728a972f2ab50cf90b52ed52af06286e1e Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 12:48:41 -0500 Subject: [PATCH 28/60] build: validate offline Rust vendor sources --- configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 128c742fbded..3b416979ee1e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,8 @@ if test "${RUSTFLAGS+set}" != "set"; then RUSTFLAGS="-C embed-bitcode=yes -C relocation-model=pic" fi +AC_ARG_VAR([RUST_VENDORED_SOURCES], [Directory containing vendored Rust crate sources for offline builds]) + AC_ARG_ENABLE([rust], [AS_HELP_STRING([--enable-rust], [build the Rust/C++ bridge smoke component (default is no)])], @@ -1769,6 +1771,14 @@ if test "$enable_rust" = "yes"; then if test -z "$CARGO" || test -z "$RUSTC" || test -z "$CXXBRIDGE"; then AC_MSG_ERROR([cargo, rustc and cxxbridge are required by --enable-rust]) fi + if test "$enable_online_rust" = "no"; then + if test -z "$RUST_VENDORED_SOURCES"; then + AC_MSG_ERROR([--enable-rust requires RUST_VENDORED_SOURCES for offline builds or --enable-online-rust]) + fi + if test ! -d "$RUST_VENDORED_SOURCES"; then + AC_MSG_ERROR([Rust vendored sources directory does not exist: $RUST_VENDORED_SOURCES]) + fi + fi AC_DEFINE([ENABLE_RUST], [1], [Define this symbol to enable Rust components]) case $host in From 4037a028adeafd0ce7bb2eea26409dea50b0ff01 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 13:51:37 -0500 Subject: [PATCH 29/60] build: complete Rust toolchain validation --- Makefile.am | 1 + configure.ac | 8 ++++++++ depends/Makefile | 6 +++--- rust/Makefile.chirp.include | 11 +++++++++-- rust/Makefile.common.include | 4 ++-- rust/Makefile.libs.include | 1 + 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index 69d7dd6671d4..6c77fdd262ab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -74,6 +74,7 @@ CARGO_FILES = \ $(top_srcdir)/.cargo/config.toml.offline \ $(top_srcdir)/Cargo.lock \ $(top_srcdir)/Cargo.toml \ + $(top_srcdir)/rust-toolchain.toml \ $(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \ diff --git a/configure.ac b/configure.ac index 3b416979ee1e..feaa437c6f38 100644 --- a/configure.ac +++ b/configure.ac @@ -133,6 +133,7 @@ dnl Rust-dependent component is explicitly enabled. AC_PATH_PROG([CARGO], [cargo]) AC_PATH_PROG([CXXBRIDGE], [cxxbridge]) AC_PATH_PROG([RUSTC], [rustc]) +CXXBRIDGE_REQUIRED_VERSION="1.0.198" AC_ARG_VAR([CARGO_INCREMENTAL], [Enable incremental compilation for Rust]) if test "${CARGO_INCREMENTAL+set}" != "set"; then @@ -1771,6 +1772,13 @@ if test "$enable_rust" = "yes"; then if test -z "$CARGO" || test -z "$RUSTC" || test -z "$CXXBRIDGE"; then AC_MSG_ERROR([cargo, rustc and cxxbridge are required by --enable-rust]) fi + AC_MSG_CHECKING([for cxxbridge $CXXBRIDGE_REQUIRED_VERSION]) + cxxbridge_version=`$CXXBRIDGE --version 2>/dev/null` + if test "$cxxbridge_version" != "cxxbridge $CXXBRIDGE_REQUIRED_VERSION"; then + AC_MSG_RESULT([no ($cxxbridge_version)]) + AC_MSG_ERROR([cxxbridge $CXXBRIDGE_REQUIRED_VERSION is required by --enable-rust]) + fi + AC_MSG_RESULT([yes]) if test "$enable_online_rust" = "no"; then if test -z "$RUST_VENDORED_SOURCES"; then AC_MSG_ERROR([--enable-rust requires RUST_VENDORED_SOURCES for offline builds or --enable-online-rust]) diff --git a/depends/Makefile b/depends/Makefile index b9e050a01483..20f3dce5a365 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -350,11 +350,11 @@ endif download-one: check-sources $(all_sources) download-osx: - @$(MAKE) -s HOST=x86_64-apple-darwin download-one + @$(MAKE) -s RUST=$(RUST) HOST=x86_64-apple-darwin download-one download-linux: - @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one + @$(MAKE) -s RUST=$(RUST) HOST=x86_64-unknown-linux-gnu download-one download-win: - @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one + @$(MAKE) -s RUST=$(RUST) HOST=x86_64-w64-mingw32 download-one download-rust-std: @mkdir -p $(SOURCES_PATH) @mkdir -p $(SOURCES_PATH)/download-stamps diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 70df0962f79c..fb50a5116ca4 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -9,7 +9,7 @@ LIBRUST_CHIRP_CRATE_DIR = $(top_srcdir)/rust/chirp LIBRUST_CHIRP_GEN_DIR = $(abs_top_builddir)/rust/chirp/gen -LIBRUST_CHIRP_GEN_SRCDIR = $(top_srcdir)/rust/chirp/gen +LIBRUST_CHIRP_GEN_SRCDIR = $(abs_top_srcdir)/rust/chirp/gen LIBRUST_CHIRP_MANIFEST = $(LIBRUST_CHIRP_CRATE_DIR)/Cargo.toml LIBRUST_CHIRP_SRCS = \ @@ -24,6 +24,9 @@ LIBRUST_CHIRP_CPP = \ LIBRUST_CHIRP_H = \ $(LIBRUST_CHIRP_GEN_DIR)/include/rust/chirp/lib.h +LIBCXXBRIDGE_H = \ + $(LIBRUST_CHIRP_GEN_DIR)/include/rust/cxx.h + LIBRUST_CHIRP_INCLUDES = \ -I$(LIBRUST_CHIRP_GEN_DIR)/include @@ -52,10 +55,14 @@ $(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(CXXBRIDGE) $< --header -o $@; \ fi +$(LIBCXXBRIDGE_H): $(CXXBRIDGE) + $(AM_V_at)$(MKDIR_P) $(@D) + $(AM_V_GEN)$(CXXBRIDGE) --header -o $@ + cxxbridge-clean-chirp: $(AM_V_at)rm -rf $(LIBRUST_CHIRP_GEN_DIR) -cxxbridge-chirp: $(LIBRUST_CHIRP_CPP) $(LIBRUST_CHIRP_H) +cxxbridge-chirp: $(LIBRUST_CHIRP_CPP) $(LIBRUST_CHIRP_H) $(LIBCXXBRIDGE_H) dist-chirp: cxxbridge-chirp $(MKDIR_P) $(distdir)/chirp/gen/src diff --git a/rust/Makefile.common.include b/rust/Makefile.common.include index eb64e2fa8055..d5cdf3259294 100644 --- a/rust/Makefile.common.include +++ b/rust/Makefile.common.include @@ -10,8 +10,8 @@ CARGO_ENV = \ RUSTC="$(RUSTC)" \ RUSTFLAGS="$(RUSTFLAGS)" \ TERM="dumb" \ - ${RUST_OSX_SDK+SDKROOT="$(RUST_OSX_SDK)"} \ - ${RUSTUP_TOOLCHAIN+RUSTUP_TOOLCHAIN="$(RUSTUP_TOOLCHAIN)"} + $(if $(RUST_OSX_SDK),SDKROOT="$(RUST_OSX_SDK)") \ + $(if $(RUSTUP_TOOLCHAIN),RUSTUP_TOOLCHAIN="$(RUSTUP_TOOLCHAIN)") # 'cargo' needs uppercase RUST_NATIVE_ENV_UPPER = $(shell echo '$(RUST_NATIVE)' | tr 'a-z-' 'A-Z_') diff --git a/rust/Makefile.libs.include b/rust/Makefile.libs.include index b637dc1c0436..9f74b0efa2ff 100644 --- a/rust/Makefile.libs.include +++ b/rust/Makefile.libs.include @@ -24,6 +24,7 @@ LIBRUSTDEPS_CPP = \ $(LIBRUST_CHIRP_CPP) LIBRUSTDEPS_H = \ + $(LIBCXXBRIDGE_H) \ $(LIBRUST_CHIRP_H) # Umbrella staticlib # From 25ff38d928fd91165aca441520b937590a2c57fd Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 14:36:18 -0500 Subject: [PATCH 30/60] build: populate Rust source cache --- .github/workflows/cache-depends-sources.yml | 4 ++-- depends/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cache-depends-sources.yml b/.github/workflows/cache-depends-sources.yml index 122851d8cd72..cb97137f5faf 100644 --- a/.github/workflows/cache-depends-sources.yml +++ b/.github/workflows/cache-depends-sources.yml @@ -31,10 +31,10 @@ jobs: uses: actions/cache@v5 with: path: depends/sources - key: depends-sources-${{ hashFiles('depends/packages/*') }} + key: depends-sources-${{ hashFiles('depends/packages/*', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} restore-keys: depends-sources- lookup-only: true - name: Download sources if: steps.cache-check.outputs.cache-hit != 'true' - run: make -C depends download + run: make -C depends RUST=1 download diff --git a/depends/Makefile b/depends/Makefile index 20f3dce5a365..0320d56df201 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -188,7 +188,7 @@ native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_nativ ifeq ($(RUST),1) packages += $(rust_packages) native_packages += $(rust_native_packages) -rust_download_target = download-rust-std +rust_download_targets = download-rust-std vendor-crates endif native_cargo_packages = $(filter native_cxxbridge,$(native_packages)) @@ -359,7 +359,7 @@ download-rust-std: @mkdir -p $(SOURCES_PATH) @mkdir -p $(SOURCES_PATH)/download-stamps @$(foreach target,$(rust_stdlib_targets),$(call download_rust_std_target,$(target)) && ) true -download: download-osx download-linux download-win $(rust_download_target) +download: download-osx download-linux download-win $(rust_download_targets) $(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package)))) From fc2c7922855d605094792c0e96ccef900a7a5381 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 14:46:14 -0500 Subject: [PATCH 31/60] ci: align Rust source cache consumers --- .github/workflows/build-depends.yml | 2 +- .github/workflows/guix-build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-depends.yml b/.github/workflows/build-depends.yml index e79c5fa4248e..09f9520cb907 100644 --- a/.github/workflows/build-depends.yml +++ b/.github/workflows/build-depends.yml @@ -141,7 +141,7 @@ jobs: uses: actions/cache/restore@v5 with: path: depends/sources - key: depends-sources-${{ hashFiles('depends/packages/*') }} + key: depends-sources-${{ hashFiles('depends/packages/*', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} restore-keys: depends-sources- - name: Restore SDKs cache diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index 98ecc74afe9e..1ccd22ae9988 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -98,7 +98,7 @@ jobs: uses: actions/cache@v5 with: path: dash/depends/sources - key: depends-sources-${{ hashFiles('dash/depends/packages/*') }} + key: depends-sources-${{ hashFiles('dash/depends/packages/*', 'dash/depends/patches/native_cxxbridge/Cargo.lock', 'dash/Cargo.lock') }} restore-keys: | depends-sources- From 83a6aeb26ac911ec6cd0ff89181c9ac5c542e084 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:03:12 -0500 Subject: [PATCH 32/60] build: validate Rust toolchain selection --- configure.ac | 10 +++++++++- depends/config.site.in | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index feaa437c6f38..2abb9a2b27df 100644 --- a/configure.ac +++ b/configure.ac @@ -134,6 +134,7 @@ AC_PATH_PROG([CARGO], [cargo]) AC_PATH_PROG([CXXBRIDGE], [cxxbridge]) AC_PATH_PROG([RUSTC], [rustc]) CXXBRIDGE_REQUIRED_VERSION="1.0.198" +RUSTC_REQUIRED_VERSION="1.92.0" AC_ARG_VAR([CARGO_INCREMENTAL], [Enable incremental compilation for Rust]) if test "${CARGO_INCREMENTAL+set}" != "set"; then @@ -1779,6 +1780,13 @@ if test "$enable_rust" = "yes"; then AC_MSG_ERROR([cxxbridge $CXXBRIDGE_REQUIRED_VERSION is required by --enable-rust]) fi AC_MSG_RESULT([yes]) + AC_MSG_CHECKING([for rustc $RUSTC_REQUIRED_VERSION]) + rustc_version=`$RUSTC --version 2>/dev/null | cut -d ' ' -f 2` + if test "$rustc_version" != "$RUSTC_REQUIRED_VERSION"; then + AC_MSG_RESULT([no ($rustc_version)]) + AC_MSG_ERROR([rustc $RUSTC_REQUIRED_VERSION is required by --enable-rust]) + fi + AC_MSG_RESULT([yes]) if test "$enable_online_rust" = "no"; then if test -z "$RUST_VENDORED_SOURCES"; then AC_MSG_ERROR([--enable-rust requires RUST_VENDORED_SOURCES for offline builds or --enable-online-rust]) @@ -1811,7 +1819,7 @@ if test "$enable_rust" = "yes"; then AC_MSG_CHECKING([for Rust target]) rust_target_libc=gnu - if test -n "$depends_prefix"; then + if test -n "$depends_prefix" && test "$RUSTC" = "$depends_prefix/native/bin/rustc"; then rust_target_libc=musl fi RS_SET_TRIPLE([RUST_TARGET], [$host], [$rust_target_libc]) diff --git a/depends/config.site.in b/depends/config.site.in index b92dd22bb3ba..34b00d898daa 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -187,4 +187,6 @@ fi if test -x "${depends_prefix}/native/bin/cxxbridge"; then CXXBRIDGE="${depends_prefix}/native/bin/cxxbridge" fi -RUST_VENDORED_SOURCES="${depends_prefix}/vendored-sources" +if test -z "$RUST_VENDORED_SOURCES"; then + RUST_VENDORED_SOURCES="${depends_prefix}/vendored-sources" +fi From a0bf5907465f48898ec384806e6c8ee13b469333 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:03:12 -0500 Subject: [PATCH 33/60] ci: provide vendored crates to Rust source builds --- .github/workflows/build-src.yml | 9 +++++++++ .github/workflows/cache-depends-sources.yml | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-src.yml b/.github/workflows/build-src.yml index 47a757d3941e..b44f08f733b9 100644 --- a/.github/workflows/build-src.yml +++ b/.github/workflows/build-src.yml @@ -97,6 +97,15 @@ jobs: exit 1 shell: bash + - name: Restore Rust vendor sources + if: inputs.build-target == 'linux64_rust' + uses: actions/cache/restore@v5 + with: + path: | + depends/sources/native_cxxbridge-*-vendored.tar.gz + depends/sources/vendored-crates-*.tar.gz + key: depends-rust-vendor-sources-${{ hashFiles('depends/Makefile', 'depends/funcs.mk', 'depends/packages/native_cxxbridge.mk', 'depends/packages/native_rust.mk', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} + - name: Restore depends cache id: depends-cache uses: actions/cache/restore@v5 diff --git a/.github/workflows/cache-depends-sources.yml b/.github/workflows/cache-depends-sources.yml index cb97137f5faf..0af73b16d1bb 100644 --- a/.github/workflows/cache-depends-sources.yml +++ b/.github/workflows/cache-depends-sources.yml @@ -35,6 +35,17 @@ jobs: restore-keys: depends-sources- lookup-only: true + - name: Cache Rust vendor sources + id: rust-vendor-cache + uses: actions/cache@v5 + with: + path: | + depends/sources/native_cxxbridge-*-vendored.tar.gz + depends/sources/vendored-crates-*.tar.gz + key: depends-rust-vendor-sources-${{ hashFiles('depends/Makefile', 'depends/funcs.mk', 'depends/packages/native_cxxbridge.mk', 'depends/packages/native_rust.mk', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} + - name: Download sources - if: steps.cache-check.outputs.cache-hit != 'true' + if: | + steps.cache-check.outputs.cache-hit != 'true' || + steps.rust-vendor-cache.outputs.cache-hit != 'true' run: make -C depends RUST=1 download From 2fdf0b8486753baafeffbe837ab8a23fd90ee89c Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:15:15 -0500 Subject: [PATCH 34/60] build: support canonical ARMv7 Rust targets --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2abb9a2b27df..f9924dc28c06 100644 --- a/configure.ac +++ b/configure.ac @@ -1750,7 +1750,7 @@ AC_DEFUN([RS_SET_TRIPLE], [ x86_64-*-freebsd*) $1="x86_64-unknown-freebsd" ;; aarch64-*-linux*|arm64-*-linux*) $1="aarch64-unknown-linux-$3" ;; - arm-*-linux*) $1="armv7-unknown-linux-$3eabihf" ;; + arm*-*-linux*) $1="armv7-unknown-linux-$3eabihf" ;; powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-$3" ;; riscv64-*-linux*) $1="riscv64gc-unknown-linux-$3" ;; From 6b62e3066e1f57db72dd871459c6da8782f1d607 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:15:16 -0500 Subject: [PATCH 35/60] build: reject stale generated Rust bridges --- rust/Makefile.chirp.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index fb50a5116ca4..137171c0b4fb 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -40,6 +40,7 @@ $(LIBRUST_CHIRP_SRCS): ; $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp && \ + test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $< && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp $@; \ else \ @@ -49,6 +50,7 @@ $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h && \ + test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $< && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h $@; \ else \ From 7900d20fb50c1c3d142fccb3e2e1ed57002f9cbc Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:27:53 -0500 Subject: [PATCH 36/60] build: preserve system Rust toolchain selection --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f9924dc28c06..6191de7ee182 100644 --- a/configure.ac +++ b/configure.ac @@ -1886,7 +1886,7 @@ if test "$enable_rust" = "yes"; then fi AC_MSG_RESULT([$NATIVE_CXX]) - if test -n "$depends_prefix"; then + if test -n "$depends_prefix" && test "$RUSTC" = "$depends_prefix/native/bin/rustc"; then RUSTUP_TOOLCHAIN="" fi fi From 9ad0760e640a269aeb93a0c6278ce2b1b77ac7ca Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:35:39 -0500 Subject: [PATCH 37/60] build: preserve native musl Rust targets --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 6191de7ee182..bca871d6af89 100644 --- a/configure.ac +++ b/configure.ac @@ -1819,6 +1819,9 @@ if test "$enable_rust" = "yes"; then AC_MSG_CHECKING([for Rust target]) rust_target_libc=gnu + case $host in + *-linux-musl*) rust_target_libc=musl ;; + esac if test -n "$depends_prefix" && test "$RUSTC" = "$depends_prefix/native/bin/rustc"; then rust_target_libc=musl fi From d05aa50fa479b444b1521789c732652ac8cdb20b Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 15:39:52 -0500 Subject: [PATCH 38/60] build: preserve native Rust host ABI --- configure.ac | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bca871d6af89..363f2ff1f4fe 100644 --- a/configure.ac +++ b/configure.ac @@ -1787,6 +1787,10 @@ if test "$enable_rust" = "yes"; then AC_MSG_ERROR([rustc $RUSTC_REQUIRED_VERSION is required by --enable-rust]) fi AC_MSG_RESULT([yes]) + rust_uses_depends=no + if test -n "$depends_prefix" && test "$RUSTC" = "$depends_prefix/native/bin/rustc"; then + rust_uses_depends=yes + fi if test "$enable_online_rust" = "no"; then if test -z "$RUST_VENDORED_SOURCES"; then AC_MSG_ERROR([--enable-rust requires RUST_VENDORED_SOURCES for offline builds or --enable-online-rust]) @@ -1822,7 +1826,7 @@ if test "$enable_rust" = "yes"; then case $host in *-linux-musl*) rust_target_libc=musl ;; esac - if test -n "$depends_prefix" && test "$RUSTC" = "$depends_prefix/native/bin/rustc"; then + if test "$rust_uses_depends" = "yes"; then rust_target_libc=musl fi RS_SET_TRIPLE([RUST_TARGET], [$host], [$rust_target_libc]) @@ -1852,7 +1856,13 @@ if test "$enable_rust" = "yes"; then esac AC_MSG_CHECKING([for Rust host]) - RS_SET_TRIPLE([RUST_NATIVE], [$build], [gnu]) + rust_native_libc=gnu + if test "$rust_uses_depends" = "no"; then + case $build in + *-linux-musl*) rust_native_libc=musl ;; + esac + fi + RS_SET_TRIPLE([RUST_NATIVE], [$build], [$rust_native_libc]) if test "$RUST_NATIVE" = ""; then if test "$cross_compiling" = "yes"; then AC_MSG_RESULT([unknown]) @@ -1889,7 +1899,7 @@ if test "$enable_rust" = "yes"; then fi AC_MSG_RESULT([$NATIVE_CXX]) - if test -n "$depends_prefix" && test "$RUSTC" = "$depends_prefix/native/bin/rustc"; then + if test "$rust_uses_depends" = "yes"; then RUSTUP_TOOLCHAIN="" fi fi From c594dda4497353ad96d81a1871f550f0b98f0285 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 16:05:02 -0500 Subject: [PATCH 39/60] build: harden Rust source provenance --- .github/workflows/build-depends.yml | 33 ++++++++++++++++++-- .github/workflows/build-src.yml | 20 ++++++++++++ .github/workflows/build.yml | 4 ++- .github/workflows/cache-depends-sources.yml | 34 +++++++++++++++++++-- .github/workflows/guix-build.yml | 4 +-- configure.ac | 1 + rust/Makefile.chirp.include | 16 ++++++++-- 7 files changed, 101 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-depends.yml b/.github/workflows/build-depends.yml index 09f9520cb907..7ff24d85e869 100644 --- a/.github/workflows/build-depends.yml +++ b/.github/workflows/build-depends.yml @@ -15,6 +15,11 @@ on: description: "Short hash of the CI base image manifest for cache busting" required: true type: string + rust-vendor-artifact: + description: "Artifact holding freshly generated Rust vendor archives" + required: false + type: string + default: "" runs-on: description: "Runner label to use (e.g., ubuntu-24.04 or ubuntu-24.04-arm)" required: true @@ -141,8 +146,32 @@ jobs: uses: actions/cache/restore@v5 with: path: depends/sources - key: depends-sources-${{ hashFiles('depends/packages/*', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} - restore-keys: depends-sources- + key: depends-sources-v2-${{ hashFiles('depends/packages/*', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} + restore-keys: depends-sources-v2- + + - name: Restore Rust vendor sources + id: rust-vendor-cache + if: inputs.build-target == 'linux64_rust' + uses: actions/cache/restore@v5 + with: + path: | + depends/sources/native_cxxbridge-*-vendored.tar.gz + depends/sources/vendored-crates-*.tar.gz + key: depends-rust-vendor-sources-${{ hashFiles('depends/Makefile', 'depends/funcs.mk', 'depends/packages/native_cxxbridge.mk', 'depends/packages/native_rust.mk', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} + + - name: Download Rust vendor sources + if: inputs.build-target == 'linux64_rust' && steps.rust-vendor-cache.outputs.cache-hit != 'true' && inputs.rust-vendor-artifact != '' + uses: actions/download-artifact@v8 + with: + name: ${{ inputs.rust-vendor-artifact }} + path: depends/sources + + - name: Check Rust vendor sources are present + if: inputs.build-target == 'linux64_rust' && steps.rust-vendor-cache.outputs.cache-hit != 'true' && inputs.rust-vendor-artifact == '' + run: | + echo "::error::Rust vendor source cache missed and no same-run artifact was provided" + exit 1 + shell: bash - name: Restore SDKs cache id: sdk-cache diff --git a/.github/workflows/build-src.yml b/.github/workflows/build-src.yml index b44f08f733b9..64608392dfe2 100644 --- a/.github/workflows/build-src.yml +++ b/.github/workflows/build-src.yml @@ -29,6 +29,11 @@ on: required: false type: string default: "" + rust-vendor-artifact: + description: "Artifact holding freshly generated Rust vendor archives" + required: false + type: string + default: "" sdk-artifact: description: "Artifact holding prepared SDKs, used if the cache restore misses" required: false @@ -98,6 +103,7 @@ jobs: shell: bash - name: Restore Rust vendor sources + id: rust-vendor-cache if: inputs.build-target == 'linux64_rust' uses: actions/cache/restore@v5 with: @@ -106,6 +112,20 @@ jobs: depends/sources/vendored-crates-*.tar.gz key: depends-rust-vendor-sources-${{ hashFiles('depends/Makefile', 'depends/funcs.mk', 'depends/packages/native_cxxbridge.mk', 'depends/packages/native_rust.mk', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} + - name: Download Rust vendor sources + if: inputs.build-target == 'linux64_rust' && steps.rust-vendor-cache.outputs.cache-hit != 'true' && inputs.rust-vendor-artifact != '' + uses: actions/download-artifact@v8 + with: + name: ${{ inputs.rust-vendor-artifact }} + path: depends/sources + + - name: Check Rust vendor sources are present + if: inputs.build-target == 'linux64_rust' && steps.rust-vendor-cache.outputs.cache-hit != 'true' && inputs.rust-vendor-artifact == '' + run: | + echo "::error::Rust vendor source cache missed and no same-run artifact was provided" + exit 1 + shell: bash + - name: Restore depends cache id: depends-cache uses: actions/cache/restore@v5 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13fdf87119de..0ee3c4b93e3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,6 +150,7 @@ jobs: build-target: linux64_rust container-path: ${{ needs.container.outputs.path }} base-image-digest: ${{ needs.check-skip.outputs.base-image-digest }} + rust-vendor-artifact: ${{ needs.cache-sources.outputs.rust-vendor-artifact }} runs-on: ${{ needs.check-skip.outputs['runner-amd64'] }} depends-linux64_multiprocess: @@ -236,7 +237,7 @@ jobs: src-linux64_rust: name: linux64_rust-build uses: ./.github/workflows/build-src.yml - needs: [check-skip, container, depends-linux64_rust] + needs: [check-skip, container, cache-sources, depends-linux64_rust] if: ${{ vars.SKIP_LINUX64_RUST == '' }} with: build-target: linux64_rust @@ -245,6 +246,7 @@ jobs: depends-host: ${{ needs.depends-linux64_rust.outputs.host }} depends-dep-opts: ${{ needs.depends-linux64_rust.outputs.dep-opts }} depends-artifact: ${{ needs.depends-linux64_rust.outputs.built-artifact }} + rust-vendor-artifact: ${{ needs.cache-sources.outputs.rust-vendor-artifact }} runs-on: ${{ needs.check-skip.outputs['runner-amd64'] }} src-linux64_asan: diff --git a/.github/workflows/cache-depends-sources.yml b/.github/workflows/cache-depends-sources.yml index 0af73b16d1bb..bffbe357d1cf 100644 --- a/.github/workflows/cache-depends-sources.yml +++ b/.github/workflows/cache-depends-sources.yml @@ -8,6 +8,10 @@ on: required: false type: string default: ubuntu-24.04-arm + outputs: + rust-vendor-artifact: + description: "Artifact holding freshly generated Rust vendor archives" + value: ${{ jobs.cache-sources.outputs.rust-vendor-artifact }} schedule: # Run daily at 6 AM UTC on the default branch to keep cache warm - cron: '0 6 * * *' @@ -18,6 +22,8 @@ jobs: # Intentionally keep scheduled cache warming on GitHub-hosted ARM runners. # Blacksmith caches are expected to persist long enough without a warmup cron. runs-on: ${{ inputs.runs-on || 'ubuntu-24.04-arm' }} + outputs: + rust-vendor-artifact: ${{ steps.vendor-artifact.outputs.name }} steps: - name: Checkout code uses: actions/checkout@v6 @@ -31,8 +37,8 @@ jobs: uses: actions/cache@v5 with: path: depends/sources - key: depends-sources-${{ hashFiles('depends/packages/*', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} - restore-keys: depends-sources- + key: depends-sources-v2-${{ hashFiles('depends/packages/*', 'depends/patches/native_cxxbridge/Cargo.lock', 'Cargo.lock') }} + restore-keys: depends-sources-v2- lookup-only: true - name: Cache Rust vendor sources @@ -48,4 +54,26 @@ jobs: if: | steps.cache-check.outputs.cache-hit != 'true' || steps.rust-vendor-cache.outputs.cache-hit != 'true' - run: make -C depends RUST=1 download + run: | + make -C depends RUST=1 download + # The cache producer normally runs on ARM, while the Rust consumer + # runs on x86_64. Native Rust is selected from the build architecture, + # so fetch the x86_64 compiler archive explicitly as well. + make -C depends BUILD=x86_64-pc-linux-gnu RUST=1 download-one + + - name: Select Rust vendor artifact + id: vendor-artifact + if: github.event_name != 'schedule' && steps.rust-vendor-cache.outputs.cache-hit != 'true' + run: echo "name=depends-rust-vendor-sources-${{ github.run_id }}" >> "$GITHUB_OUTPUT" + + - name: Upload Rust vendor sources + if: steps.vendor-artifact.outputs.name != '' + uses: actions/upload-artifact@v6 + with: + name: ${{ steps.vendor-artifact.outputs.name }} + path: | + depends/sources/native_cxxbridge-*-vendored.tar.gz + depends/sources/vendored-crates-*.tar.gz + compression-level: 0 + retention-days: 1 + overwrite: true diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index 1ccd22ae9988..43148945783b 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -98,9 +98,9 @@ jobs: uses: actions/cache@v5 with: path: dash/depends/sources - key: depends-sources-${{ hashFiles('dash/depends/packages/*', 'dash/depends/patches/native_cxxbridge/Cargo.lock', 'dash/Cargo.lock') }} + key: depends-sources-v2-${{ hashFiles('dash/depends/packages/*', 'dash/depends/patches/native_cxxbridge/Cargo.lock', 'dash/Cargo.lock') }} restore-keys: | - depends-sources- + depends-sources-v2- - name: Cache Guix and depends id: guix-cache-restore diff --git a/configure.ac b/configure.ac index 363f2ff1f4fe..c72e14dcfdac 100644 --- a/configure.ac +++ b/configure.ac @@ -135,6 +135,7 @@ AC_PATH_PROG([CXXBRIDGE], [cxxbridge]) AC_PATH_PROG([RUSTC], [rustc]) CXXBRIDGE_REQUIRED_VERSION="1.0.198" RUSTC_REQUIRED_VERSION="1.92.0" +AC_SUBST([CXXBRIDGE_REQUIRED_VERSION]) AC_ARG_VAR([CARGO_INCREMENTAL], [Enable incremental compilation for Rust]) if test "${CARGO_INCREMENTAL+set}" != "set"; then diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 137171c0b4fb..71f97c9b4f93 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -10,6 +10,8 @@ LIBRUST_CHIRP_CRATE_DIR = $(top_srcdir)/rust/chirp LIBRUST_CHIRP_GEN_DIR = $(abs_top_builddir)/rust/chirp/gen LIBRUST_CHIRP_GEN_SRCDIR = $(abs_top_srcdir)/rust/chirp/gen +LIBRUST_CHIRP_GEN_STAMP = $(LIBRUST_CHIRP_GEN_DIR)/.cxxbridge-@CXXBRIDGE_REQUIRED_VERSION@ +LIBRUST_CHIRP_GEN_SRCSTAMP = $(LIBRUST_CHIRP_GEN_SRCDIR)/.cxxbridge-@CXXBRIDGE_REQUIRED_VERSION@ LIBRUST_CHIRP_MANIFEST = $(LIBRUST_CHIRP_CRATE_DIR)/Cargo.toml LIBRUST_CHIRP_SRCS = \ @@ -37,27 +39,34 @@ LIBRUST_CHIRP_FILES = \ $(LIBRUST_CHIRP_SRCS): ; -$(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) +$(LIBRUST_CHIRP_GEN_STAMP): $(CXXBRIDGE) + $(AM_V_at)$(MKDIR_P) $(@D) + $(AM_V_at)rm -f $(@D)/.cxxbridge-* + $(AM_V_at)touch $@ + +$(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $< && \ + test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp $@; \ else \ $(CXXBRIDGE) $< -o $@; \ fi -$(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) +$(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $< && \ + test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h $@; \ else \ $(CXXBRIDGE) $< --header -o $@; \ fi -$(LIBCXXBRIDGE_H): $(CXXBRIDGE) +$(LIBCXXBRIDGE_H): $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)$(CXXBRIDGE) --header -o $@ @@ -71,5 +80,6 @@ dist-chirp: cxxbridge-chirp $(MKDIR_P) $(distdir)/chirp/gen/include/rust/chirp cp $(LIBRUST_CHIRP_CPP) $(distdir)/chirp/gen/src/ cp $(LIBRUST_CHIRP_H) $(distdir)/chirp/gen/include/rust/chirp/ + cp $(LIBRUST_CHIRP_GEN_STAMP) $(distdir)/chirp/gen/ .PHONY: cxxbridge-chirp cxxbridge-clean-chirp dist-chirp From 88d0e2fa81530dfae86498e4ac55ff471c1139e2 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 16:16:40 -0500 Subject: [PATCH 40/60] fix: require matching bridge generator stamp --- rust/Makefile.chirp.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 71f97c9b4f93..3f5973ee3561 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -47,6 +47,7 @@ $(LIBRUST_CHIRP_GEN_STAMP): $(CXXBRIDGE) $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp && \ + test -f $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $< && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ @@ -58,6 +59,7 @@ $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h && \ + test -f $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $< && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ From 043706d12184069baa51a267b8744124c409f8c0 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 17:16:44 -0500 Subject: [PATCH 41/60] fix: preserve ARM Rust floating-point ABI --- configure.ac | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index c72e14dcfdac..796923cab93b 100644 --- a/configure.ac +++ b/configure.ac @@ -1739,6 +1739,7 @@ if test "$use_zmq" = "yes"; then fi AC_DEFUN([RS_SET_TRIPLE], [ + rs_triple_libc=$3 case $2 in aarch64-*-linux-android*) $1="aarch64-linux-android" ;; @@ -1750,12 +1751,14 @@ AC_DEFUN([RS_SET_TRIPLE], [ $1="x86_64-linux-android" ;; x86_64-*-freebsd*) $1="x86_64-unknown-freebsd" ;; aarch64-*-linux*|arm64-*-linux*) - $1="aarch64-unknown-linux-$3" ;; - arm*-*-linux*) $1="armv7-unknown-linux-$3eabihf" ;; + $1="aarch64-unknown-linux-${rs_triple_libc}" ;; + arm*-*-linux-*eabihf) $1="armv7-unknown-linux-${rs_triple_libc}eabihf" ;; + arm*-*-linux-*eabi) $1="armv7-unknown-linux-${rs_triple_libc}eabi" ;; + arm*-*-linux*) $1="armv7-unknown-linux-${rs_triple_libc}eabihf" ;; powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; - powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-$3" ;; - riscv64-*-linux*) $1="riscv64gc-unknown-linux-$3" ;; - x86_64-*-linux*) $1="x86_64-unknown-linux-$3" ;; + powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-${rs_triple_libc}" ;; + riscv64-*-linux*) $1="riscv64gc-unknown-linux-${rs_triple_libc}" ;; + x86_64-*-linux*) $1="x86_64-unknown-linux-${rs_triple_libc}" ;; x86_64-*-darwin*) $1="x86_64-apple-darwin" ;; aarch64-*-darwin*|arm64-*-darwin*) $1="aarch64-apple-darwin" ;; From cb4e8fa1ab6556218b468b17f5793547e0dcb6bf Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 17:31:16 -0500 Subject: [PATCH 42/60] fix: support Rust on 32-bit Linux --- configure.ac | 1 + contrib/devtools/update-rust-hashes.py | 1 + depends/packages/rust_stdlib.mk | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 796923cab93b..b513889751a6 100644 --- a/configure.ac +++ b/configure.ac @@ -1758,6 +1758,7 @@ AC_DEFUN([RS_SET_TRIPLE], [ powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-${rs_triple_libc}" ;; riscv64-*-linux*) $1="riscv64gc-unknown-linux-${rs_triple_libc}" ;; + i?86-*-linux*) $1="i686-unknown-linux-${rs_triple_libc}" ;; x86_64-*-linux*) $1="x86_64-unknown-linux-${rs_triple_libc}" ;; x86_64-*-darwin*) $1="x86_64-apple-darwin" ;; aarch64-*-darwin*|arm64-*-darwin*) diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index adb78a0948b0..3a5a7d697aa1 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -23,6 +23,7 @@ # Linux "aarch64-unknown-linux-musl", "armv7-unknown-linux-musleabihf", + "i686-unknown-linux-musl", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-musl", diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index de7e0bcc3705..750290d71fd4 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -47,6 +47,12 @@ $(package)_targets += aarch64-unknown-linux-musl $(package)_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-musl $(package)_sha256_hash_aarch64-unknown-linux-musl:=715fbcfd8712c723947a020d0371c8a1a21f7531f2b696aeaed50ac23ba675c9 +# Linux (x86 32-bit) +$(package)_targets += i686-unknown-linux-musl +$(package)_target_i686-pc-linux-gnu:=i686-unknown-linux-musl +$(package)_target_i686-unknown-linux-gnu:=i686-unknown-linux-musl +$(package)_sha256_hash_i686-unknown-linux-musl:=3d6ccb700a17533eea10c7541896c92817783045c5537af37228142da7668fb3 + # Linux (PowerPC 64-bit little-endian) $(package)_targets += powerpc64le-unknown-linux-musl $(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-musl From 1427f5be40013b5a3754551be3f11adca4b3ac7f Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 17:31:16 -0500 Subject: [PATCH 43/60] ci: isolate Guix source cache --- .github/workflows/guix-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index 43148945783b..98ecc74afe9e 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -98,9 +98,9 @@ jobs: uses: actions/cache@v5 with: path: dash/depends/sources - key: depends-sources-v2-${{ hashFiles('dash/depends/packages/*', 'dash/depends/patches/native_cxxbridge/Cargo.lock', 'dash/Cargo.lock') }} + key: depends-sources-${{ hashFiles('dash/depends/packages/*') }} restore-keys: | - depends-sources-v2- + depends-sources- - name: Cache Guix and depends id: guix-cache-restore From 93325c0d0312809c4f15071cb8a8d44162d4173d Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 17:39:23 -0500 Subject: [PATCH 44/60] fix: provision soft-float ARM Rust stdlib --- contrib/devtools/update-rust-hashes.py | 1 + depends/packages/rust_stdlib.mk | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 3a5a7d697aa1..5e8795e8f2ae 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -22,6 +22,7 @@ "x86_64-unknown-freebsd", # Linux "aarch64-unknown-linux-musl", + "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf", "i686-unknown-linux-musl", "powerpc64-unknown-linux-gnu", diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index 750290d71fd4..c3d08a063da0 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -37,9 +37,13 @@ $(package)_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd $(package)_sha256_hash_x86_64-unknown-freebsd:=3616afb808cd030e65e66c51f6f0fb6a6fc52d877d0d70bb681b0c35238adbe8 # Linux (ARMv7) +$(package)_targets += armv7-unknown-linux-musleabi $(package)_targets += armv7-unknown-linux-musleabihf +$(package)_target_arm-unknown-linux-gnueabi:=armv7-unknown-linux-musleabi $(package)_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf +$(package)_target_armv7-unknown-linux-gnueabi:=armv7-unknown-linux-musleabi $(package)_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf +$(package)_sha256_hash_armv7-unknown-linux-musleabi:=3bf1b0015dc3b0f5f6f5622588431855c658d5c47093f24e4077f6893229ab30 $(package)_sha256_hash_armv7-unknown-linux-musleabihf:=fc5c4ca757599caab8e93000becb9d57587088d32dab5c4f3b253f00ec3a2fd6 # Linux (ARMv8) From cbf098b578cb199150d6e61fd7026d43753a6c69 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 17:41:58 -0500 Subject: [PATCH 45/60] fix: reject unsupported Rust stdlib targets --- depends/packages/rust_stdlib.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index c3d08a063da0..7f2fd34ffb73 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -94,6 +94,10 @@ $(package)_targets += x86_64-pc-windows-gnu $(package)_target_x86_64-w64-mingw32:=x86_64-pc-windows-gnu $(package)_sha256_hash_x86_64-pc-windows-gnu:=6256f3497e3b14b6650511e84fdfb51fc632db1908ae5a173dffcdc96c80b7ce +ifeq ($($(package)_target),) +$(error Unsupported Rust standard library target: $(canonical_host)) +endif + $(package)_file_name=rust-std-$($(package)_version)-$($(package)_target).tar.gz $(package)_sha256_hash=$($(package)_sha256_hash_$($(package)_target)) From 3bf1f7958c79b0fd0e609293fdaf7887784e226a Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 17:51:22 -0500 Subject: [PATCH 46/60] fix: preserve system PowerPC Rust ABI --- configure.ac | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b513889751a6..56060ab3e0ed 100644 --- a/configure.ac +++ b/configure.ac @@ -1755,7 +1755,7 @@ AC_DEFUN([RS_SET_TRIPLE], [ arm*-*-linux-*eabihf) $1="armv7-unknown-linux-${rs_triple_libc}eabihf" ;; arm*-*-linux-*eabi) $1="armv7-unknown-linux-${rs_triple_libc}eabi" ;; arm*-*-linux*) $1="armv7-unknown-linux-${rs_triple_libc}eabihf" ;; - powerpc64-*-linux*) $1="powerpc64-unknown-linux-gnu" ;; + powerpc64-*-linux*) $1="powerpc64-unknown-linux-${rs_triple_libc}" ;; powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-${rs_triple_libc}" ;; riscv64-*-linux*) $1="riscv64gc-unknown-linux-${rs_triple_libc}" ;; i?86-*-linux*) $1="i686-unknown-linux-${rs_triple_libc}" ;; @@ -1832,7 +1832,10 @@ if test "$enable_rust" = "yes"; then *-linux-musl*) rust_target_libc=musl ;; esac if test "$rust_uses_depends" = "yes"; then - rust_target_libc=musl + case $host in + powerpc64-*-linux*) rust_target_libc=gnu ;; + *) rust_target_libc=musl ;; + esac fi RS_SET_TRIPLE([RUST_TARGET], [$host], [$rust_target_libc]) if test "$RUST_TARGET" = ""; then From 1bbef7d687deddad5a6c9248c438bda59ab6c2a6 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:05:49 -0500 Subject: [PATCH 47/60] fix: make Rust vendor setup retryable --- depends/Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/depends/Makefile b/depends/Makefile index 0320d56df201..de1fad05b415 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -65,6 +65,7 @@ CRATE_REGISTRY := vendored-sources CRATE_LOCK = $(BASEDIR)/../Cargo.lock CRATE_LOCK_HASH = $(shell $(build_SHA256SUM) $(CRATE_LOCK) | cut -c-$(HASH_LENGTH)) CRATE_ARCHIVE = $(SOURCES_PATH)/vendored-crates-$(CRATE_LOCK_HASH).tar.gz +CRATE_REGISTRY_STAMP = $(host_prefix)/.$(CRATE_REGISTRY).stamp ifneq ($(DEBUG),) release_type=debug @@ -220,13 +221,15 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) # Vendors Rust crate dependencies for offline builds # Uses pre-built archive if available, otherwise runs 'cargo vendor' -$(host_prefix)/$(CRATE_REGISTRY): $(host_prefix)/.stamp_$(final_build_id) $(CRATE_LOCK) +$(CRATE_REGISTRY_STAMP): $(host_prefix)/.stamp_$(final_build_id) $(CRATE_LOCK) + @rm -rf $(host_prefix)/$(CRATE_REGISTRY) @if test -f $(CRATE_ARCHIVE); \ then echo Extracting pre-vendored crates from $(CRATE_ARCHIVE)...; \ - $(build_TAR) --no-same-owner -xf $(CRATE_ARCHIVE) -C $(@D); \ + $(build_TAR) --no-same-owner -xf $(CRATE_ARCHIVE) -C $(host_prefix); \ else echo Vendoring crates...; \ - $(@D)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $@; \ + $(host_prefix)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(host_prefix)/$(CRATE_REGISTRY); \ fi + @test -d $(host_prefix)/$(CRATE_REGISTRY) @touch $@ # Vendors crates for cargo packages @@ -341,7 +344,7 @@ clean: @rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) *.log ifeq ($(RUST),1) -install: check-packages $(host_prefix)/share/config.site $(host_prefix)/$(CRATE_REGISTRY) +install: check-packages $(host_prefix)/share/config.site $(CRATE_REGISTRY_STAMP) else install: check-packages $(host_prefix)/share/config.site endif From 0afa9e49d8eded7d5581ef12b766197f222ac4ca Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:05:49 -0500 Subject: [PATCH 48/60] fix: preserve developer Cargo configuration --- .gitignore | 1 + rust/Makefile.am | 3 +-- rust/Makefile.common.include | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 722e46abedfd..e6638debe3e7 100644 --- a/.gitignore +++ b/.gitignore @@ -190,6 +190,7 @@ perf.data.old /.cargo/.configured-for-* /.cargo/config /.cargo/config.toml +/.cargo/dash-build.toml /.cargo/*-linker # These are backup files generated by rustfmt diff --git a/rust/Makefile.am b/rust/Makefile.am index a007ff547599..6664efd64d02 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -32,8 +32,7 @@ endif cargo-clean-config: $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)rm -f $(CARGO_BUILD_CONFIG) $(AM_V_at)rm -f $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) clean-local: cargo-clean-dashrust cxxbridge-clean-chirp cargo-clean-config diff --git a/rust/Makefile.common.include b/rust/Makefile.common.include index d5cdf3259294..5b6ea08e23fc 100644 --- a/rust/Makefile.common.include +++ b/rust/Makefile.common.include @@ -4,6 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. CARGO_BUILD_OPTS = --locked --target $(RUST_TARGET) +CARGO_BUILD_CONFIG = $(abs_top_builddir)/.cargo/dash-build.toml CARGO_ENV = \ MACOSX_DEPLOYMENT_TARGET="$(RUST_MACOS_DEPLOYMENT_TARGET)" \ CARGO_INCREMENTAL="$(CARGO_INCREMENTAL)" \ @@ -58,20 +59,17 @@ CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-online $(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-offline - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config + $(AM_V_at)rm -f $(CARGO_BUILD_CONFIG) $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo $(AM_V_at)touch $@ else -CARGO_BUILD_OPTS += --offline -CARGO_CONFIGURED = $(abs_top_builddir)/.cargo/.configured-for-offline +CARGO_BUILD_OPTS += --offline --config "$(CARGO_BUILD_CONFIG)" +CARGO_CONFIGURED = $(CARGO_BUILD_CONFIG) $(CARGO_CONFIGURED): $(RUST_NATIVE_LINKER) $(RUST_TARGET_LINKER) $(top_srcdir)/.cargo/config.toml.offline $(top_srcdir)/Cargo.lock $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/.configured-for-online - $(AM_V_at)rm -f $(abs_top_builddir)/.cargo/config $(AM_V_at)$(MKDIR_P) $(abs_top_builddir)/.cargo - $(AM_V_at)cp $(top_srcdir)/.cargo/config.toml.offline $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)$(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh $(top_srcdir)/Cargo.lock >> $(abs_top_builddir)/.cargo/config.toml - $(AM_V_at)touch $@ + $(AM_V_at)cp $(top_srcdir)/.cargo/config.toml.offline $(CARGO_BUILD_CONFIG) + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >> $(CARGO_BUILD_CONFIG) + $(AM_V_at)$(top_srcdir)/contrib/devtools/cargo-vendor-git-sources.sh $(top_srcdir)/Cargo.lock >> $(CARGO_BUILD_CONFIG) endif # ENABLE_ONLINE_RUST From f5ebb59c302a098c284a0e771f4f76abfba2e222 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:16:14 -0500 Subject: [PATCH 49/60] build: require matching Cargo toolchain --- configure.ac | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 56060ab3e0ed..639a5e676c2a 100644 --- a/configure.ac +++ b/configure.ac @@ -135,6 +135,7 @@ AC_PATH_PROG([CXXBRIDGE], [cxxbridge]) AC_PATH_PROG([RUSTC], [rustc]) CXXBRIDGE_REQUIRED_VERSION="1.0.198" RUSTC_REQUIRED_VERSION="1.92.0" +CARGO_REQUIRED_VERSION="$RUSTC_REQUIRED_VERSION" AC_SUBST([CXXBRIDGE_REQUIRED_VERSION]) AC_ARG_VAR([CARGO_INCREMENTAL], [Enable incremental compilation for Rust]) @@ -1785,6 +1786,13 @@ if test "$enable_rust" = "yes"; then AC_MSG_ERROR([cxxbridge $CXXBRIDGE_REQUIRED_VERSION is required by --enable-rust]) fi AC_MSG_RESULT([yes]) + AC_MSG_CHECKING([for cargo $CARGO_REQUIRED_VERSION]) + cargo_version=`$CARGO --version 2>/dev/null | cut -d ' ' -f 2` + if test "$cargo_version" != "$CARGO_REQUIRED_VERSION"; then + AC_MSG_RESULT([no ($cargo_version)]) + AC_MSG_ERROR([cargo $CARGO_REQUIRED_VERSION is required by --enable-rust]) + fi + AC_MSG_RESULT([yes]) AC_MSG_CHECKING([for rustc $RUSTC_REQUIRED_VERSION]) rustc_version=`$RUSTC --version 2>/dev/null | cut -d ' ' -f 2` if test "$rustc_version" != "$RUSTC_REQUIRED_VERSION"; then From fbff0157f10c90e620d7656e8d7b39eda1a259b6 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:16:14 -0500 Subject: [PATCH 50/60] build: hash external depends recipe helpers --- depends/funcs.mk | 2 +- depends/packages/native_cxxbridge.mk | 1 + depends/packages/native_rust.mk | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/depends/funcs.mk b/depends/funcs.mk index 4fa1585a883b..cf8228c06b17 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -41,7 +41,7 @@ define fetch_file endef define int_get_build_recipe_hash -$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) | cut -d" " -f1)) +$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) $($(1)_extra_recipe_files) | cut -d" " -f1)) $(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1)) endef diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk index 11e9a91f0cd2..4822df59c6d7 100644 --- a/depends/packages/native_cxxbridge.mk +++ b/depends/packages/native_cxxbridge.mk @@ -14,6 +14,7 @@ $(package)_sha256_hash:=e8c54f11e12b00f80a7da8cc2eac55db5c4688cb2bc483f5e923261f $(package)_build_subdir:=bridge/cmd $(package)_dependencies:=native_rust $(package)_patches:=Cargo.lock cargo-config.toml +$(package)_extra_recipe_files:=$(PATCHES_PATH)/native_rust/fix-elf-interpreter.sh $(package)_vendored_file_name:=native_cxxbridge-$($(package)_version)-vendored.tar.gz $(package)_cargo_manifest:=bridge/cmd/Cargo.toml diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index f7528d65f5b1..fa8fc856de37 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -9,6 +9,7 @@ package:=native_rust $(package)_version:=1.92.0 $(package)_download_path:=https://static.rust-lang.org/dist +$(package)_extra_recipe_files:=$(PATCHES_PATH)/native_rust/fix-elf-interpreter.sh # FreeBSD (x86_64) $(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz From 9c94e2c6e63c8608b274f82a292e07f0a322af48 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:26:00 -0500 Subject: [PATCH 51/60] build: scope Rust helper cache invalidation --- depends/funcs.mk | 2 +- depends/packages/native_cxxbridge.mk | 5 ++--- depends/packages/native_rust.mk | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/depends/funcs.mk b/depends/funcs.mk index cf8228c06b17..4fa1585a883b 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -41,7 +41,7 @@ define fetch_file endef define int_get_build_recipe_hash -$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) $($(1)_extra_recipe_files) | cut -d" " -f1)) +$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) | cut -d" " -f1)) $(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1)) endef diff --git a/depends/packages/native_cxxbridge.mk b/depends/packages/native_cxxbridge.mk index 4822df59c6d7..3c5a1cf15cf4 100644 --- a/depends/packages/native_cxxbridge.mk +++ b/depends/packages/native_cxxbridge.mk @@ -13,8 +13,7 @@ $(package)_download_file:=$($(package)_version).tar.gz $(package)_sha256_hash:=e8c54f11e12b00f80a7da8cc2eac55db5c4688cb2bc483f5e923261fa3a285bf $(package)_build_subdir:=bridge/cmd $(package)_dependencies:=native_rust -$(package)_patches:=Cargo.lock cargo-config.toml -$(package)_extra_recipe_files:=$(PATCHES_PATH)/native_rust/fix-elf-interpreter.sh +$(package)_patches:=Cargo.lock cargo-config.toml ../native_rust/fix-elf-interpreter.sh $(package)_vendored_file_name:=native_cxxbridge-$($(package)_version)-vendored.tar.gz $(package)_cargo_manifest:=bridge/cmd/Cargo.toml @@ -29,7 +28,7 @@ endef define $(package)_stage_cmds $($(package)_cargo) install --locked --path=. --bin=cxxbridge --root=$($(package)_staging_prefix_dir) && \ mkdir -p $($(package)_staging_prefix_dir)/lib && \ - bash $(BASEDIR)/patches/native_rust/fix-elf-interpreter.sh \ + bash $($(package)_patch_dir)/fix-elf-interpreter.sh \ $($(package)_staging_prefix_dir)/lib \ $($(package)_staging_prefix_dir)/bin/cxxbridge endef diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index fa8fc856de37..599c2ceac44f 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -9,7 +9,7 @@ package:=native_rust $(package)_version:=1.92.0 $(package)_download_path:=https://static.rust-lang.org/dist -$(package)_extra_recipe_files:=$(PATCHES_PATH)/native_rust/fix-elf-interpreter.sh +$(package)_patches:=fix-elf-interpreter.sh # FreeBSD (x86_64) $(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz @@ -51,7 +51,7 @@ define $(package)_stage_cmds cp rustc/bin/rustdoc $($(package)_staging_dir)/$(host_prefix)/native/bin/ && \ cp -r rustc/lib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/ && \ cp -r rust-std-*/lib/rustlib/* $($(package)_staging_dir)/$(host_prefix)/native/lib/rustlib/ && \ - bash $(BASEDIR)/patches/native_rust/fix-elf-interpreter.sh \ + bash $($(package)_patch_dir)/fix-elf-interpreter.sh \ $($(package)_staging_dir)/$(host_prefix)/native/lib \ $($(package)_staging_dir)/$(host_prefix)/native/bin/cargo \ $($(package)_staging_dir)/$(host_prefix)/native/bin/rustc \ From 684495e16dde8cab4d3b1cd3d5278541fb77cdf9 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:35:46 -0500 Subject: [PATCH 52/60] build: fix cxxbridge updater fetch guidance --- contrib/devtools/update-native-cxxbridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/devtools/update-native-cxxbridge.py b/contrib/devtools/update-native-cxxbridge.py index b056dac8d49c..0d81a1b15f45 100755 --- a/contrib/devtools/update-native-cxxbridge.py +++ b/contrib/devtools/update-native-cxxbridge.py @@ -36,7 +36,7 @@ def main() -> int: tarball_path = repo_root / f"depends/sources/native_cxxbridge-{version}.tar.gz" if not tarball_path.exists(): print(f"Error: {tarball_path} not found", file=sys.stderr) - print("Run 'make -C depends download-one PKG=native_cxxbridge' first", file=sys.stderr) + print("Run 'make -C depends RUST=1 native_cxxbridge_fetched' first", file=sys.stderr) return 1 toolchain_path = repo_root / "rust-toolchain.toml" From 9fa7a39d20b3e3158a0fbeb7890962b0ebd7927c Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:54:02 -0500 Subject: [PATCH 53/60] build: synchronize Rust updater version pins --- contrib/devtools/update-rust-hashes.py | 59 +++++++++++++++++--------- depends/packages/rust_stdlib.mk | 3 +- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 5e8795e8f2ae..1124531d53ef 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -48,6 +48,7 @@ ("x86_64-apple-darwin", "x86_64_darwin"), ] + def get_rust_version(makefile_path: Path) -> str: content = makefile_path.read_text() match = re.search(r"\$\(package\)_version:=(.+)", content) @@ -73,18 +74,25 @@ def update_hash_in_file(makefile_path: Path, pattern: str, new_hash: str) -> Non makefile_path.write_text(new_content) -def update_rust_hash(makefile_path: Path, rust_version: str, rust_target: str, makefile_id: str) -> None: +def update_version_in_file(path: Path, pattern: str, version: str) -> None: + content = path.read_text() + regex = re.compile(pattern, re.MULTILINE) + new_content, replacements = regex.subn( + lambda match: f"{match.group(1)}{version}{match.group(2) if match.lastindex == 2 else ''}", content + ) + if replacements != 1: + raise RuntimeError(f"Expected one version pin in {path}, found {replacements}") + path.write_text(new_content) + + +def compute_rust_hash(rust_version: str, rust_target: str) -> str: url = f"https://static.rust-lang.org/dist/rust-{rust_version}-{rust_target}.tar.gz" - hash_value = compute_sha256(url) - update_hash_in_file(makefile_path, f"sha256_hash_{makefile_id}", hash_value) - print(f" Updated sha256_hash_{makefile_id}") + return compute_sha256(url) -def update_stdlib_hash(makefile_path: Path, rust_version: str, rust_target: str) -> None: +def compute_stdlib_hash(rust_version: str, rust_target: str) -> str: url = f"https://static.rust-lang.org/dist/rust-std-{rust_version}-{rust_target}.tar.gz" - hash_value = compute_sha256(url) - update_hash_in_file(makefile_path, f"sha256_hash_{rust_target}", hash_value) - print(f" Updated sha256_hash_{rust_target}") + return compute_sha256(url) def main() -> int: @@ -93,26 +101,39 @@ def main() -> int: native_rust_path = native_rust_path.resolve() rust_stdlib_path = script_dir / "../../depends/packages/rust_stdlib.mk" rust_stdlib_path = rust_stdlib_path.resolve() + toolchain_path = (script_dir / "../../rust-toolchain.toml").resolve() + configure_path = (script_dir / "../../configure.ac").resolve() - if not native_rust_path.exists(): - print(f"Error: {native_rust_path} not found", file=sys.stderr) - return 1 - - if not rust_stdlib_path.exists(): - print(f"Error: {rust_stdlib_path} not found", file=sys.stderr) - return 1 + for path in (native_rust_path, rust_stdlib_path, toolchain_path, configure_path): + if not path.exists(): + print(f"Error: {path} not found", file=sys.stderr) + return 1 rust_version = get_rust_version(native_rust_path) print(f"Rust version: {rust_version}\n") - print("Updating native compiler hashes:") + print("Downloading native compiler hashes:") + native_hashes = {} for rust_target, makefile_id in NATIVE_TARGETS: - update_rust_hash(native_rust_path, rust_version, rust_target, makefile_id) + native_hashes[makefile_id] = compute_rust_hash(rust_version, rust_target) + print(f" Downloaded sha256_hash_{makefile_id}") - print("\nUpdating stdlib hashes:") + print("\nDownloading stdlib hashes:") + stdlib_hashes = {} for rust_target in CROSS_TARGETS: - update_stdlib_hash(rust_stdlib_path, rust_version, rust_target) + stdlib_hashes[rust_target] = compute_stdlib_hash(rust_version, rust_target) + print(f" Downloaded sha256_hash_{rust_target}") + + for makefile_id, hash_value in native_hashes.items(): + update_hash_in_file(native_rust_path, f"sha256_hash_{makefile_id}", hash_value) + for rust_target, hash_value in stdlib_hashes.items(): + update_hash_in_file(rust_stdlib_path, f"sha256_hash_{rust_target}", hash_value) + + update_version_in_file(rust_stdlib_path, r"^(\$\(package\)_version:=).*$", rust_version) + update_version_in_file(toolchain_path, r'^(channel = ")[^"]*(")$', rust_version) + update_version_in_file(configure_path, r'^(RUSTC_REQUIRED_VERSION=")[^"]*(")$', rust_version) + print("\nSynchronized rust_stdlib.mk, rust-toolchain.toml, and configure.ac") print("\nDone!") return 0 diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index 7f2fd34ffb73..335ba7a7e565 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -3,8 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -# To update the Rust stdlib, change the version below and then run the script -# ./contrib/devtools/update-rust-hashes.py +# This version is synchronized from native_rust.mk by update-rust-hashes.py. package:=rust_stdlib $(package)_version:=1.92.0 From f8fde5110abfa1799dfb9054b8ea6d72f5aac466 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:54:02 -0500 Subject: [PATCH 54/60] build: make cxxbridge updater self-contained --- contrib/devtools/update-native-cxxbridge.py | 62 +++++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/contrib/devtools/update-native-cxxbridge.py b/contrib/devtools/update-native-cxxbridge.py index 0d81a1b15f45..ea9a33b3a7e7 100755 --- a/contrib/devtools/update-native-cxxbridge.py +++ b/contrib/devtools/update-native-cxxbridge.py @@ -4,14 +4,17 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +import hashlib import re import shutil import subprocess import sys import tarfile import tempfile +import urllib.request from pathlib import Path + def get_cxx_version(makefile_path: Path) -> str: content = makefile_path.read_text() match = re.search(r"\$\(package\)_version:=(.+)", content) @@ -20,6 +23,42 @@ def get_cxx_version(makefile_path: Path) -> str: return match.group(1).strip() +def download_and_hash(url: str, dest: Path) -> str: + hasher = hashlib.sha256() + dest.parent.mkdir(parents=True, exist_ok=True) + temporary_path = None + try: + with tempfile.NamedTemporaryFile(dir=dest.parent, delete=False) as output: + temporary_path = Path(output.name) + with urllib.request.urlopen(url) as response: + while chunk := response.read(8192): + hasher.update(chunk) + output.write(chunk) + temporary_path.replace(dest) + except BaseException: + if temporary_path is not None: + temporary_path.unlink(missing_ok=True) + raise + return hasher.hexdigest() + + +def write_stamp(stamps_dir: Path, version: str, sha256: str, file_name: str) -> None: + stamps_dir.mkdir(parents=True, exist_ok=True) + stamp_path = stamps_dir / f".stamp_fetched-native_cxxbridge-{version}-{sha256}.hash" + stamp_path.write_text(f"{sha256} {file_name}\n") + + +def update_value_in_file(path: Path, pattern: str, value: str) -> None: + content = path.read_text() + regex = re.compile(pattern, re.MULTILINE) + new_content, replacements = regex.subn( + lambda match: f"{match.group(1)}{value}{match.group(2) if match.lastindex == 2 else ''}", content + ) + if replacements != 1: + raise RuntimeError(f"Expected one matching value in {path}, found {replacements}") + path.write_text(new_content) + + def main() -> int: script_dir = Path(__file__).resolve().parent repo_root = script_dir / "../.." @@ -33,11 +72,13 @@ def main() -> int: version = get_cxx_version(makefile_path) print(f"cxx version: {version}") - tarball_path = repo_root / f"depends/sources/native_cxxbridge-{version}.tar.gz" - if not tarball_path.exists(): - print(f"Error: {tarball_path} not found", file=sys.stderr) - print("Run 'make -C depends RUST=1 native_cxxbridge_fetched' first", file=sys.stderr) - return 1 + sources_dir = repo_root / "depends/sources" + file_name = f"native_cxxbridge-{version}.tar.gz" + tarball_path = sources_dir / file_name + url = f"https://github.com/dtolnay/cxx/archive/refs/tags/{version}.tar.gz" + print(f"Downloading {url}") + hash_value = download_and_hash(url, tarball_path) + print(f"sha256: {hash_value}") toolchain_path = repo_root / "rust-toolchain.toml" if not toolchain_path.exists(): @@ -88,6 +129,17 @@ def main() -> int: shutil.copy(cargo_lock_src, cargo_lock_dst) print(f"Copied Cargo.lock to {cargo_lock_dst}") + update_value_in_file(makefile_path, r"^(\$\(package\)_sha256_hash:=).*$", hash_value) + configure_path = repo_root / "configure.ac" + update_value_in_file(configure_path, r'^(CXXBRIDGE_REQUIRED_VERSION=")[^"]*(")$', version) + write_stamp(sources_dir / "download-stamps", version, hash_value, file_name) + + print("Updating the workspace cxx crates") + result = subprocess.run(["cargo", "update", "-p", "cxx", "--precise", version], cwd=repo_root) + if result.returncode != 0: + print("Error: workspace cargo update failed", file=sys.stderr) + return 1 + print("\nDone!") return 0 From a0cee6845e2f35b051f7d6007b8356b53c7de6b5 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 11 Aug 2026 18:55:18 -0500 Subject: [PATCH 55/60] build: avoid partial cxxbridge updater changes --- contrib/devtools/update-native-cxxbridge.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/devtools/update-native-cxxbridge.py b/contrib/devtools/update-native-cxxbridge.py index ea9a33b3a7e7..319fe9ada6b3 100755 --- a/contrib/devtools/update-native-cxxbridge.py +++ b/contrib/devtools/update-native-cxxbridge.py @@ -125,6 +125,12 @@ def main() -> int: print(f"Error: {cargo_lock_src} not found after cargo check", file=sys.stderr) return 1 + print("Updating the workspace cxx crates") + result = subprocess.run(["cargo", "update", "-p", "cxx", "--precise", version], cwd=repo_root) + if result.returncode != 0: + print("Error: workspace cargo update failed", file=sys.stderr) + return 1 + cargo_lock_dst.parent.mkdir(parents=True, exist_ok=True) shutil.copy(cargo_lock_src, cargo_lock_dst) print(f"Copied Cargo.lock to {cargo_lock_dst}") @@ -134,12 +140,6 @@ def main() -> int: update_value_in_file(configure_path, r'^(CXXBRIDGE_REQUIRED_VERSION=")[^"]*(")$', version) write_stamp(sources_dir / "download-stamps", version, hash_value, file_name) - print("Updating the workspace cxx crates") - result = subprocess.run(["cargo", "update", "-p", "cxx", "--precise", version], cwd=repo_root) - if result.returncode != 0: - print("Error: workspace cargo update failed", file=sys.stderr) - return 1 - print("\nDone!") return 0 From 4b2ec385b925b93764418107dca9c65dc1ef1a58 Mon Sep 17 00:00:00 2001 From: pasta Date: Wed, 12 Aug 2026 18:38:33 -0500 Subject: [PATCH 56/60] build: confine Rust support to validated hosts The Rust stdlib/target provisioning covered Android, FreeBSD, ARMv7, i686, PowerPC and more, inherited from the Zcash-derived tooling and later ABI-correctness fixes, even though only x86-64 Linux is CI-covered and Guix Rust builds are disabled. Presence in the build system implies a support commitment we cannot honor, and untested mappings can bitrot or emit broken binaries. Trim CROSS_TARGETS, rust_stdlib.mk, native_rust.mk and RS_SET_TRIPLE to the hosts we actually validate: the narrowed Guix release set (x86_64/aarch64/riscv64 Linux, x86_64 Windows, both macOS) plus native development hosts. Any other host now fails --enable-rust explicitly instead of fetching a standard library we never test. Android triples are rejected explicitly since they would otherwise match the generic Linux arms. Co-Authored-By: Claude Fable 5 --- configure.ac | 26 ++++---------- contrib/devtools/update-rust-hashes.py | 19 ++--------- depends/packages/native_rust.mk | 4 --- depends/packages/rust_stdlib.mk | 47 ++------------------------ 4 files changed, 13 insertions(+), 83 deletions(-) diff --git a/configure.ac b/configure.ac index 639a5e676c2a..28f3b6c28b21 100644 --- a/configure.ac +++ b/configure.ac @@ -1739,27 +1739,18 @@ if test "$use_zmq" = "yes"; then esac fi +dnl Rust support is deliberately confined to the hosts we validate (the Guix +dnl release set plus native development hosts). Any other host resolves to an +dnl empty triple, so --enable-rust fails explicitly rather than emitting +dnl binaries for a target we never build or test. AC_DEFUN([RS_SET_TRIPLE], [ rs_triple_libc=$3 case $2 in - aarch64-*-linux-android*) - $1="aarch64-linux-android" ;; - arm*-*-linux-android*) - $1="armv7-linux-androideabi" ;; - i?86-*-linux-android*) - $1="i686-linux-android" ;; - x86_64-*-linux-android*) - $1="x86_64-linux-android" ;; - x86_64-*-freebsd*) $1="x86_64-unknown-freebsd" ;; + *-linux-android*) dnl unsupported; must stay above the generic linux arms + $1="" ;; aarch64-*-linux*|arm64-*-linux*) $1="aarch64-unknown-linux-${rs_triple_libc}" ;; - arm*-*-linux-*eabihf) $1="armv7-unknown-linux-${rs_triple_libc}eabihf" ;; - arm*-*-linux-*eabi) $1="armv7-unknown-linux-${rs_triple_libc}eabi" ;; - arm*-*-linux*) $1="armv7-unknown-linux-${rs_triple_libc}eabihf" ;; - powerpc64-*-linux*) $1="powerpc64-unknown-linux-${rs_triple_libc}" ;; - powerpc64le-*-linux*) $1="powerpc64le-unknown-linux-${rs_triple_libc}" ;; riscv64-*-linux*) $1="riscv64gc-unknown-linux-${rs_triple_libc}" ;; - i?86-*-linux*) $1="i686-unknown-linux-${rs_triple_libc}" ;; x86_64-*-linux*) $1="x86_64-unknown-linux-${rs_triple_libc}" ;; x86_64-*-darwin*) $1="x86_64-apple-darwin" ;; aarch64-*-darwin*|arm64-*-darwin*) @@ -1840,10 +1831,7 @@ if test "$enable_rust" = "yes"; then *-linux-musl*) rust_target_libc=musl ;; esac if test "$rust_uses_depends" = "yes"; then - case $host in - powerpc64-*-linux*) rust_target_libc=gnu ;; - *) rust_target_libc=musl ;; - esac + rust_target_libc=musl fi RS_SET_TRIPLE([RUST_TARGET], [$host], [$rust_target_libc]) if test "$RUST_TARGET" = ""; then diff --git a/contrib/devtools/update-rust-hashes.py b/contrib/devtools/update-rust-hashes.py index 1124531d53ef..a2cee608f33e 100755 --- a/contrib/devtools/update-rust-hashes.py +++ b/contrib/devtools/update-rust-hashes.py @@ -11,22 +11,11 @@ import urllib.request from pathlib import Path -# Corresponds to 'hosts/*.mk' +# Rust standard libraries provisioned in rust_stdlib.mk. Confined to the +# hosts we validate (the Guix release set); see rust_stdlib.mk. CROSS_TARGETS = [ - # Android - "aarch64-linux-android", - "armv7-linux-androideabi", - "i686-linux-android", - "x86_64-linux-android", - # FreeBSD - "x86_64-unknown-freebsd", # Linux "aarch64-unknown-linux-musl", - "armv7-unknown-linux-musleabi", - "armv7-unknown-linux-musleabihf", - "i686-unknown-linux-musl", - "powerpc64-unknown-linux-gnu", - "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-musl", "x86_64-unknown-linux-musl", # Windows @@ -36,10 +25,8 @@ "x86_64-apple-darwin", ] -# Corresponds to 'builders/*.mk' +# Native compilers provisioned in native_rust.mk (build hosts for depends) NATIVE_TARGETS = [ - # FreeBSD - ("x86_64-unknown-freebsd", "x86_64_freebsd"), # Linux ("aarch64-unknown-linux-gnu", "aarch64_linux"), ("x86_64-unknown-linux-gnu", "x86_64_linux"), diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 599c2ceac44f..b474a0971ae3 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -11,10 +11,6 @@ $(package)_version:=1.92.0 $(package)_download_path:=https://static.rust-lang.org/dist $(package)_patches:=fix-elf-interpreter.sh -# FreeBSD (x86_64) -$(package)_file_name_x86_64_freebsd:=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz -$(package)_sha256_hash_x86_64_freebsd:=f32b7d8d5ad5c186fa496dd0b7202899f89e93870940e41c37e576f324494189 - # Linux (ARMv8) $(package)_file_name_aarch64_linux:=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz $(package)_sha256_hash_aarch64_linux:=c812028423c3d7dd7ba99f66101e9e1aa3f66eab44a1285f41c363825d49dca4 diff --git a/depends/packages/rust_stdlib.mk b/depends/packages/rust_stdlib.mk index 335ba7a7e565..d54594c875e2 100644 --- a/depends/packages/rust_stdlib.mk +++ b/depends/packages/rust_stdlib.mk @@ -16,56 +16,15 @@ $(package)_target=$(or \ $($(package)_target_$(subst -linux-,-unknown-linux-,$(canonical_host))),\ $(if $(findstring -apple-darwin,$(canonical_host)),$(host_arch)-apple-darwin)) -# Android -$(package)_targets += aarch64-linux-android -$(package)_targets += armv7-linux-androideabi -$(package)_targets += i686-linux-android -$(package)_targets += x86_64-linux-android -$(package)_target_aarch64-unknown-linux-android:=aarch64-linux-android -$(package)_target_armv7a-unknown-linux-android:=armv7-linux-androideabi -$(package)_target_i686-pc-linux-android:=i686-linux-android -$(package)_target_x86_64-pc-linux-android:=x86_64-linux-android -$(package)_sha256_hash_aarch64-linux-android:=f6689cf5b71056e887261ec84ae1f499eeb42c67e5ae73e7c0e06065b6648c44 -$(package)_sha256_hash_armv7-linux-androideabi:=18f6e6903c5f4361efe8c8a1ea546303e4473e8b9cd1b11fcf4e5b170468d464 -$(package)_sha256_hash_i686-linux-android:=d994d70493ad68ced22a5269e41b9fa6f83af9f3adabade154860058bc2e18c0 -$(package)_sha256_hash_x86_64-linux-android:=b9074f6961baff09334afaff745fb16dbf9f05cdf856b17309d8e6232a281c40 - -# FreeBSD (x86_64) -$(package)_targets += x86_64-unknown-freebsd -$(package)_target_x86_64-unknown-freebsd:=x86_64-unknown-freebsd -$(package)_sha256_hash_x86_64-unknown-freebsd:=3616afb808cd030e65e66c51f6f0fb6a6fc52d877d0d70bb681b0c35238adbe8 - -# Linux (ARMv7) -$(package)_targets += armv7-unknown-linux-musleabi -$(package)_targets += armv7-unknown-linux-musleabihf -$(package)_target_arm-unknown-linux-gnueabi:=armv7-unknown-linux-musleabi -$(package)_target_arm-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf -$(package)_target_armv7-unknown-linux-gnueabi:=armv7-unknown-linux-musleabi -$(package)_target_armv7-unknown-linux-gnueabihf:=armv7-unknown-linux-musleabihf -$(package)_sha256_hash_armv7-unknown-linux-musleabi:=3bf1b0015dc3b0f5f6f5622588431855c658d5c47093f24e4077f6893229ab30 -$(package)_sha256_hash_armv7-unknown-linux-musleabihf:=fc5c4ca757599caab8e93000becb9d57587088d32dab5c4f3b253f00ec3a2fd6 +# Rust support is deliberately confined to the hosts we actually validate +# (the Guix release set plus native development hosts). RUST=1 on any other +# host fails explicitly below rather than fetching a stdlib we never test. # Linux (ARMv8) $(package)_targets += aarch64-unknown-linux-musl $(package)_target_aarch64-unknown-linux-gnu:=aarch64-unknown-linux-musl $(package)_sha256_hash_aarch64-unknown-linux-musl:=715fbcfd8712c723947a020d0371c8a1a21f7531f2b696aeaed50ac23ba675c9 -# Linux (x86 32-bit) -$(package)_targets += i686-unknown-linux-musl -$(package)_target_i686-pc-linux-gnu:=i686-unknown-linux-musl -$(package)_target_i686-unknown-linux-gnu:=i686-unknown-linux-musl -$(package)_sha256_hash_i686-unknown-linux-musl:=3d6ccb700a17533eea10c7541896c92817783045c5537af37228142da7668fb3 - -# Linux (PowerPC 64-bit little-endian) -$(package)_targets += powerpc64le-unknown-linux-musl -$(package)_target_powerpc64le-unknown-linux-gnu:=powerpc64le-unknown-linux-musl -$(package)_sha256_hash_powerpc64le-unknown-linux-musl:=696958d87842d877640140ddbbaa74d044374874dee9516e227a395b70bfb8d4 - -# Linux (PowerPC 64-bit big-endian) -$(package)_targets += powerpc64-unknown-linux-gnu -$(package)_target_powerpc64-unknown-linux-gnu:=powerpc64-unknown-linux-gnu -$(package)_sha256_hash_powerpc64-unknown-linux-gnu:=c47938c152f1b237c901090d69522ce1ccfa69a859ed10d634fe3083108c3017 - # Linux (RISCV64GC) $(package)_targets += riscv64gc-unknown-linux-musl $(package)_target_riscv64-unknown-linux-gnu:=riscv64gc-unknown-linux-musl From 594f394e70f1bc4a2871d6d7c50330a586a61b6d Mon Sep 17 00:00:00 2001 From: pasta Date: Wed, 12 Aug 2026 18:38:55 -0500 Subject: [PATCH 57/60] fix: match Rust macOS deployment target to the C++ toolchain RUST_MACOS_DEPLOYMENT_TARGET fell back to the host OS version (sw_vers) whenever OSX_MIN_VERSION was not set as a shell variable. The depends config.site passes the deployment target to C/C++ inside CXXFLAGS (-mmacos-version-min=14.0) without exporting OSX_MIN_VERSION, so C++ objects were built for macOS 14.0 while libdashrust.a claimed the host version (e.g. minos 26.5), producing binaries whose Rust code assumes a newer macOS than the binary advertises. Derive the Rust deployment target from the C++ compiler's effective target instead: honor OSX_MIN_VERSION and MACOSX_DEPLOYMENT_TARGET when set, otherwise probe __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ through $CXX $CXXFLAGS so version-min flags embedded in CXXFLAGS are respected. Verified: configure now reports 14.0 under the depends config.site and the built archive carries minos 14.0. Co-Authored-By: Claude Fable 5 --- configure.ac | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 28f3b6c28b21..ac779eac1ce2 100644 --- a/configure.ac +++ b/configure.ac @@ -1820,7 +1820,24 @@ if test "$enable_rust" = "yes"; then if test -z "$OSX_MIN_VERSION" && test "$cross_compiling" = "yes"; then AC_MSG_ERROR([Cross-compilation requires OSX_MIN_VERSION to be set, cannot continue!]) fi - RUST_MACOS_DEPLOYMENT_TARGET="${OSX_MIN_VERSION:-$(sw_vers -productVersion)}" + if test -n "$OSX_MIN_VERSION"; then + RUST_MACOS_DEPLOYMENT_TARGET="$OSX_MIN_VERSION" + elif test -n "$MACOSX_DEPLOYMENT_TARGET"; then + RUST_MACOS_DEPLOYMENT_TARGET="$MACOSX_DEPLOYMENT_TARGET" + else + dnl Match the C/C++ compiler's effective deployment target so Rust + dnl objects never claim a different minimum macOS version than the + dnl C++ objects they are linked with. + rust_macos_min_raw=`echo __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ | $CXX $CXXFLAGS -E -xc++ - 2>/dev/null | tail -n 1` + case $rust_macos_min_raw in + [[0-9]][[0-9]]*) + RUST_MACOS_DEPLOYMENT_TARGET="`expr $rust_macos_min_raw / 10000`.`expr $rust_macos_min_raw % 10000 / 100`" + ;; + *) + RUST_MACOS_DEPLOYMENT_TARGET=`sw_vers -productVersion` + ;; + esac + fi AC_MSG_RESULT([$RUST_MACOS_DEPLOYMENT_TARGET]) ;; esac From eeb3b9157519b416a630f240e00bbb8ba96b505e Mon Sep 17 00:00:00 2001 From: pasta Date: Wed, 12 Aug 2026 18:38:55 -0500 Subject: [PATCH 58/60] build: dist the cxxbridge stamp before generated sources dist-chirp copied the generated bridge sources before the version stamp, so in the extracted tarball the stamp was newer than the sources and the strictly-newer staleness check always failed, forcing cxxbridge regeneration and defeating the pre-generated dist sources. Copy the stamp first so the shipped sources compare newer than it. Co-Authored-By: Claude Fable 5 --- rust/Makefile.chirp.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 3f5973ee3561..5e5a5c24875d 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -80,8 +80,8 @@ cxxbridge-chirp: $(LIBRUST_CHIRP_CPP) $(LIBRUST_CHIRP_H) $(LIBCXXBRIDGE_H) dist-chirp: cxxbridge-chirp $(MKDIR_P) $(distdir)/chirp/gen/src $(MKDIR_P) $(distdir)/chirp/gen/include/rust/chirp + cp $(LIBRUST_CHIRP_GEN_STAMP) $(distdir)/chirp/gen/ cp $(LIBRUST_CHIRP_CPP) $(distdir)/chirp/gen/src/ cp $(LIBRUST_CHIRP_H) $(distdir)/chirp/gen/include/rust/chirp/ - cp $(LIBRUST_CHIRP_GEN_STAMP) $(distdir)/chirp/gen/ .PHONY: cxxbridge-chirp cxxbridge-clean-chirp dist-chirp From ecafbb8af97f499caecc4a2eae0b8f640a0b28f5 Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 17 Aug 2026 17:23:08 -0500 Subject: [PATCH 59/60] build: accept equal-mtime cxxbridge artifacts from source tarballs Automake dists with tar --format=ustar, which stores mtimes at one-second precision, so the distributed generator stamp and the bridge artifacts it vouches for regularly extract with identical timestamps. The strict -nt comparison against the stamp then rejected perfectly fresh artifacts and forced regeneration. Accept artifacts that are at least as new as the stamp, while keeping the strict comparison against lib.rs so an edited bridge definition still forces regeneration. Co-Authored-By: Claude Fable 5 --- rust/Makefile.chirp.include | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rust/Makefile.chirp.include b/rust/Makefile.chirp.include index 5e5a5c24875d..e11b81459189 100644 --- a/rust/Makefile.chirp.include +++ b/rust/Makefile.chirp.include @@ -39,6 +39,13 @@ LIBRUST_CHIRP_FILES = \ $(LIBRUST_CHIRP_SRCS): ; +# Pre-generated bridge sources shipped in a source distribution are used when +# they are strictly newer than lib.rs (an edited lib.rs must force +# regeneration) and at least as new as the distributed stamp. The stamp +# comparison must accept equal timestamps: ustar archives store mtimes at +# one-second precision, so the stamp and the artifacts it vouches for often +# extract with identical times. + $(LIBRUST_CHIRP_GEN_STAMP): $(CXXBRIDGE) $(AM_V_at)$(MKDIR_P) $(@D) $(AM_V_at)rm -f $(@D)/.cxxbridge-* @@ -49,7 +56,7 @@ $(LIBRUST_CHIRP_CPP): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp && \ test -f $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $< && \ - test $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp -nt $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ + ! test $(LIBRUST_CHIRP_GEN_SRCSTAMP) -nt $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/src/lib.cpp $@; \ else \ @@ -61,7 +68,7 @@ $(LIBRUST_CHIRP_H): $(LIBRUST_CHIRP_SRCS) $(LIBRUST_CHIRP_GEN_STAMP) $(AM_V_GEN)if test -f $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h && \ test -f $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $< && \ - test $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h -nt $(LIBRUST_CHIRP_GEN_SRCSTAMP) && \ + ! test $(LIBRUST_CHIRP_GEN_SRCSTAMP) -nt $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h && \ test "$(LIBRUST_CHIRP_GEN_SRCDIR)" != "$(LIBRUST_CHIRP_GEN_DIR)"; then \ cp $(LIBRUST_CHIRP_GEN_SRCDIR)/include/rust/chirp/lib.h $@; \ else \ From 480126c908635474ef1798d01a8ddbbfadf14da9 Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 17 Aug 2026 17:23:09 -0500 Subject: [PATCH 60/60] docs: describe the optional Rust build support Document --enable-rust and --enable-online-rust, the RUST=1 depends workflow, supported hosts, pinned tool versions, offline crate vendoring, the system-toolchain workflow and how source tarballs ship pre-generated cxxbridge artifacts. Link the new doc from the doc index and the depends options list. Co-Authored-By: Claude Fable 5 --- depends/README.md | 2 + doc/README.md | 1 + doc/rust.md | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 doc/rust.md diff --git a/depends/README.md b/depends/README.md index f504627729f0..dbb285c22023 100644 --- a/depends/README.md +++ b/depends/README.md @@ -92,6 +92,8 @@ The following can be set when running make: `make FOO=bar` build script logic) are searched for among the host system packages using `pkg-config`. It allows building with packages of other (newer) versions - `MULTIPROCESS`: build libmultiprocess (experimental, requires cmake) +- `RUST`: Download/build/cache the Rust toolchain, target standard library, `cxxbridge` + and vendored crate sources needed for `--enable-rust` (see [doc/rust.md](../doc/rust.md)) - `DEBUG`: Disable some optimizations and enable more runtime checking - `HOST_ID_SALT`: Optional salt to use when generating host package ids - `BUILD_ID_SALT`: Optional salt to use when generating build package ids diff --git a/doc/README.md b/doc/README.md index 384ba6442f66..585f9ba2b4a8 100644 --- a/doc/README.md +++ b/doc/README.md @@ -34,6 +34,7 @@ Building The following are developer notes on how to build Dash Core on your native platform. They are not complete guides, but include notes on the necessary libraries, compile flags, etc. - [Dependencies](dependencies.md) +- [Rust](rust.md) - [macOS Build Notes](build-osx.md) - [Unix Build Notes](build-unix.md) - [Windows Build Notes](build-windows.md) diff --git a/doc/rust.md b/doc/rust.md new file mode 100644 index 000000000000..6fd1252365a8 --- /dev/null +++ b/doc/rust.md @@ -0,0 +1,134 @@ +# Rust in Dash Core + +Dash Core has optional support for components written in Rust, bridged into +the C++ codebase with [cxx](https://cxx.rs/). Rust support is **disabled by +default**: a default `./configure && make` performs no Rust work at all and +requires no Rust tooling. + +The Rust code lives in `rust/`. Component crates (currently only `chirp`, a +small smoke-test component) are compiled as dependencies of the umbrella crate +`rust/dashrust`, which cargo builds into a single static library that is +linked into the C++ binaries. The C++ side of each bridge is generated from +the crate's `src/lib.rs` by the `cxxbridge` code generator. + +## Toolchain requirements + +`--enable-rust` requires exact tool versions, enforced at configure time: + +| Tool | Version | +|-------------|------------| +| `rustc` | 1.92.0 | +| `cargo` | 1.92.0 | +| `cxxbridge` | 1.0.198 | + +The version pins live in `configure.ac`, `rust-toolchain.toml` (picked up +automatically by rustup) and the depends packages. To update them, change the +version in `depends/packages/native_rust.mk` and run +`contrib/devtools/update-rust-hashes.py`, and/or change +`depends/packages/native_cxxbridge.mk` and run +`contrib/devtools/update-native-cxxbridge.py`, keeping `configure.ac` in sync. + +## Building with depends (recommended) + +The depends system can provision the whole Rust toolchain, the Rust standard +library for the target, and offline copies of all crate dependencies: + +```bash +make -C depends RUST=1 HOST=x86_64-pc-linux-gnu +./configure --prefix=$(pwd)/depends/x86_64-pc-linux-gnu +make +``` + +`RUST=1` builds/installs into the depends prefix: + +- `native_rust`: the pinned Rust compiler and cargo for the build machine; +- `native_cxxbridge`: the pinned `cxxbridge` code generator; +- `rust_stdlib`: the pre-built Rust standard library for the target triple; +- `rustcxx`: the `rust/cxx.h` header; +- `vendored-sources/`: all crates from the workspace `Cargo.lock`, vendored + for offline use. + +The generated `share/config.site` then makes `./configure` default to +`--enable-rust` with `CARGO`, `RUSTC`, `CXXBRIDGE` and +`RUST_VENDORED_SOURCES` pointing into the depends prefix, so no extra +configure flags are needed. Everything after the depends downloads works +offline. + +For an offline sources mirror, `make -C depends RUST=1 download` additionally +fetches the Rust standard libraries for all supported targets +(`download-rust-std`) and creates a pre-vendored crate archive +(`vendor-crates`) in `SOURCES_PATH`. + +## Supported hosts + +Rust support is deliberately confined to the hosts that are validated in CI +and release builds. `--enable-rust` (and `RUST=1` in depends) fails +explicitly on any other host rather than producing binaries for a target that +is never tested: + +- Linux: `x86_64`, `aarch64`, `riscv64` (glibc and musl; depends builds use + the musl-targeted standard library) +- macOS: `x86_64`, `arm64` +- Windows: `x86_64` (MinGW-w64) + +Android is explicitly unsupported. Additional targets can be added later +together with CI lanes that exercise them. + +## Building with a system toolchain + +Instead of depends, a system Rust toolchain can be used as long as it matches +the pinned versions exactly. With rustup, the pinned toolchain from +`rust-toolchain.toml` is selected automatically; the matching code generator +can be installed with: + +```bash +rustup toolchain install 1.92.0 +cargo install cxxbridge-cmd --version 1.0.198 --locked +``` + +Note that rustup resolves `rust-toolchain.toml` from the current working +directory, so for out-of-tree builds export `RUSTUP_TOOLCHAIN=1.92.0` (the +build system propagates it to all cargo invocations). + +Configure builds are offline by default, so a system-toolchain build must +either provide vendored crates or opt in to network access: + +```bash +# Offline: vendor the workspace dependencies once, then point configure at them +cargo vendor --locked /path/to/vendored-sources +./configure --enable-rust RUST_VENDORED_SOURCES=/path/to/vendored-sources + +# Online: let cargo fetch dependencies from the network (developer convenience) +./configure --enable-rust --enable-online-rust +``` + +In offline mode the build generates a cargo config from +`.cargo/config.toml.offline`, adds the vendored directory as the +`crates-io` replacement, and reconstructs source-replacement stanzas for any +git-sourced crates in `Cargo.lock` via +`contrib/devtools/cargo-vendor-git-sources.sh`. Cargo then runs with +`--locked --offline`. In online mode no config is injected and the +developer's own cargo configuration (e.g. in `~/.cargo`) is left in effect; +cargo still runs with `--locked`. + +Useful configure variables (see `./configure --help`): + +- `RUST_VENDORED_SOURCES`: directory containing vendored crate sources + (required for offline builds outside depends); +- `RUSTFLAGS`: defaults to `-C embed-bitcode=yes -C relocation-model=pic`; +- `CARGO_INCREMENTAL`: defaults to `0`; +- `NATIVE_CC`/`NATIVE_CXX`/`NATIVE_AR`: build-machine tools, required when + cross-compiling (depends sets them automatically). + +`--enable-debug` builds the Rust code with cargo's debug profile instead of +the release profile. + +## Source tarballs + +Source distributions generated from a Rust-enabled tree (`make dist`) ship +the generated C++ bridge sources under `rust//gen/` together with a +stamp recording the `cxxbridge` version that produced them. Builds from such +a tarball reuse the shipped artifacts instead of regenerating them, provided +the artifacts are at least as new as the stamp and strictly newer than the +crate's `lib.rs`; editing `lib.rs` forces regeneration with the pinned +`cxxbridge`.