Commit 239a057
committed
reorder
This helps ensure that `libc.so` is instantiated first, which matters because
other libraries like `libunwind.so` have start functions which call functions
like `__wasm_set_tls_base` imported from `libc.so`.
Specifically, there's a dependency cycle between `libc.so` and the application
`.so` because `libc.so` imports `__main_argc_argv` and the application `.so`
imports a bunch of stuff from `libc.so`. `wit-component` will try to break that
cycle by having the synthesized `env` module re-export functions using
`call_indirect`, but that only works if the start functions of each library
participating in the cycle don't call imports from each other, since the table
used by the `call_indirect` calls is only initialized as part of the last
`__init` module's instantiation. `wit-component` isn't smart enough inspect the
code and figure all that out, but it will attempt to preserve the order
libraries were specified (programatically or via the CLI), so if we specify
`libc.so` first, it will be instantiated first in its "cyclical dependency"
group.wasm-tools component link arguments1 parent 6683f1b commit 239a057
1 file changed
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | 176 | | |
178 | | - | |
| 177 | + | |
179 | 178 | | |
180 | 179 | | |
181 | 180 | | |
| |||
0 commit comments