Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cargo rustc to compile models as dynamic libraries #938

Closed
hannobraun opened this issue Aug 10, 2022 · 0 comments · Fixed by #1209
Closed

Use cargo rustc to compile models as dynamic libraries #938

hannobraun opened this issue Aug 10, 2022 · 0 comments · Fixed by #1209
Labels
good first issue Good for newcomers type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

Fornjot models are Rust packages that are compiled as dynamic libraries, then loaded into the Fornjot application at runtime. Right now, the user needs to add the following to their model's Cargo.toml to make that work:

[lib]
crate-type = ["cdylib"]

If they don't do that, this results in the following unfriendly error message:

thread 'main' panicked at 'Error reloading model: LibLoading(DlOpen { desc: "target/debug/liberror.so: cannot open shared object file: No such file or directory" })', crates/fj-host/src/lib.rs:279:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It should be possible to use cargo rustc to compile models, and pass the --crate-type argument (which has just been stabilized) to compile models as dynamic libraries. This should remove the need to specify the crate type in Cargo.toml.

The code that compiles models lives in fj-host:
https://github.com/hannobraun/Fornjot/blob/c5aee575fe443d2e0f91fd198a7b44b88ddff0fc/crates/fj-host/src/lib.rs#L91-L96

Labeling as https://github.com/hannobraun/Fornjot/labels/good%20first%20issue, as this should be a relatively small change, if it works out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: feature New features and improvements to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant