emscripten ASSERTIONS=1 生成链接器错误 "Referencing global in another module!"

emscripten ASSERTIONS=1 generates linker error "Referencing global in another module!"

当我设置“-s ASSERTIONS=1”时,链接器将失败并显示大量 "Referencing global in another module!" 消息,例如:

Referencing global in another module! [16 x i8]* @_ZZN8nlohmann10basic_jsonINSt3__23mapENS1_6vectorENS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbxydS7_NS_14adl_serializerEE13escape_stringERKS9_E6hexify ; ModuleID = 'src/ui_lib/logic/libcommands.bc' [16 x i8]* @_ZZN8nlohmann10basic_jsonINSt3__23mapENS1_6vectorENS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbxydS7_NS_14adl_serializerEE13escape_stringERKS9_E6hexify ; ModuleID = 'src/ui_lib/curves.bc' Referencing global in another module! %"struct.ui::EmscriptenBindingInitializer_uicurves"* @_ZN5boost6detail15optional_detail13none_instanceINS_6none_tEE8instanceE ; ModuleID = 'src/ui_lib/logic/libcommands.bc' %"struct.ui::EmscriptenBindingInitializer_uicurves"* @_ZN5boost6detail15optional_detail13none_instanceINS_6none_tEE8instanceE ; ModuleID = 'src/ui_lib/curves.bc'

当我在多个翻译单元中使用 nlohmann::json (https://github.com/nlohmann/json) 的实例时会发生这种情况。

这是错误还是功能?我该如何解决?

这是一个 emscripten 错误:https://github.com/kripken/emscripten/issues/5008

修复非常简单:https://github.com/kripken/emscripten/pull/5021/commits/1b0d41d1845015491a52da2cb9f7da7dfe3acf44