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

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.

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?

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

1 Like

@adi can you pls take a look

1 Like

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!

1 Like

hi @adi I already got the issue 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.

1 Like

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.
After I run discovery compile -s ASSERTIONS=1, it gave me a bunch of errors which I’m gonna show below:

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?

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

 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!

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

2 Likes

hi @adi, any lucks on this one?

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!

2 Likes

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

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 :slight_smile: … happens if you don’t change the name in Cargo.toml file

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

1 Like

hi @adi, i found some information here & here relating to my issue.

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

Thank you.

1 Like

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.

1 Like

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

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

1 Like