Rust backend #17502
Replies: 6 comments 3 replies
-
|
from discussion on Slack - @benjyw mentioned "dependency inference" e.g. :
|
Beta Was this translation helpful? Give feedback.
-
|
Prior art:
|
Beta Was this translation helpful? Give feedback.
-
|
Hi @rbuckland , wondering if you've had further thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
|
Since it hasn't been mentioned there's an equivalent plugin for Bazel: https://github.com/google/cargo-raze. Might be interesting to look at that and see what parallels there are and what can be learned. From experience, one of the things I think raze does wrong is embedding one build-file per package into the repo. Huge source of noise. And it requires "non-native" tooling to work with by using |
Beta Was this translation helpful? Give feedback.
-
|
At this top of this discussion there is the concept of a rust thing in a monorepo, e.g. just building a lib. We're a current user of Bazel, amongst other things, and for us a monorepo looks like a real polyglot situation: generally we build a docker image for a particular service, and we have dozens of services in a single repo; some are just Rust, some are just Go, some are just Python etc. A small number have both NPM and Python or some similar combination in one docker image; A small number have cross-language libraries being built. I mention this just to say that the common case where a caching, hermetic, remote-build-capable build system would be useful to Rust users, is actually just building Rust docker images :). At least for us. Doing that fast, consistently, well, would allow making CI toolchains a heck of a lot nicer. Bazel has rough edges particular related to C dependencies that Rust ends up bringing in. Like openssl_sys. |
Beta Was this translation helpful? Give feedback.
-
|
I noticed that For instance, running Details{
"invocations": [
{
"package_name": "peg-runtime",
"package_version": "0.8.1",
"target_kind": [
"lib"
],
"kind": null,
"compile_mode": "build",
"deps": [],
"outputs": [
"/Users/huon/projects/pantsbuild/pants/src/rust/engine/target/debug/deps/libpeg_runtime-c5f23995afc28bca.rlib",
"/Users/huon/projects/pantsbuild/pants/src/rust/engine/target/debug/deps/libpeg_runtime-c5f23995afc28bca.rmeta"
],
"links": {},
"program": "rustc",
"args": [
"--crate-name",
"peg_runtime",
"--edition=2018",
"/Users/huon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/peg-runtime-0.8.1/lib.rs",
"--error-format=json",
"--json=diagnostic-rendered-ansi,artifacts,future-incompat",
"--diagnostic-width=274",
"--crate-type",
"lib",
"--emit=dep-info,metadata,link",
"-C",
"embed-bitcode=no",
"-C",
"split-debuginfo=unpacked",
"-C",
"debuginfo=2",
"-C",
"metadata=c5f23995afc28bca",
"-C",
"extra-filename=-c5f23995afc28bca",
"--out-dir",
"/Users/huon/projects/pantsbuild/pants/src/rust/engine/target/debug/deps",
"-L",
"dependency=/Users/huon/projects/pantsbuild/pants/src/rust/engine/target/debug/deps",
"--cap-lints",
"allow",
"--cfg",
"tokio_unstable"
],
"env": {
"CARGO": "/Users/huon/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo",
"CARGO_CRATE_NAME": "peg_runtime",
"CARGO_MANIFEST_DIR": "/Users/huon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/peg-runtime-0.8.1",
"CARGO_PKG_AUTHORS": "Kevin Mehall <km@kevinmehall.net>",
"CARGO_PKG_DESCRIPTION": "Runtime support for rust-peg grammars. To use rust-peg, see the `peg` crate.",
"CARGO_PKG_HOMEPAGE": "",
"CARGO_PKG_LICENSE": "MIT",
"CARGO_PKG_LICENSE_FILE": "",
"CARGO_PKG_NAME": "peg-runtime",
"CARGO_PKG_REPOSITORY": "https://github.com/kevinmehall/rust-peg",
"CARGO_PKG_RUST_VERSION": "",
"CARGO_PKG_VERSION": "0.8.1",
"CARGO_PKG_VERSION_MAJOR": "0",
"CARGO_PKG_VERSION_MINOR": "8",
"CARGO_PKG_VERSION_PATCH": "1",
"CARGO_PKG_VERSION_PRE": "",
"DYLD_FALLBACK_LIBRARY_PATH": "/Users/huon/projects/pantsbuild/pants/src/rust/engine/target/debug/deps:/Users/huon/.rustup/toolchains/nightly-aarch64-apple-darwin/lib:/Users/huon/.rustup/toolchains/nightly-aarch64-apple-darwin/lib:/Users/huon/lib:/usr/local/lib:/usr/lib"
},
"cwd": "/Users/huon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/peg-runtime-0.8.1"
},
...I could imagine that this might be a path forward for integrating external dependencies via Relevant issues: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Preamble
This is a discussion thread to gather the requirements, ideas and wisdom for creating a development backend workflow for Rust.
There is some prior work already that we will continue on:
This is intended to be a bit of a brain dump and request for ideas/opinions/thoughts on creating a compilation and packaging workflow for the C and C++ backend(s). Currently only "firing" shell command is supported, no rust.
This discussion thread is to flesh out the themes we would need, such that we can incrementally build out a Rust backend.
Base principle is to no reinvent any wheel, but let a rust project, live within in a wider polyglot monorepo (thing a Rust lib that generates Python, C and npm (webpack) libs)
Required Features
Resource/Dependency Generation
cargo.tomlenough to determine what will be "spat out" - need to know the architectures being generated of course.Compiler and Toolchain
The assumption would be that we can hook straight into cargo execution
Do we run rustc ?
Package Management
cargo.lock file exists, - need to look how it is handled With Python/pip,poetry and Java/maven today. This should be similar same, which has the best example ?
Linting and Formatting
run cargo fmt :-) ?
Testing
run cargo test :-) ?
Compilation
Caching
need to know how the caching architecture works and how we seed it from a rust point of view.
Build Generators
An example (personally used) is auto generation of json-schema files, from the rust struct external data types.
Then used in APIs.
Actions
Beta Was this translation helpful? Give feedback.
All reactions