getditto/safer_ffi

Trying to build targeting Mac Catalyst which requires nightly but a dependency fails

Closed this issue · 4 comments

If the use of mini_paste isn't too performance critical perhaps moving to paste would make sense since mini_paste hasn't been updated in a couple years.

   Compiling mini_paste v0.1.11
error[E0432]: unresolved imports `proc_macro::item`, `proc_macro::__expr_hack__`
  --> /Users/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/mini_paste-0.1.11/src/lib.rs:11:5
   |
11 |     item as __item__,
   |     ----^^^^^^^^^^^^
   |     |
   |     no `item` in the root
   |     help: a similar name exists in the module: `iter`
12 |     __expr_hack__,
   |     ^^^^^^^^^^^^^ no `__expr_hack__` in the root

For more information about this error, try `rustc --explain E0432`.
error: could not compile `mini_paste` due to previous error

Yeah, with the current revamp/cleanup of safer-ffi, minipaste will be replaced back with paste (the reason for using it at the moment is a very weird and obscure misinteraction between spans of tokens and a macro_rules! macro calling a proc-macro which calls back a macro_rules! macro: in such a contrived scenario, the implementation of mini_paste seems to dodge the compiler bug whereas paste doesn't).

But as the step #97 of the revamp is completed, we won't hit that bug anyways, making usage of paste fine again.

Workaround

In the interim, you are hitting yet another compiler bug (can't have a renamed a proc-macro = true crate dependency when cross-compiling), which was circumvented upstream, but due to the "archived state" of mini_paste the workaround has not made it to crates.io:

# https://github.com/danielhenrymantilla/mini_paste/commit/69f4e5e0784d05fecaaca7ec8d8ed0a13f407472
[patch.crates-io.mini_paste]
git = "https://github.com/danielhenrymantilla/mini_paste.git"
rev = "69f4e5e0784d05fecaaca7ec8d8ed0a13f407472"

(I'm aware a patch is not ideal, but it should just be needed for a couple weeks / a month at most; at that point the revamp ought to be ready and thus have been released. I'm quite confident the patch will circumvent the bug, hence my closing the issue (my way of tagging it as "nothing more to be done" (since #97 will already naturally fix this long-term)). But it's not meant to put an end to the discussion, on the other hand 🙂)

That patch does get me past compiling mini_paste (thanks!) but then safer_ffi fails to build:

error[E0432]: unresolved imports `proc_macro::ffi_export`, `proc_macro::cfg_headers`
  --> /Users/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/safer-ffi-0.0.7/src/_lib.rs:42:24
   |
42 | pub use ::proc_macro::{ffi_export, cfg_headers};
   |                        ^^^^^^^^^^  ^^^^^^^^^^^ no `cfg_headers` in the root
   |                        |
   |                        no `ffi_export` in the root

error[E0432]: unresolved import `proc_macro::derive_ReprC`
  --> /Users/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/safer-ffi-0.0.7/src/_lib.rs:52:13
   |
52 |     pub use ::proc_macro::derive_ReprC;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `derive_ReprC` in the root

error[E0432]: unresolved import `proc_macro::_proc_macro_hack_c_str`
  --> /Users/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/safer-ffi-0.0.7/src/_lib.rs:49:15
   |
49 |     pub use ::proc_macro::c_str as c;
   |               ^^^^^^^^^^^^^^^^^ no `_proc_macro_hack_c_str` in the root

error[E0432]: unresolved import `proc_macro::derive_ReprC`
  --> /Users/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/safer-ffi-0.0.7/src/layout/_mod.rs:17:9
   |
17 |         derive_ReprC,
   |         ^^^^^^^^^^^^ no `derive_ReprC` in the root

BTW, thanks for releasing this library. It made using Rust on iOS so much easier. (I'm working on this: https://github.com/spullara/granne_c)

Damn, safer-ffi itself is affected by that Rust bug as well. Thanks for bringing this up, will smuggle a fix to it with the other changes, and in the meantime, I'll set up a patch to fix safer-ffi itself