Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Refactor zinc crate to support native build #303

Open
farcaller opened this issue Jun 1, 2015 · 7 comments
Open

Refactor zinc crate to support native build #303

farcaller opened this issue Jun 1, 2015 · 7 comments
Labels

Comments

@farcaller
Copy link
Member

As of now it's not possible to build zinc crate as it uses arm assembly. Still, zinc contains lots of code that would be interesting to unit test and validate coverage.

The proposed solution is to extract all machine-dependent code into new file hierarchy, namely arch/, and allow that to depend on feature flags.

Actual mcu code should be buildable for native arch as it's expected that it would be unit tested as well.

@mcoffin
Copy link
Contributor

mcoffin commented Jun 1, 2015

Compiling the zinc crate natively works fine for me? cargo test --lib --verbose.

It won't work of you enable one of the platform features, as that will enable that ISR vector code for that platform (and therefore some assembly). Note that the stuff in hal/platform is not gated behind #[cfg(feature = "platform")] and can therefore be unit tested if you can find a way to get it to use dummy registers.

@farcaller
Copy link
Member Author

That's for test only, no? I mean, compile the dylib/rlib of zinc for native target.

@farcaller
Copy link
Member Author

Also, #302 will sort out the dummy registers part.

@bharrisau
Copy link
Contributor

I think the #cfgs for the asm code is currently just for tests. But
moving all of the unsafe ASM to a separate mod and documenting it (so we
don't get asm popping up everywhere) would be a good thing for hygiene.
On 2 Jun 2015 6:14 am, "Vladimir Pouzanov" [email protected] wrote:

Also, #302 #302 will sort out the
dummy registers part.


Reply to this email directly or view it on GitHub
#303 (comment).

@mcoffin mcoffin added ready and removed in progress labels Jun 1, 2015
@mcoffin
Copy link
Contributor

mcoffin commented Jun 1, 2015

@bharrisau Regarding what you said in #305, i think a decent solution might be to come up with a system like rustc's "lang items". Then, i would agree, #[cfg(...)] to import the right impl (maybe within some intrinsics mod?)

@farcaller
Copy link
Member Author

a system like rustc's "lang items"

would be nice, but the only way to implement something like it, as far as I know, is to have a stable path and pub use the #[cfg]-guarded version into it.

@mcoffin
Copy link
Contributor

mcoffin commented Nov 30, 2016

Note for self and anyone reading: the zinc crate will now build for native, but that's just because all the mcu code sits behind cargo feature gates.

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

Successfully merging a pull request may close this issue.

3 participants