Skip to content

Commit

Permalink
Fix EM_JS macro in the face of recent llvm change
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).
  • Loading branch information
sbc100 committed Feb 23, 2024
1 parent 34c83d8 commit fd0a998
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion system/include/emscripten/em_js.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#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; \
void* __em_js_ref_##c_name = (void*)&c_name; \
EMSCRIPTEN_KEEPALIVE \
__attribute__((section("em_js"), aligned(1))) char __em_js__##js_name[] = \
#params "<::>" code; \
Expand Down

0 comments on commit fd0a998

Please sign in to comment.