Hacker News new | past | comments | ask | show | jobs | submit login

Cargo != rust. They are different things for a reason. You don't ever need cargo to manage deps or build, it's just idiomatic to do so.

Nothing stopping you from building rust code with manual vcs, rustc, autoconf, and make, just like C.




True in principle. But once you divorce yourself from Cargo, almost all resources and advice when it comes to building Rust programs go out the window. I love the language, and I love the community, but the attitude of "rustup nightly and Cargo, or bust" is bit terrifying.

As a noob, I had to wade through endless "but don't do that, just get the latest from Cargo!!!!" when I asked for advice on how to use my system-provided Rust packages for my project.


For what it's worth, system-provided can be arbitrary and vary widely between systems.

Moreover, in the Python world a distinction is made between "software that runs your system" and "software that you use for development"; maybe Rust people think similarly.


> For what it's worth, system-provided can be arbitrary and vary widely between systems.

Sure. That's inherent with software.

> Moreover, in the Python world a distinction is made between "software that runs your system" and "software that you use for development"; maybe Rust people think similarly.

What?


Yes, however they're much more tied together as an ecosystem than, say, python and pip.


Notably for this thread, Linux will not be using Cargo.


Is there any sort of detailed documentation on how to use rustc directly in more complex ways? I imagine that any begginer's text will mostly treat cargo and not such special usage scenarios as this one.


You can read how Google is going to do it, regardless of what upstream decides to do.

https://security.googleblog.com/2021/05/integrating-rust-int...

https://security.googleblog.com/2021/06/rustc-interop-in-and...


https://doc.rust-lang.org/stable/rustc/ is the rustc specific documentation.

You can pass -v to Cargo and it will show you the rustc invocation it makes if you want to reverse-engineer what Cargo does.


Oh, somehow I missed that there's a rustc book. Cool, thanks.


You're welcome! Yeah, it's not always the easiest to find.


Oh, it's actually easy to find on https://www.rust-lang.org/learn in the second section of the page. Most likely reason for me not having found it is that the last time I looked at that page, I wasn't looking for the rustc book specifically, and that now that I wondered where rustc's user-level documentation was, the book doesn't appear when I googled simply "rustc documentation". You have to google specifically "rustc book" and that didn't occur to me, as I was expecting some kind of manpage instead.


Thanks for clearing that up. Say, you know a lot of things about the rust ecosystem. Do you have any insight into how hypothetical rust driver code would integrate with the rest of the kernel build process? I imagine it would have to use llvm-rustc, or is gccrs ready for the job?

Would it be emitting objects that gcc/ld would link against?


> Do you have any insight

Well, this is a working patch set, so, yes, though I have no direct involvement and haven't read all of it yet.

> I imagine it would have to use llvm-rustc,

Yes, it uses upstream rustc.

> is gccrs ready for the job?

Not yet. They're making great progress, but major chunks of the language are still missing. They'll get there.

Using upstream rustc isn't a blocker for new code implementing drivers, but it is a blocker for getting into older drivers, or the kernel. The blocker is platform support; or at least, the current largest blocker, and either rustc will gain it, or gccrs will be good enough to compile this codebase. We'll see :)

> Would it be emitting objects that gcc/ld would link against?

Yep, it emits output that looks like any C compiler's output, you link 'em together and you're good.

If you manage to compile the kernel with clang, in theory you can even get cross-language LTO; this is working in Firefox, but I'm not sure if anyone's tried it with the kernel yet or not.


> If you manage to compile the kernel with clang, in theory you can even get cross-language LTO.

Note, that there is still bunch of unsolved issues [1] in LLVM to allow all building all of Linux kernel. The efforts had stopped for some years but recently gained steam again, though a lot of time was wasted before.

[1] https://bugs.llvm.org/show_bug.cgi?id=4068




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: