Can rust specify the compile order

Can rust specify the compile order, when I use tonic I find the compile order changes, I guess the order change is causing dependency errors for the entire code to compile, maybe some env changed.
not use tonic:
image
used tonic:


and then cause errors like this:

and flags also changed:

filcrypto's build script doesn't specify any C library to link. It only generates bindings to one:

How should it link to libfilcrypto in the first place if no dependency is specified?

Cargo will look at which crates depend on each other and queue each crate to be compiled in parallel, so the difference in orders you see are probably because one rustc process got slightly more CPU time than another.

This issue isn't because of compile orders, though. There is a bug in the build.rs script for whichever crate is failing because they implicitly rely on those OpenGL symbols being available and that just happened to work out most of the time. Really, each crate that depends on a native library should pass rustc the appropriate -l flags and specify the link field in their Cargo.toml so linking will always work.

I don't know much about this, and I had no problem compiling the rust part alone.
However, this error occurred when compiling with Lotus, and I looked at their compilation logs and saw that this was different, causing problems when compiling to golang.
I don't know if it's because of CGO, I have no idea at all...

Yes, it worked when I added the link,thanks!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.