Skip to content

Commit

Permalink
Fix EM_JS macro in the face of recent llvm change (#21403)
Browse files Browse the repository at this point in the history
A recent change to llvm (llvm/llvm-project#81539)
means that the `used` attribute on data forces the segment to be
present in the output file, even if it's not used.

The usage here in `em_js.h` was assuming that the data was not incldued
in the final output.  This change makes the symbol non-static instead
of used, which is enough to force clang to keep the data around but
not the linker (which is exactly the effect we want).
sbc100 authored Feb 23, 2024
1 parent a71c02c commit b69e44c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system/include/emscripten/em_js.h
Original file line number Diff line number Diff line change
@@ -61,7 +61,8 @@
#define _EM_JS(ret, c_name, js_name, params, code) \
_EM_BEGIN_CDECL \
ret c_name params EM_IMPORT(js_name); \
__attribute__((used)) static void* __em_js_ref_##c_name = (void*)&c_name; \
__attribute__((visibility("hidden"))) \
void* __em_js_ref_##c_name = (void*)&c_name; \
EMSCRIPTEN_KEEPALIVE \
__attribute__((section("em_js"), aligned(1))) char __em_js__##js_name[] = \
#params "<::>" code; \

0 comments on commit b69e44c

Please sign in to comment.