Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using voting in lib-crate makes this lib export cw_core functions on linux #483

Closed
Buckram123 opened this issue Sep 15, 2022 · 9 comments
Closed

Comments

@Buckram123
Copy link
Contributor

Buckram123 commented Sep 15, 2022

Short description

So, what happened: we have a lib that wants to import voting, and then contract depend on that lib, what happens:
cw-core gets imported (with everything)

Error

note: rust-lld: error: duplicate symbol: instantiate
          >>> defined in /code/target/wasm32-unknown-unknown/release/deps/duplicate_bug.duplicate_bug.8f61a3e5-cgu.0.rcgu.o
          >>> defined in /code/target/wasm32-unknown-unknown/release/deps/libcw_core-bfb32c933257001e.rlib(cw_core-bfb32c933257001e.cw_core.0b07bdab-cgu.0.rcgu.o)
          
          rust-lld: error: duplicate symbol: execute
          >>> defined in /code/target/wasm32-unknown-unknown/release/deps/duplicate_bug.duplicate_bug.8f61a3e5-cgu.0.rcgu.o
          >>> defined in /code/target/wasm32-unknown-unknown/release/deps/libcw_core-bfb32c933257001e.rlib(cw_core-bfb32c933257001e.cw_core.0b07bdab-cgu.0.rcgu.o)
          
          rust-lld: error: duplicate symbol: query
          >>> defined in /code/target/wasm32-unknown-unknown/release/deps/duplicate_bug.duplicate_bug.8f61a3e5-cgu.0.rcgu.o
          >>> defined in /code/target/wasm32-unknown-unknown/release/deps/libcw_core-bfb32c933257001e.rlib(cw_core-bfb32c933257001e.cw_core.0b07bdab-cgu.0.rcgu.o)

Minimal example

https://github.com/Buckram123/duplicate_example
This is minimal template from here: https://github.com/InterWasm/cw-template
One difference is here: https://github.com/Buckram123/duplicate_example/blob/57859b4e0997b7eba359b3da393ae55f2b563d30/duplicate-bug/src/msg.rs#L1
And instantiate method

Reproduce

To reproduce on my machine, simply run optimizer or just wasm

cargo build --release --target wasm32-unknown-unknown
docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/rust-optimizer:0.12.6

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08), (optimizer uses 1.60.0)
5.19.8-arch1-1

@Buckram123 Buckram123 changed the title Using voting in lib-crate makes this lib importing cw_core on linux Using voting in lib-crate makes this lib importing cw_core export functions on linux Sep 15, 2022
@Buckram123 Buckram123 changed the title Using voting in lib-crate makes this lib importing cw_core export functions on linux Using voting in lib-crate makes this lib export cw_core functions on linux Sep 15, 2022
@0xekez
Copy link
Contributor

0xekez commented Sep 22, 2022

thanks for reporting!

@Buckram123: cw-core gets imported (with everything)

can we get around this by adding the library feature to the cw-core import in voting, or is this something more complex? would just need to do that here:

cw-core = { path = "../../contracts/cw-core", version = "*"}

@de-husk
Copy link
Contributor

de-husk commented Sep 23, 2022

Contracts being used by other packages/contracts as library dependencies has caused other problems (and likely will be a hard to debug landmine for future devs even once these are ironed out). The ones I know about:

Honestly, I think we should see how bad it is to just split out the shared library code out of the contracts and into packages. What do you think?

I think its fine to keep them as dev-deps, and used by things that aren't depended on by other packages.

@Buckram123
Copy link
Contributor Author

@ezekiiel you are right it is enough, you can check fix branch here: https://github.com/Buckram123/duplicate_example

@Buckram123
Copy link
Contributor Author

@de-husk but I agree with you, IMO it's better to not use contracts as a dependency, should be easy to remove that dependency, it's only one function. What you think is the best solution?

@0xekez
Copy link
Contributor

0xekez commented Sep 27, 2022

definitely think @de-husk is right here. :) the structure of having a package with the external api and the contract is slick.

this would be a nice refactor to get in with the renaming work, but also adding library flags is fast 🤷‍♂️

@JakeHartnell
Copy link
Member

This would be a good thing to get in before the v2 release.

@JakeHartnell
Copy link
Member

@Buckram123 is this still an issue since we switch to rust workspaces?

@Buckram123
Copy link
Contributor Author

@Buckram123 is this still an issue since we switch to rust workspaces?

Don't think so, updated this repo, still same issue, if I didn't miss anything.
This time I used
rust-optimizer:0.12.10
which uses 1.65.0 rustc

@JakeHartnell
Copy link
Member

Closing. Feel free to re-open if it re-appears.

JakeHartnell pushed a commit that referenced this issue Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants