Fix linker error when building complex contracts
Created by: cmichi
Closes https://github.com/paritytech/cargo-contract/issues/198 and https://github.com/paritytech/ink/issues/701.
My understanding is that the linker error was a result of conflicting build artifacts in the target
directory.
The root contract is build with the ink-as-dependency
feature enabled for sub-contracts, whereas the sub-contracts are build without this flag. This results in the external function __ink_generate_metadata
(which is only build when ink-as-dependency
is disabled) not being available in the artifacts, but cargo still tries to reuse the artifacts. Hence the linker error.
I fixed it now by building sub-contracts into sub-folders of target/ink/
. This way all artifacts are separate.