I am attempting to build CPython 2.7 using jallwine's instructions at [1], however I am making one big change: I am using a modern version of Emscripten (1.35.0) rather than the old_shared_libs branch (which is circa May 2013). I have gotten pretty far, although I am stuck on one point: accessing global variables from JavaScript.
Emscripten@old_shared_libs used to support a "-s NAMED_GLOBALS=1" option, which makes globals in CPython such as "Py_NoSiteFlag" accessible from the JS top-level environment. After export I could write to such a global using code like "setValue(_Py_NoSiteFlag, 1, 'i32');". However in the latest version of Emscripten I am having trouble performing the same types of global variable accesses.
Emscripten@master (1.35.0) does not recognize the "-s NAMED_GLOBALS=1" option. It does however recognize `-s EXPORTED_GLOBALS="['_Py_NoSiteFlag']"`, which I'm guessing works similarly to the EXPORTED_FUNCTIONS option. Unfortunately adding the EXPORTED_GLOBALS flag to all the same compile steps as EXPORTED_FUNCTIONS does not appear to actually export any globals where I can find them. Certainly not at the `Module._Py_NoSiteFlag` location, which is what I'd expect.
I am unable to find any documentation about accessing C globals from JavaScript. In particular the guide documentation at [2] does not make any mention.
Is there any obvious I am doing wrong here? Is using EXPORTED_GLOBALS the right approach? If so, does anyone have a small program making use of EXPORTED_GLOBALS that I could examine to determine the appropriate usage, given the apparent lack of documentation?
- David