diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2024-07-19 03:27:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-19 03:27:46 -0500 |
| commit | 986d6bf9fb7aeb3032014183cdd7c30d90810360 (patch) | |
| tree | b4febbf4ea14cca50c9653ae66e0d491d4b97a04 /compiler/rustc_pattern_analysis/src/errors.rs | |
| parent | 3d68afc9e821b00d59058abc9bda670b07639955 (diff) | |
| parent | 1de046fa24a8a0304be274963b43819cfe56013a (diff) | |
| download | rust-986d6bf9fb7aeb3032014183cdd7c30d90810360.tar.gz rust-986d6bf9fb7aeb3032014183cdd7c30d90810360.zip | |
Rollup merge of #121533 - ratmice:wasm_init_fini_array, r=nnethercote
Handle .init_array link_section specially on wasm
Given that wasm-ld now has support for [.init_array](https://github.com/llvm/llvm-project/blob/8f2bd8ae68883592a333f4bdbed9798d66e68630/llvm/lib/MC/WasmObjectWriter.cpp#L1852), it appears we can easily implement that section by falling through to the normal path rather than taking the typical custom_section path for wasm.
The wasm-ld appears to have a bunch of limitations. Only one static with the `link_section` in a crate or else you hit the fatal error in the link above "only one .init_array section fragment supported". They do not get merged.
You can still call multiple constructors by setting it to an array.
```
unsafe extern "C" fn ctor() {
println!("foo");
}
#[used]
#[link_section = ".init_array"]
static FOO: [unsafe extern "C" fn(); 2] = [ctor, ctor];
```
Another issue appears to be that if crate *A* depends on crate *B*, but *A* doesn't call any symbols from *B* and *B* doesn't `#[export_name = ...]` any symbols, then crate *B*'s constructor will not be called. The workaround to this is to provide an exported symbol in crate *B*.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
