summary refs log tree commit diff stats
path: root/compiler/saturate.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-04-03 00:18:03 +0800
committerGitHub <noreply@github.com>2024-04-02 18:18:03 +0200
commita1602b0d852942e5649b50b1afc77f7c7cb4ad6c (patch)
tree0302957b10d5c77f1f0e9310aaac5a2f2caccf14 /compiler/saturate.nim
parent32fa7e2871f7e23a0b7ca056e8bb7f7f0e6cc6d1 (diff)
downloadNim-a1602b0d852942e5649b50b1afc77f7c7cb4ad6c.tar.gz
dynlib keeps exported functions alive in emscripten (#23469)
ref https://forum.nim-lang.org/t/11338

ref https://github.com/beef331/wasm3/blob/master/src/wasm3/exporter.nim

ref https://github.com/emscripten-core/emscripten/issues/6233

ref
https://github.com/emscripten-core/emscripten/blob/3.1.56/system/include/emscripten/em_macros.h#L10

`EMSCRIPTEN_KEEPALIVE` is a macro that is used to prevent unused
functions from being deadcode eliminated in emscripten, which is a
simple wrapper around `__attribute__((used))`. This PR follows suits and
expects dynlib is supposed to keep these functions alive. In the future,
`exportwasm` might be introduced.

After this PR, a function with `{.dynlib, exportc.}` can be reused from
other wasm programs reliably.
Diffstat (limited to 'compiler/saturate.nim')
0 files changed, 0 insertions, 0 deletions
d='n127' href='#n127'>127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191