Mixing generated and static sources with rust
See original GitHub issueRust works somewhat differently than languages like C do, it uses the filesystem hierarchy to find imports, and lacks a mechanism like C’s -I
. This makes using generated sources quite difficult, as meson separates generated sources and static sources into the build and source trees.
The most obvious solution to fix this is to copy or link the static sources into the build tree so that the hierarchy looks like what rustc expects. It would be best if this could be done transparently, and only when there are generated sources as well as
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Rust - The Meson Build system
Mixing Generated and Static sources ... You can use a structured_src for this. Structured sources are a dictionary mapping a string of the...
Read more >Linkage - The Rust Reference - Learn Rust
The compiler supports various methods to link crates together both statically and dynamically. This section will explore the various methods to link crates ......
Read more >Interacting with assembly in Rust - LogRocket Blog
The quickest and easiest way to generate assembly is with the compiler itself. This method doesn't require installing any additional tools, but ...
Read more >Mixing static and dynamic libraries in Rust FFI - Stack Overflow
My executable Rust crate uses a native library libfoo.a which depends on a shared library libbar.so , but does not expose it at...
Read more >Linkage - The Rust Reference
--crate-type=dylib , #[crate_type = "dylib"] - A dynamic Rust library will be produced. This is different from the lib output type in that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, it looks like the way that cargo handles this is with an environment variable (of course). Basically you add something like:
in your source, and cargo set’s OUT_DIR to the place it puts the generated files.
That is probably workable (rust really like environment variables, so we probably need a solution for them anyway 😕), with the one caveat that we need to ensure that all of the generated sources end up in a single output directory. That’s ugly, but probably workable.
https://github.com/rust-lang/rust/issues/78913
I seem to be mis-remembering a bit of this discussion, it’s been a while. This may actually be possible.