Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Cargo / C++ build integration #2080

Merged
merged 16 commits into from
Jun 20, 2023
Merged

Conversation

prasannavl
Copy link
Member

@prasannavl prasannavl commented Jun 18, 2023

Summary

  • Refine cargo build integration, and fix stale build due to updated Rust libs being untracked on C++ dep tree
    • This PR injects the final librs_exports.a into sources as proxy so that it a part of the dep graph whenever rebuilt naturally
    • Workaround to touch defid.cpp is no longer needed.
  • Cleans up the build process removing things that's not practically used and adds noise.
  • Refactor cargo Makefile
    • Use RUST_TARGET to set CARGO_BUILD_TARGET which is tracked by cargo (https://doc.rust-lang.org/cargo/reference/environment-variables.html)
    • Uses CARGO_TARGET_DIR env instead of having to pass --target-dir in each step.
    • Use --all-targets when not cross compiling to catch more failures early
    • Uses JOBS var to set CARGO_BUILD_JOBS to maintain coherency across jobs
    • Remove further noise by exporting CC related envs
  • Fixes incoherent .cargo/config.toml apply.
    • Moves .cargo/config.toml to the root dir so that it works across all tooling since cargo searches up.
    • Remove workaround no longer needed

make.sh

  • MAKE_JOBS is now respected throughout the build and carried coherently across C++ and Rust.
  • ./make.sh lib is now available that forwards to the Makefile in /lib for easier execution.
    • ./make.sh lib check / lib fmt / lib fmt-check etc are now used through this.
  • compiledb now available with ./make.sh for convenience
  • rust-analyzer-check for better consistency across build configs
  • _get_default_jobs is now used by default during make to ensure that there's a max cap of 80% of the cores on compiles to now use up all cores. 20% offers minimal difference to compile times, but provides for better dev experience without overloading machines.

Misc

  • Move protobuf up to v23.3.
  • Use osx universal binaries to simplify.
  • Adds .vscode/settings.default.json for recommended coherent settings that avoiding excessive recompilation during dev

Further pending Rust Issues

  • Enable cargo test for full code graphs that call C++ libs
  • [Fixed] Rust-analyzer and cargo build ends up in different configs due to RUSTFLAGS. What's applied in .cargo/config.toml doesn't seem to be applied to rust-analyzer workflow resulting in multiple compilations and invalidating compile caches all the time.

Implications

  • Storage

    • Database reindex required
    • Database reindex optional
    • Database reindex not required
    • None
  • Consensus

    • Network upgrade required
    • Includes backward compatible changes
    • Includes consensus workarounds
    • Includes consensus refactors
    • None

@Bushstar Bushstar merged commit 5d43402 into master Jun 20, 2023
@Bushstar Bushstar deleted the pvl/master-build-cleanup branch June 20, 2023 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants