How to use proc_macro2 with thumbv6m-none-eabi

Hi,

I have written a proc_macro (which makes use of std) and am currently trying to compile some code that uses this macro.
However I get a bunch of errors when trying to compile for thumbv6m-none-eabi, it looks like this is because it does not have support for std.

My confusion comes from the fact that this toy example which uses the macro is completely no_std, only the macro makes use of std.
Am I compiling this incorrectly or is it not possible to compile for some target (that does not have support for std) while some macro code depends on std?

That's strange. I recently did a quick test with a no-std lib in which I used a procedural macro to replace declarative macros, and it didn't cause any trouble. I added the procedural macro in the dependency list and instantiated it a few times it in the library (that procedural macro doesn't add any code that depends on std, of course). I wasn't cross-compiling, though.

As long as std doesn't feature in your use list—in the expanded code—then #![no_std] should still be accepted.

I assume your code was compiling before you added the macro?

PS: I think that, long ago, std was leaking in some circumstances, and using procedural macros was one of them, but it's been fixed. If that's any relevant, and hopefully I'm giving the correct link.

When cross-compiling, proc macro libraries will be built for the host, not the target platform.

Most likely, you've got a run-time dependency on proc-macro2 somehow, or whatever build command you issued is accidentally trying to build the macro library for the target in addition to its use as a macro. We'll need to see your code (including Cargo.tomls) and build logs to diagnose this further.

@kpreid
Yes indeed, I thought that it should be compiling the macros for my host, but wasn't sure anymore.

Your question made me try and get a MVE to show what went wrong.
I managed to fix it by copying each directory one by one over to a new directory and checking if it still worked and compiled.

The problem which was giving me all this trouble was having macrotest in my regular dependencies instead of my dev-dependencies -_-.