# Got error "linking with rust-lld failed: exit code: 1" when compiling contracts in examples

**URL:** <https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987>\
**Category:** Developer Help\
**Created:** [July 15, 2019, 10:23am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987 "2019-07-15T10:23:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 15, 2019, 10:23am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/1 "2019-07-15T10:23:56Z")

</div>

Hi guys,

When compiling the `simple_calculator` contract, it seems that it cannot generate `contract.wasm` because of this error “linking with `rust-lld` failed: exit code: 1” (The same error happens when I compiled the other examples).

You can check full error logs [here](https://forum.scrt.network/t/error-installing-discovery-cli/917/25).

And I tried some ways to rebuild it, such as add option linker “RUSTFLAGS=’-C linker=rust-lld’ cargo build --release --target wasm32-unknown-unknown --verbose” when recompiling it , but still got same error.

Can you please take a look?

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 16, 2019, 8:32am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/2 "2019-07-16T08:32:26Z")

</div>

hey guys, any updates on this one? Please help me.

---

<div class="post-metadata">

**Author:** ![can](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/can/32/596_2.png) [@can](https://forum.scrt.network/u/can)\
**Post date:** [July 18, 2019, 2:56pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/3 "2019-07-18T14:56:42Z")

</div>

@adi can you pls take a look

---

<div class="post-metadata">

**Author:** ![adi](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@adi](https://forum.scrt.network/u/adi)\
**Post date:** [July 18, 2019, 5:12pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/4 "2019-07-18T17:12:41Z")

</div>

> [@arookie](#):
>
> linking with `rust-lld` failed: exit code: 1

Hey @arookie!

Looking into this, unable to reproduce on my end at the moment, so will continue digging. From the looks of it, it seems like you are building things more manually. Have you tried using the `discovery-cli` to compile the `simple_calculator` and other example contracts. That’s our recommended way of playing around with the examples and writing your own secret contracts, and I don’t believe there should be an issue with that at the moment…but let me know if you see otherwise!

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 19, 2019, 2:26am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/5 "2019-07-19T02:26:47Z")

</div>

hi @adi I already got [the issue](https://forum.scrt.network/t/error-installing-discovery-cli/917/25) when installing `discovery-cli`, so I used the docker to build instead.  
I will try to rebuild the brand-new env and let you know the result later.

Btw, for `discovery-cli`, I tried to downgrade node version to v10 and it’s working now.

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 21, 2019, 2:26pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/6 "2019-07-21T14:26:37Z")

</div>

hi @adi, can you please help to take a look? Once again, I still cannot compile the contract `millionaires_problem`, I just followed the 2nd part of [dev guide](https://blog.enigma.co/getting-started-with-enigma-an-intro-to-secret-contracts-cdba4fe501c2).  
After I run `discovery compile -s ASSERTIONS=1`, it gave me a bunch of errors which I’m gonna show below:

```auto
warning: unused attribute                                                                                                                                                                                          
  --> src/lib.rs:43:5                                                                                                                                                                                              
   |                                                                                                                                                                                                               
43 | #[no_mangle]                                                                                                                                                                                              
   | ^^^^^^^^^^^^                                                                                                                                                                                              
   |                                                                                                                                                                                                               
   = note: #[warn(unused_attributes)] on by default                                                                                                                                                                
                                                                                                                                                                                                                   
warning: unused attribute                                                                                                                                                                                          
  --> src/lib.rs:53:5                                                                                                                                                                                              
   |                                                                                                                                                                                                               
53 | #[no_mangle]                                                                                                                                                                                              
   | ^^^^^^^^^^^^                                                                                                                                                                                              
                                                                                                                                                                                                                   
error: linking with `rust-lld` failed: exit code: 1                                                                                                                                                                
  |                                                                                                                                                                                                                
  = note: "rust-lld" "-flavor" "wasm" "--no-threads" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "--export-dynamic" "--no-entry" "-L" "/home/vagrant/.rustup/t
oolchains/nightly-2019-05-20-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/rele
ase/deps/contract.contract.2yh5mw4u-cgu.1.rcgu.o" "-o" "/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/deps/contract.wasm" "--export" "fun
ction_name" "--export" "deploy" "--export" "call" "--export" "args" "--export" "print" "--gc-sections" "-O2" "-L" "/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-
unknown-unknown/release/deps" "-L" "/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/release/deps" "-L" "/home/vagrant/.rustup/toolchains/nightly-2019-05-20-x86_64-unknown
-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/home/vagrant/.rustup/toolchains/nightly-2019-05-20-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-c2f76c4d0d77f31b.rlib"
 "--no-entry"                                                                                                                                                                                                      
  = note: rust-lld: error: failed to open /vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/deps/contract.wasm: Invalid argument             
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
error: aborting due to previous error                                                                                                                                                                              
                                                                                                                                                                                                                   
error: Could not compile `contract`.                                                                                                                                                                               
                                                                                                                                                                                                                   
To learn more, run the command again with --verbose.                                                                                                                                                               
Something went wrong compiling secret contract millionaires_problem, aborting.                                                                                                                                     
{ Error: ENOENT: no such file or directory, copyfile '/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/contract.wasm' -> '/vagrant/projects/
millionaires_problem_demo/build/secret_contracts/millionaires_problem.wasm'                                                                                                                                        
    at Object.copyFileSync (fs.js:1728:3)                                                                                                                                                                          
    at Object.module.exports.compile (/home/vagrant/.nvm/versions/node/v10.16.0/lib/node_modules/@enigmampc/discovery-cli/src/deps.js:135:8)                                                                       
    at process._tickCallback (internal/process/next_tick.js:68:7)                                                                                                                                                  
  errno: -2,                                                                                                                                                                                                       
  syscall: 'copyfile',                                                                                                                                                                                             
  code: 'ENOENT',                                                                                                                                                                                                  
  path:                                                                                                                                                                                                            
   '/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/contract.wasm',                                                                        
  dest:                                                                                                                                                                                                            
   '/vagrant/projects/millionaires_problem_demo/build/secret_contracts/millionaires_problem.wasm' }                                                                                                                
{ Error: ENOENT: no such file or directory, copyfile '/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/contract.wasm' -> '/vagrant/projects/
millionaires_problem_demo/build/secret_contracts/millionaires_problem.wasm'                                                                                                                                        
    at Object.copyFileSync (fs.js:1728:3)                                                                                                                                                                          
    at Object.module.exports.compile (/home/vagrant/.nvm/versions/node/v10.16.0/lib/node_modules/@enigmampc/discovery-cli/src/deps.js:135:8)                                                                       
    at process._tickCallback (internal/process/next_tick.js:68:7)                                                                                                                                                  
  errno: -2,                                                                                                                                                                                                       
  syscall: 'copyfile',                                                                                                                                                                                             
  code: 'ENOENT',                                                                                                                                                                                                  
  path:                                                                                                                                                                                                            
   '/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/contract.wasm',                                                                        
  dest:                                                                                                                                                                                                            
   '/vagrant/projects/millionaires_problem_demo/build/secret_contracts/millionaires_problem.wasm' }                                                                                                                
                                                                                                                                                                                                                   
:30                                                                                                                                                                                                                
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var __GLOBAL__ I_000101=Module[" __GLOBAL__ I_000101"]=asm[" __GLOBAL__ I_000101"];var __GLOBAL__ sub_I_ABIFunctions_cpp=Module[" __GLOBAL__ sub_I_ABIFunctions_cpp"]=asm
[" __GLOBAL__ sub_I_ABIFunctions_cpp"];var __GLOBAL__ sub_I_ABI_cpp=Module[" __GLOBAL__ sub_I_ABI_cpp"]=asm[" __GLOBAL__ sub_I_ABI_cpp"];var __GLOBAL__ sub_I_ASTJsonConverter_cpp=Module[" __GLOBAL__ sub_I_ASTJsonConverter
_cpp"]=asm[" __GLOBAL__ sub_I_ASTJsonConverter_cpp"];var __GLOBAL__ sub_I_AST_cpp=Module[" __GLOBAL__ sub_I_AST_cpp"]=asm[" __GLOBAL__ sub_I_AST_cpp"];var __GLOBAL__ sub_I_ArrayUtils_cpp=Module[" __GLOBAL__ sub_I_ArrayUti
ls_cpp"]=asm[" __GLOBAL__ sub_I_ArrayUtils_cpp"];var __GLOBAL__ sub_I_AsmAnalysis_cpp=Module[" __GLOBAL__ sub_I_AsmAnalysis_cpp"]=asm[" __GLOBAL__ sub_I_AsmAnalysis_cpp"];var __GLOBAL__ sub_I_CompilerContext_cpp=Module[
" __GLOBAL__ sub_I_CompilerContext_cpp"]=asm[" __GLOBAL__ sub_I_CompilerContext_cpp"];var __GLOBAL__ sub_I_CompilerStack_cpp=Module[" __GLOBAL__ sub_I_CompilerStack_cpp"]=asm["__GLO                                     
abort({"errno":-2,"syscall":"copyfile","code":"ENOENT","path":"/vagrant/projects/millionaires_problem_demo/secret_contracts/millionaires_problem/target/wasm32-unknown-unknown/release/contract.wasm","dest":"/vagr
ant/projects/millionaires_problem_demo/build/secret_contracts/millionaires_problem.wasm"}). Build with -s ASSERTIONS=1 for more info.                                                                              

```

And it also relates to `linking with rust-lld issue` which I reported few days ago.

Can you please take a closer look and give me advice?

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 21, 2019, 3:29pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/7 "2019-07-21T15:29:27Z")

</div>

hi @adi, if I run `cargo +nightly run`, I cannot compile the `eng-wasm` ☹  
How can it happen?  
Error logs:

```auto
 Compiling eng-wasm v0.1.3
error[E0432]: unresolved import `self::std::slice::SliceConcatExt`
  --> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/eng-wasm-0.1.3/src/internal_std.rs:11:9
   |
11 | pub use self::std::slice::SliceConcatExt;
   | ^^^^^^^^^^^^^^^^^^--------------
   | | |
   | | help: a similar name exists in the module: `SliceConcat`
   | no `SliceConcatExt` in `slice`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: Could not compile `eng-wasm`.

To learn more, run the command again with --verbose.

```

Please help!

---

<div class="post-metadata">

**Author:** ![adi](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@adi](https://forum.scrt.network/u/adi)\
**Post date:** [July 21, 2019, 7:55pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/8 "2019-07-21T19:55:06Z")

</div>

looking into this @arookie , hopefully will have something for you shortly!

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 23, 2019, 2:47am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/9 "2019-07-23T02:47:59Z")

</div>

hi @adi, any lucks on this one?

---

<div class="post-metadata">

**Author:** ![adi](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@adi](https://forum.scrt.network/u/adi)\
**Post date:** [July 23, 2019, 3:09pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/10 "2019-07-23T15:09:53Z")

</div>

Hey @arookie!

Been spending a fair amount of time on this and can’t reproduce, I believe these are all corollary issues to your initial setup (node, etc.). I think what’s best is if we start a private chat (via discord, feel free to DM me (@Adi#6679) to have more streamlined communication. I’ll draft up a initial setup post after we resolve your issue to help guide others that may run into similar problems in the future!

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 24, 2019, 2:03pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/11 "2019-07-24T14:03:43Z")

</div>

hi @adi, will get in touch with you tomorrow. I have sth need to be done today 😉 and back to Enigma tmr.

---

<div class="post-metadata">

**Author:** ![izokay](https://avatars.discourse-cdn.com/v4/letter/i/51bf81/32.png) [@izokay](https://forum.scrt.network/u/izokay)\
**Post date:** [July 26, 2019, 2:55am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/12 "2019-07-26T02:55:08Z")

</div>

I got a similar error compiling a contract. In my case I found deps.js looks for contract.wasm but

`secret_contracts/{CONTRACT_NAME}/target/wasm32-unknown-unknown/release/contract.wasm`

was named

`secret_contracts/{CONTRACT_NAME}/target/wasm32-unknown-unknown/release/{CONTRACT_NAME}.wasm`

fixed by manually renaming to contract.wasm and recompiling. Maybe this isn’t the right solution but it compiled 🙂 … happens if you don’t change the name in Cargo.toml file

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 26, 2019, 3:26am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/13 "2019-07-26T03:26:30Z")

</div>

hi @izokay, i got that issue even though I compile the example contracts.  
Btw, I will try your solution tonight.

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 28, 2019, 3:49am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/14 "2019-07-28T03:49:32Z")

</div>

hi @adi, i found some information [here](https://bugs.llvm.org/show_bug.cgi?id=40358) & [here](https://github.com/rustwasm/wasm-bindgen/issues/1136) relating to my issue.

I already dm you on Discord, if you have time, can you please help?

Thank you.

---

<div class="post-metadata">

**Author:** ![ainsley](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/ainsley/32/73_2.png) [@ainsley](https://forum.scrt.network/u/ainsley)\
**Post date:** [July 29, 2019, 7:49am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/15 "2019-07-29T07:49:41Z")

</div>

Hey @izokay and @arookie – can you confirm that you’re building using the CLI and in SW mode? At this time we can only support issues that arise in a controlled developer environment so it’s important that the setup is consistent.

---

<div class="post-metadata">

**Author:** ![arookie](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/arookie/32/845_2.png) [@arookie](https://forum.scrt.network/u/arookie)\
**Post date:** [July 29, 2019, 10:00am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/16 "2019-07-29T10:00:00Z")

</div>

hi @ainsley, yes. I met the issue with `discovery-cli` and using `sw` mode.

---

<div class="post-metadata">

**Author:** ![adi](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@adi](https://forum.scrt.network/u/adi)\
**Post date:** [July 29, 2019, 12:01pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/17 "2019-07-29T12:01:18Z")

</div>

Being handled offline at the moment, but will post findings to help others running into similar presetup issues

---

<div class="post-metadata">

**Author:** ![bmiller59](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/bmiller59/32/261_2.png) [@bmiller59](https://forum.scrt.network/u/bmiller59)\
**Post date:** [December 22, 2019, 11:23pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/18 "2019-12-22T23:23:12Z")

</div>

@adi @arookie Any notes on the resolution of this issue? I seem to be encountering something similar. Thank you.

---

<div class="post-metadata">

**Author:** ![bmiller59](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/bmiller59/32/261_2.png) [@bmiller59](https://forum.scrt.network/u/bmiller59)\
**Post date:** [December 27, 2019, 8:09pm UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/19 "2019-12-27T20:09:55Z")

</div>

If anyone else comes onto this thread looking for the resolution, this post from above helped me to resolve my issue: [Got error "linking with rust-lld failed: exit code: 1" when compiling contracts in examples](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/12)

I had to set the `name` field in my `Cargo.toml` to be `contract`. Creating a custom contract name causes the build to fail.

@taariq or @ainsley I recommend that be documented in the sample `Cargo.toml` files so people don’t change it! 😉

---

<div class="post-metadata">

**Author:** ![taariq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/taariq/32/291_2.png) [@taariq](https://forum.scrt.network/u/taariq)\
**Post date:** [December 28, 2019, 4:44am UTC](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987/20 "2019-12-28T04:44:22Z")

</div>

> [@bmiller59](#):
>
> @taariq or @ainsley I recommend that be documented in the sample `Cargo.toml` files so people don’t change it! 😉

Hmmm, just tried this and it compiled with any package name.  
I copied one of the examples into a new project and renamed the package in Cargo.toml, did i miss something?

My rustc version is 1.39.0, what’s yours?

[Next page](https://forum.scrt.network/t/got-error-linking-with-rust-lld-failed-exit-code-1-when-compiling-contracts-in-examples/987.md?page=2)
