Sorry for the confusion here - yes, EXPORTED_GLOBALS is obsolete (it was
only supported before fastcomp). I removed it from settings.js now.

Yes, the proper way to do this is to create global accessor functions, and
export those.

On Tue, Nov 10, 2015 at 10:41 AM, David Foster <davidf...@gmail.com> wrote:

> Odd. I am no longer able to find the mention of EXPORTED_GLOBALS in
> emscripten.h, which is where I think I learned about it. So perhaps that
> option does not in fact exist.
>
> In the meantime I've worked around the inability to access globals
> directly by creating accessor functions that get/set the appropriate global
> variables. Then I've exported those accessors via EXPORTED_FUNCTIONS.
> Appears to work.
>
> - David
>
> On Monday, November 9, 2015 at 8:19:28 PM UTC-8, David Foster wrote:
>>
>> 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
>>
>> [1]
>> https://github.com/jallwine/emscripten_test/wiki/Compiling-python-with-emscripten
>> [2]
>> https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
>>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to