#Add .rlib as dependency
33 messages · Page 1 of 1 (latest)
Hi! We’d like to help you with your current problem, but we have to know more about its surrounding context. What is the goal that you are trying to accomplish, as a whole? Not only can more information help fixing the problem better, sometimes it turns out that the best solution to accomplish your goal is something else entirely. This is known as an X-Y-problem. See: https://xyproblem.info/
I want to compile rust to a single file and using that later as a dependency.
Compiling and storing Rust libs isn't that great of an idea, as the format and contents of a .rlib is internal to the Rust compiler and can be changed without any warning, breaking all your dependants for your code.
If you mean just using your code a dependency, you can add a <your_package_name> = { path = "path/to/dep" } under dependencies to your Cargo.toml
[dependencies]
my_package = { path = "../my_package" }
if you have an rlib and want to use it in a rustc invocation, use --extern $cratename=$rlibpath
but is there a specific reason why you cant use cargo?
or some other build system, for that matter
I am aware that the rust abi is not stable. Still want to try to use it.
I can use cargo and want that. But I want to pre compile the code for performance reasons.
isn't that just the default behavior of cargo
I mean at least if you use a shared target directory
use sccache
When using cargo with normal dependencies, all libraries need to be compiled once for each system. I want to compile it once and just download the files.
I want to use a libary without compiling it on a specific machine.
Whats sccache?
Is there a guide für sccache?
Well that is as short and not self explenatory that it is at most a quickstart from my perspective.
I have no Idea what it exacly does, how it works nor how it solves my problem.
Steps:
- Install sccache
- Add to global cargo config ($HOME/.cargo.config.toml):
[build]
rustc-wrapper = "path/to/sccache"
- Use cargo normally
Thanks.
How do I transfer that cached content between systems? Thats my use case.
https://github.com/mozilla/sccache/?tab=readme-ov-file#storage-options
Really depends on your use-case
I think the easiest option is probably to use some kind of NAS and then use the "local" option
mh. I pretty much want to stay out of server stuff for such things.
Hmm, maybe having a local cache everywhere and then rsyncing that to the other machines could work?
Having a local cache where I could just copy and paste would work for me.