anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
107 stars 32 forks source link

[Bug] Support compiling a multimodule package with entry functions in multiple modules #369

Closed dmakarov closed 10 months ago

dmakarov commented 10 months ago

🐛 Bug multiple entrypoint glue functions are generated for a single multimodule package

The current implementation of entrypoint glue code assumes all entry functions are located in a single module of a Move package. If multiple modules contain entry functions, multiple conflicting entrypoint glue functions will be generated.

To reproduce

An example package is located at language/solana/examples/multimodule

$ cargo run --features solana-backend -p move-cli --bin move -- build --arch solana -p language/solana/examples/multi_module
     Running `target/debug/move build --arch solana -p language/solana/examples/multi_module`
COMPILING MoveStdlib, multi_module to SOLANA
linking with lld failed. stderr:

ld.lld: error: duplicate symbol: main
>>> defined at modules.move
>>>            ./build/solana/multi_module/0x7__B.o:(main)
>>> defined at modules.move
>>>            ./build/solana/multi_module/0x7__A.o:(.text+0x180)
 Failed to compile Move into SOLANA ERROR

Error: linking with lld failed. stderr:

ld.lld: error: duplicate symbol: main
>>> defined at modules.move
>>>            ./build/solana/multi_module/0x7__B.o:(main)
>>> defined at modules.move
>>>            ./build/solana/multi_module/0x7__A.o:(.text+0x180)

Expected Behavior

A single entrypoint glue function is generated that can route calls to entry functions in proper modules.

Additional context

This is necessary for resolving issue #161.