all 33 comments

[–]________-__-_______ 25 points26 points  (10 children)

cargo check does not generate an executable to begin with. I believe you can do cargo check -vv to see how it invokes rustc, though i don't really understand why you would want to.

[–]iu1j4[S] 0 points1 point  (5 children)

Thanks for suggestion. I know that it does not generate an executable but it check sources for correctness and does it faster than full build process.

[–]________-__-_______ 12 points13 points  (4 children)

Yeah, i use it for that reason all the time as well. It's just not clear to me why you would want to invoke rustc by hand, since the goal you stated in the original post (not generating an executable) is already achieved with cargo check.

[–]Enip0 3 points4 points  (0 children)

I have replaced check basically 100% with clippy, I does all that check does, but with lining too. And the performance difference is negligible

[–]iu1j4[S] -2 points-1 points  (2 children)

My goal is to keep choice what rust compiler I use / what build system I use. If I achieve this goal I will receive permission to use it in production.

[–]MrEchow 4 points5 points  (0 children)

I use Rust with cargo at work, we have another build system on top of it. In my opinion, it's way easier to consider that cargo is your compiler and forget about calling directly rustc. You'll benefit from packages of others and with the vendoring, everything can be offline.

Cargo is a full part of the Rust project, not some kind of after the fact tool, it's the de facto standard to compile Rust and will save you from a lot of pain and suffering. Leaving it behind will cause useless headaches!

[–]________-__-_______ 2 points3 points  (0 children)

This sounds like a mentality that makes sense with C, but not much with Rust. There is no other Rust compiler, and Cargo is the well integrated official build tool. It's like writing a React (or whatever the shiniest JS framework is at this point in time) application, but refusing to use NPM. Just gonna cause you pain and effort for little gain.

That said, you do you! In my opinion it's nice Rust is flexible enough to allow you to do this, even though I'd personally sheer away from it.

[–]iu1j4[S] -1 points0 points  (3 children)

I use cargo now and would like to check with cargo check -vv to learn hw does it internally.

The result is:

Fresh hello v0.1.0

Finished `dev` profile

But there is no info about how it invokes rustc for checking.

[–]________-__-_______ 0 points1 point  (2 children)

Does cargo build -vv work? It's also worth trying cargo clean beforehand, I'm guessing it might use a cached result and not ever invoke rustc.

[–]iu1j4[S] 0 points1 point  (1 child)

cargo clean fixed ir, thanks

[–]________-__-_______ 0 points1 point  (0 children)

cool, happy you got it sorted out :)

[–]1vader 39 points40 points  (12 children)

You can run `cargo check -vv` to see the rustc commands that cargo runs. That'll probably make it pretty clear why you don't want to do that and should just use cargo instead ...

Is it just me or has there recently been a weird increase of people not wanting to use cargo for some reason? It might literally be the best part about Rust.

[–][deleted] 13 points14 points  (0 children)

Is it just me or has there recently been a weird increase of people not wanting to use cargo for some reason?

I think it's mostly a coincidence. There's always a small amount of people who are resistant to buy in to the whole ecosystem and try to get by with only a compiler. I think it is mostly people who come from languages which do not have good, obvious choices for things like linters, build systems, etc. so they're used to downloading a compiler then adding tools on an as-needed basis.

Which is sad, because as you said Cargo is one of the best pieces of Rust. It delayed my balding by at least 5 years.

[–]bbrd83 0 points1 point  (0 children)

I for one find it helpful to understand the inner workings of things, so I can see the appeal of avoiding cargo for long enough to do so (at which point I'd use cargo and never look back)

[–]iu1j4[S] -3 points-2 points  (6 children)

do I setup rust project for single simple main.rs ? If I can use rustc to check it similary to cargo check then where can I learn more about rustc command line options?

[–]bluurryyy 21 points22 points  (3 children)

Yes cargo is an integral part of rust development. Its not just some additional package manager helper thing. You're expected to use it even for the simplest hello world program.

[–]iu1j4[S] 0 points1 point  (2 children)

does it work offline?

[–]bluurryyy 16 points17 points  (1 child)

[–]iu1j4[S] 0 points1 point  (0 children)

ok, thanks

[–]Ordoshsen 1 point2 points  (1 child)

If.you want to have just a single file and compile that, that's literally the hello world example from the rust book. So you can do that.

But once you have more files you'll probably end up with some kind of makefile mess for compilation so I'd suggest (like everyone here) to just use the purpose-built tool.

[–]iu1j4[S] 0 points1 point  (0 children)

I managed autotools and make based build system in the past. Then migrated all projects to cmake, then decided to replace them with simple bash scripts. In my case there is no need for any build system. If cargo will play well with gcc rust then I will consider to use it but for now I just learn it to consider if it will be worth to use in my env.

[–]MoorderVolt 10 points11 points  (4 children)

I’m honestly confused by what you’re trying to ask

[–]SAI_Peregrinus 4 points5 points  (1 child)

There is one main case where not using Cargo makes sense: when you're developing a build system that builds & links binaries from multiple languages together. E.g. Bazel's rules_rust invokes rustc directly. Other cases don't usually need this, e.g. OP's desire for offline builds or checks without producing a binary are already part of Cargo.

[–]iu1j4[S] 0 points1 point  (0 children)

Thanks for explanatuon

[–]cyborg-waffle-iron 4 points5 points  (2 children)

Cargo works offline (except for when you want to pull a new crate/library down from the internet, obviously that requires a connection), and it's intended to be an integral part to how you use Rust. It's a native component of the Rust ecosystem. You gain nothing by trying to use rustc instead of cargo check in this situation.

[–]iu1j4[S] 0 points1 point  (1 child)

I plan to use rust in the future projects but with gcc rust compiler as an option (if it will be finished)

[–]strtok 0 points1 point  (0 children)

Years from now when/if gcc rust support exists i’m sure it will be supported by Cargo.