-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
linkedProjects: support using different cargo configurations / targets #8521
Comments
Oh wow, that's quite a hole in the design indeed.... We need to think how to fix this. Some considirations:
|
This kind of project setup might become more commonly used, there was a blog post from ferrous systems (I think @japaric): https://ferrous-systems.com/blog/test-embedded-app/ I might be able to look into this issue myself sometime soon-ish. Of course, we need to come up with ab easy-but-flexible solution, |
When writing embedded or operating system kernel, this feature might be more widely used. |
Any further thinking on this? I could try a PR with some guidance. Thanks. |
By default, could rust-analyzer build each of the targets specified in the cargo configuration? I believe that might also address #2142. |
this feature would be very useful when working in a workspace in which some crates target web assembly. right now, this (with #10021) makes RA unusable in this situation |
Bump this, I'm in this situation myself. @matklad are you on this? |
I also having the same issue. My situation is I need to build a x86 Windows DLL that depend on x64 driver. I can't target the DLL to x64 due to it need to be loaded by x86 application. |
This is a recurring problem with lots of my projects with mixed targets. Especially workspaces containing embedded projects or targeting WASM. A common situation is using the Another situation is I think it would already help to specify the target as Another option might be to blacklist build targets in Yet another idea would be to have profiles which act as an overlay to specify target overrides. This could be a configuration file (pseudo): {
"my_profile" : {
"my_crate": "my-target-triple",
},
"wasm" : {
"xtask": "default", // make sure that xtask is always built with the host's target triple
// every other crate used the existing mechanism
},
"linux" : {
"my_linux_launcher": "default",
"my_windows_launcher": null, // ignore this crate
"my_wasm_tools": null,
},
} On a second thought: Should this be approached by Cargo first? [https://github.com/rust-lang/cargo/issues/6179](Allow specifying a set of supported target platforms in Cargo.toml) I'm not very experienced in tool configurations so please let me know if other workarounds exist. |
Hopefully this can be a temporary workaround for people who are waiting for a fix. I have twitched my local project config to launch 2 lsps for project that has workspaces with different target triple. 1 checks with However,
But hopefully this is of help to anyone out there! |
I am having some difficulties with the linkedProjects feature of RA. Let me explain, what I am
trying to do.
My code base is structured like this:
Note, that the top level Cargo.toml and the cross/Cargo.toml are separate workspaces.
To support that project layout, I use the following settings.json (for vscode):
I use two separate workspaces, because I want to build code for two targets at the same time.
The top level workspace is build by default for the host machine target. It contains a custom xtask crate,
which functions as a cargo-wrapper, which is used to execute some external tools (essentially for
post processing build artifacts from the cross/ workspace.
There is also a libs/ folder, containing code shared among the cross/ and root workspaces.
The cross/ workspace is by default cross compiled to a different architecture (RISC-V, and arm
bare-metal targets).
Unfortunately, rust-analyzer is not aware, that it should process the two workspaces for different targets
and also different features. Putting a default target into the relevant .cargo/config files does not work.
With the rust-analyzer vscode settings, I can only specify the target for all loaded projects at once with the
rust-analyzer.cargo.target
config.Is it possible, to specify the used cargo target and features for every linked workspace separately?
If not, should this feature be added? Right now, the RA project model is already very flexible (as I understand),
so supporting this may be too difficult.
The text was updated successfully, but these errors were encountered: