# \[SOLVED\] Compiling cosmwasm-sgx-vm: error\[E0432\]: unresolved imports \`cranelift\`

**URL:** <https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838>\
**Category:** Developer Help\
**Created:** [July 12, 2020, 10:56am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838 "2020-07-12T10:56:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![plek](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@plek](https://forum.scrt.network/u/plek)\
**Post date:** [July 12, 2020, 10:56am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/1 "2020-07-12T10:56:31Z")

</div>

Hi all,  
I’m simply following [https://build.scrt.network/dev/contract-dev-guide.html](https://build.scrt.network/dev/contract-dev-guide.html) and it compiles well, but afterwards, when running unit/integration tests or `cargo scheme` I’m getting:

```
Compiling cosmwasm-sgx-vm v0.9.0-alpha1 (https://github.com/enigmampc/SecretNetwork?tag=v0.5.0-alpha2#b1710787)
error[E0432]: unresolved imports `cranelift`, `crate::backends::get_gas_left`
  --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/backends/mod.rs:24:9
   |
24 | pub use cranelift::{backend, compile, get_gas_left, set_gas_limit};
   | ^^^^^^^^^ use of undeclared type or module `cranelift`
   | 
  ::: /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:20:5
   |
20 | use crate::backends::get_gas_left;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find macro `imports` in this scope
  --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:94:13
   |
94 | imports! { move || { setup_context::(gas_limit) }, "env" => {}, };
   | ^^^^^^^

error: cannot find macro `imports` in this scope
...
```

What could be wrong? Do I miss anything?  
I run it on Ubuntu 18.04 with SGX working well.

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [July 12, 2020, 11:10am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/2 "2020-07-12T11:10:44Z")

</div>

Ah yeah, sorry, that’s a small oversight on our end. I’ll push a PR that fixes it in the `secret-template` repo now, but in the meanwhile please apply this patch to your `Cargo.toml` file:

```diff
diff --git a/Cargo.toml b/Cargo.toml
index 763d3e5..5e20f38 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,12 +27,10 @@ incremental = false
 overflow-checks = true
 
 [features]
-default = ["cranelift"]
+default = []
 # for quicker tests, cargo test --lib
 # for more explicit tests, cargo test --features=backtraces
 backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"]
-cranelift = ["cosmwasm-vm/default-cranelift"]
-singlepass = ["cosmwasm-vm/default-singlepass"]
 
 [dependencies]
 cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v0.5.0-alpha2" }

```

In general though, i don’t think that the integration tests will work. Definitely let us know if they do 😅 I believe the unittests should be good 👍

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [July 12, 2020, 11:18am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/3 "2020-07-12T11:18:24Z")

</div>

@plek and to anyone else that finds this:

The issue should be fixed in the latest commit on the `secret-template` repository 👍

---

<div class="post-metadata">

**Author:** ![plek](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@plek](https://forum.scrt.network/u/plek)\
**Post date:** [July 12, 2020, 11:42am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/4 "2020-07-12T11:42:25Z")

</div>

@reuven thanks for your prompt action!😉 That indeed helped with the first error, but I’m getting others:

```auto
Compiling cosmwasm-sgx-vm v0.9.0-alpha1 (https://github.com/enigmampc/SecretNetwork?tag=v0.5.0-alpha2#b1710787)
error[E0432]: unresolved import `crate::backends::get_gas_left`
  --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:20:5
   |
20 | use crate::backends::get_gas_left;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `get_gas_left` in `backends`

error: cannot find macro `imports` in this scope
  --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:94:13
   |
94 | imports! { move || { setup_context::<S, Q>(gas_limit) }, "env" => {}, };
   | ^^^^^^^

error: cannot find macro `imports` in this scope
  --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:98:27
   |
98 | import_obj.extend(imports! {
   | ^^^^^^^

error[E0433]: failed to resolve: use of undeclared type or module `VmError`
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:167:13
    |
167 | VmError::instantiation_err(format!("Error instantiating module: {:?}", original))
    | ^^^^^^^ use of undeclared type or module `VmError`

error[E0433]: failed to resolve: use of undeclared type or module `CommunicationError`
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:249:24
    |
249 | return Err(CommunicationError::zero_address().into());
    | ^^^^^^^^^^^^^^^^^^ use of undeclared type or module `CommunicationError`

error[E0412]: cannot find type `Func` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/calls.rs:161:23
    |
161 | let func: Func<u32, u32> = instance.func(name)?;
    | ^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
1 | use parity_wasm::elements::Func;
    |

error[E0412]: cannot find type `Func` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/calls.rs:165:23
    |
165 | let func: Func<(u32, u32), u32> = instance.func(name)?;
    | ^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
1 | use parity_wasm::elements::Func;
    |

error[E0412]: cannot find type `NonNull` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/context.rs:177:29
    |
177 | wasmer_instance: Option<NonNull<WasmerInstance>>,
    | ^^^^^^^ not found in this scope
    |
help: possible candidates are found in other modules, you can import them into scope
    |
6 | use core::ptr::NonNull;
    |
6 | use std::ptr::NonNull;
    |

error[E0412]: cannot find type `WasmerInstance` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/context.rs:177:37
    |
175 | pub fn set_wasmer_instance<S: Storage, Q: Querier>(
    | - help: you might be missing a type parameter: `, WasmerInstance`
176 | ctx: &mut Ctx,
177 | wasmer_instance: Option<NonNull<WasmerInstance>>,
    | ^^^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `WasmTypeList` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/context.rs:297:11
    |
297 | Args: WasmTypeList,
    | ^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `WasmTypeList` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/context.rs:298:11
    |
298 | Rets: WasmTypeList,
    | ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `Func` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/context.rs:299:22
    |
299 | Callback: FnOnce(Func<Args, Rets, Wasm>) -> VmResult<CallbackData>,
    | ^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
6 | use parity_wasm::elements::Func;
    |

error[E0412]: cannot find type `Wasm` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/context.rs:299:39
    |
299 | Callback: FnOnce(Func<Args, Rets, Wasm>) -> VmResult<CallbackData>,
    | ^^^^ not found in this scope
    |
help: there is an enum variant `cosmwasm_std::CosmosMsg::Wasm` and 1 other; try using the variant's enum
    |
299 | Callback: FnOnce(Func<Args, Rets, cosmwasm_std::CosmosMsg>) -> VmResult<CallbackData>,
    | ^^^^^^^^^^^^^^^^^^^^^^^
299 | Callback: FnOnce(Func<Args, Rets, cosmwasm_std::QueryRequest>) -> VmResult<CallbackData>,
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: you might be missing a type parameter
    |
289 | pub(crate) fn with_func_from_context<S, Q, Args, Rets, Callback, CallbackData, Wasm>(
    | ^^^^^^

error[E0425]: cannot find function `get_memory_info` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:219:10
    |
219 | (get_memory_info(self.inner.context()).size as u64) * WASM_PAGE_SIZE
    | ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `WASM_PAGE_SIZE` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:219:63
    |
219 | (get_memory_info(self.inner.context()).size as u64) * WASM_PAGE_SIZE
    | ^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `Func` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:246:20
    |
246 | let alloc: Func<u32, u32> = self.func("allocate")?;
    | ^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
4 | use parity_wasm::elements::Func;
    |

error[E0425]: cannot find function `to_u32` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:247:30
    |
247 | let ptr = alloc.call(to_u32(size)?)?;
    | ^^^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
4 | use crate::conversion::to_u32;
    |

error[E0412]: cannot find type `Func` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:259:22
    |
259 | let dealloc: Func<u32, ()> = self.func("deallocate")?;
    | ^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
4 | use parity_wasm::elements::Func;
    |

error[E0425]: cannot find function `read_region` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:267:9
    |
267 | read_region(self.inner.context(), region_ptr, max_length)
    | ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `write_region` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:273:9
    |
273 | write_region(self.inner.context(), region_ptr, data)?;
    | ^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `WasmTypeList` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:280:15
    |
280 | Args: WasmTypeList,
    | ^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `WasmTypeList` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:281:15
    |
281 | Rets: WasmTypeList,
    | ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `Func` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:278:67
    |
278 | pub(crate) fn func<Args, Rets>(&self, name: &str) -> VmResult<Func<Args, Rets, Wasm>>
    | ^^^^ not found in this scope
    |
help: possible candidate is found in another module, you can import it into scope
    |
4 | use parity_wasm::elements::Func;
    |

error[E0412]: cannot find type `Wasm` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/instance.rs:278:84
    |
278 | pub(crate) fn func<Args, Rets>(&self, name: &str) -> VmResult<Func<Args, Rets, Wasm>>
    | ^^^^ not found in this scope
    |
help: there is an enum variant `cosmwasm_std::CosmosMsg::Wasm` and 1 other; try using the variant's enum
    |
278 | pub(crate) fn func<Args, Rets>(&self, name: &str) -> VmResult<Func<Args, Rets, cosmwasm_std::CosmosMsg>>
    | ^^^^^^^^^^^^^^^^^^^^^^^
278 | pub(crate) fn func<Args, Rets>(&self, name: &str) -> VmResult<Func<Args, Rets, cosmwasm_std::QueryRequest>>
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: you might be missing a type parameter
    |
64 | impl<S, A, Q, Wasm> Instance<S, A, Q>
    | ^^^^^^

error[E0405]: cannot find trait `Storage` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/testing/instance.rs:134:19
    |
134 | pub fn test_io<S: Storage + 'static, A: Api + 'static, Q: Querier + 'static>(
    | ^^^^^^^ not found in this scope
    |
help: possible candidates are found in other modules, you can import them into scope
    |
4 | use cosmwasm_std::Storage;
    |
4 | use crate::traits::Storage;
    |

error[E0405]: cannot find trait `Api` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/testing/instance.rs:134:41
    |
134 | pub fn test_io<S: Storage + 'static, A: Api + 'static, Q: Querier + 'static>(
    | ^^^ not found in this scope
    |
help: possible candidates are found in other modules, you can import them into scope
    |
4 | use cosmwasm_std::Api;
    |
4 | use crate::traits::Api;
    |

error[E0405]: cannot find trait `Querier` in this scope
   --> /home/p1/.cargo/git/checkouts/secretnetwork-2885a5c51d1243af/b171078/cosmwasm/packages/sgx-vm/src/testing/instance.rs:134:59
    |
134 | pub fn test_io<S: Storage + 'static, A: Api + 'static, Q: Querier + 'static>(
    | ^^^^^^^ not found in this scope
    |
help: possible candidates are found in other modules, you can import them into scope
    |
4 | use cosmwasm_std::Querier;
    |
4 | use crate::traits::Querier;
    |

error: aborting due to 27 previous errors

Some errors have detailed explanations: E0405, E0412, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `cosmwasm-sgx-vm`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

```

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [July 12, 2020, 11:55am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/5 "2020-07-12T11:55:34Z")

</div>

yikes  
what command did you run to get this output?

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [July 12, 2020, 11:58am UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/6 "2020-07-12T11:58:38Z")

</div>

also, please edit your last comment to surround the console output with triple back-ticks:  
```

It will make it a lot easier to read.  
Ideally paste big outputs to [pastebin.com](http://pastebin.com) and then link to it

---

<div class="post-metadata">

**Author:** ![plek](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@plek](https://forum.scrt.network/u/plek)\
**Post date:** [July 12, 2020, 12:18pm UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/7 "2020-07-12T12:18:41Z")

</div>

I’m getting it with any of `RUST_BACKTRACE=1 cargo unit-test `, `cargo integration-test`, or `cargo schema`.

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [July 12, 2020, 12:20pm UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/8 "2020-07-12T12:20:04Z")

</div>

alright, remove the `default-features = false` part from the `cosmwas-vm` line in `Cargo.toml` please 🙂

---

<div class="post-metadata">

**Author:** ![plek](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@plek](https://forum.scrt.network/u/plek)\
**Post date:** [July 12, 2020, 12:33pm UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/9 "2020-07-12T12:33:16Z")

</div>

Thanks, that helped!😉

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [July 12, 2020, 12:36pm UTC](https://forum.scrt.network/t/solved-compiling-cosmwasm-sgx-vm-error-e0432-unresolved-imports-cranelift/1838/10 "2020-07-12T12:36:12Z")

</div>

Happy to hear that!  
Definitely let us know if you run into any other issues or questions along the way 😃  
We’re still pre-testnet so we’re still polishing a lot of rough edges like this one.
