Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

tracking issue: cross compilation #309

Open
2 tasks
nrc opened this issue May 10, 2017 · 16 comments
Open
2 tasks

tracking issue: cross compilation #309

nrc opened this issue May 10, 2017 · 16 comments
Labels
enhancement Indicates new feature requests

Comments

@nrc
Copy link
Member

nrc commented May 10, 2017

The RLS should work properly with cross-compiled crates, this mostly means working properly with Rustup and Xargo

cc #104
cc @Xanewok

@nrc nrc added the P-high label May 12, 2017
@nrc
Copy link
Member Author

nrc commented Oct 30, 2017

To address the first item, I think we need to pass the target from the RLS to rls-analysis so that we load the correct version of the std libs save-analysis data.

@ketsuban
Copy link

ketsuban commented Dec 4, 2017

#88 was closed, should the first box in the OP be checked or is there more to it than that?

@nrc
Copy link
Member Author

nrc commented Dec 5, 2017

Although we do have the info available from indexing std, we still don't use the correct version when compiling for a target other than the host.

@nrc
Copy link
Member Author

nrc commented Apr 17, 2018

This is where to fix that: https://github.com/rust-lang/rust/blob/master/src/tools/build-manifest/src/main.rs#L348 It should be treated more like std libs, just below.

@nrc nrc removed the P-high label Jun 21, 2018
@parasyte
Copy link
Contributor

This is related. I started a new project that contains two different crates, with both expected to be compiled for different targets. I could split the crates out into separate repos, but I don't think they will ever be used apart. One is a build tool that is compiled on the host (Linux, Windows, macOS). And the other is cross compiled for an embedded system.

The trouble is RLS only has a notion of using one target triple for every crate in the project.

@marmistrz
Copy link
Contributor

marmistrz commented Jul 22, 2019

Currently we have the rust.target configuration option, which seems to partially do the trick for me (only for compilation, not for hover hints)

@jacobrosenthal
Copy link

Forgive the dumb question, but why does target have to be specified separately from .cargo/config

@marmistrz
Copy link
Contributor

@jacobrosenthal I meant the configuration option of the VSCode extension.

@jacobrosenthal
Copy link

This may or may not be the place or this, but Im asking why rls can't harvest the target from the existing .cargo/config instead of me having to duplicate which is obviously error prone. Im sure theres a reason, but curious what it is.

@marmistrz
Copy link
Contributor

marmistrz commented Jul 24, 2019

@jacobrosenthal I don't understand what you mean. It's as simple as "rust.target": "x86_64-pc-windows-gnu", in the vscode settings.json. It's equivalent to cargo build --target=$TARGET

@jacobrosenthal
Copy link

jacobrosenthal commented Jul 24, 2019 via email

@rubberduck203
Copy link

It's not desirable to have to hard code the target.
When unit testing embedded code, you often want to run your tests (and therefore compile at least a portion of your production code) on your development machine.
This means you cannot set a target in the .cargo/config file, it must be specified on the command line.

Please see the cortex-m-quickstart example linked below for an example of why we can't rely on a build target being specified in .cargo/config.

https://github.com/rust-embedded/cortex-m-quickstart/blob/master/examples/test_on_host.rs

@jacobrosenthal
Copy link

jacobrosenthal commented Nov 13, 2019 via email

@rubberduck203
Copy link

Sure, if it already is, then it'd be nice to use it.
I'm just seeing some things in the ecosystem that are assuming you are hard coding it into your config.

@VizorKit
Copy link

VizorKit commented Jun 30, 2020

I have added this to my .vscode/settings.json file.

{
    "rust.target": "thumbv7em-none-eabi",
    "rust.all_targets": false
}

I have added this to my .cargo/config file.

[build]
target = "thumbv7m-none-eabi"

And I am still getting this error.
image

** EDIT **
I switched to using "riscv32imac-unknown-none-elf" for all these settings. Since that is what type of binary I really wanted to build. I was just trying to follow this guide. https://docs.rust-embedded.org/embedonomicon/memory-layout.html

It's proving to be quite out of date, but at least I can get started there. I am no longer receiving the error about the target missing, but it is still complaining about the below.

image

@MozarellaMan
Copy link

@VizorKit Did you find a solution? I'm having the same problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

9 participants