How to get assembly output from building with Cargo?

You can use Cargo’s cargo rustc command to send arguments to rustc directly: cargo rustc — –emit asm ls target/debug/deps/<crate_name>-<hash>.s For optimized assembly: cargo rustc –release — –emit asm ls target/release/deps/<crate_name>-<hash>.s If you see multiple <crate_name>-<hash>-<hash>.rcgu.s files instead of a <crate_name>-<hash>.s file, disable incremental compilation by setting the environment variable CARGO_INCREMENTAL=0.

How can I specify binary-only dependencies?

There are several ways to simulate what you want: 1) Turn the binaries to examples Examples and tests are built with dev-dependencies, so you could move those dependencies into this section. The library won’t depend on them. # File structure conformal/ Cargo.toml src/ lib.rs examples/ # <– the `ucitest` is ucitest.rs # <– moved to … Read more

error[E0554]: #![feature] may not be used on the stable release channel Couldn’t install racer using cargo

As the error message states, you cannot compile that code with stable Rust. You need to install nightly Rust and then use it to compile the program: rustup install nightly cargo +nightly install racer See also: How to execute cargo test using the nightly channel? Is it possible to have multiple coexisting Rust installations? Rocket … Read more

How to get a release build with debugging information when using cargo?

As of Rust 1.57, Cargo now allows for custom profiles. This allows you to define your own profile that adds debug information: [profile.release-with-debug] inherits = “release” debug = true You can then use that profile when building: % cargo build –profile=release-with-debug Compiling buggin v0.1.0 (/tmp/buggin) Finished release-with-debug [optimized + debuginfo] target(s) in 0.48s Prior to … Read more

How to define test-only dependencies?

Yes. Use dev-dependencies. From the Cargo docs: You can add a [dev-dependencies] section to your Cargo.toml whose format is equivalent to [dependencies]: [dev-dependencies] tempdir = “0.3” Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks. When possible, you should also use Cargo’s resolver version 2 … Read more

What is a crate attribute and where do I add it?

A crate attribute is an attribute (#[…]) that applies to the enclosing context (#![…]). This attribute must be added to the top of your crate root, thus the context is the crate itself: #![attribute_name] #![attribute_name(arg1, …)] If you are creating a library — the crate root will be a file called lib.rs an application — … Read more

Does cargo install have an equivalent update command?

There is no such command in vanilla cargo (well, there’s cargo install but that’s for dependencies), but since cargo supports third-party subcommands there is an answer: the cargo-update crate. Install as usual with cargo install cargo-update, then use cargo install-update -a to update all installed packages, for more usage information and examples see the cargo … Read more

How to check release / debug builds using cfg in Rust?

You can use debug_assertions as the appropriate configuration flag. It works with both #[cfg(…)] attributes and the cfg! macro: #[cfg(debug_assertions)] fn example() { println!(“Debugging enabled”); } #[cfg(not(debug_assertions))] fn example() { println!(“Debugging disabled”); } fn main() { if cfg!(debug_assertions) { println!(“Debugging enabled”); } else { println!(“Debugging disabled”); } #[cfg(debug_assertions)] println!(“Debugging enabled”); #[cfg(not(debug_assertions))] println!(“Debugging disabled”); example(); } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)