Specifically, it looks like static class constructors for linked .a 
libraries are not invoked when the libcxx runtime is initialized. Since 
embind is relying on static class constructors being invoked at startup 
time, the bindings don't get generated. Here's the stack trace:

___cxx_global_var_init
__GLOBAL__sub_I_bind_cpp
asm.__GLOBAL__sub_I_bind_cpp
 __ATINIT__.push.func
callRuntimeCallbacks
ensureInitRuntime
doRun
run
...
Module.runMain

On Wednesday, December 9, 2015 at 3:48:18 PM UTC-8, arnab choudhury wrote:
>
> The issue seems to be related to static variable initialization. I dumped 
> the contents of the .a file using llvm-nm and am seeing the static binding 
> symbols. However, libcxx doesn't seem to be initializing the static when 
> its present in the .a file. Is this a known issue?
>
> On Friday, December 4, 2015 at 12:12:56 PM UTC-8, arnab choudhury wrote:
>>
>> Hi there
>>
>> I am currently using embind to generate bindings for my C++ code so that 
>> it can be invoked from non ASM JS code. I have a number of .a files that my 
>> project is generating. My goal initially was to add emscripten bindings to 
>> each .a file that my project was generating since each .a file has fairly 
>> self contained functionality that can be used by consumers of my project. 
>> However, I don't see any of the bindings exposed on my Module object when I 
>> link the .a file with client code to form the final JS. Is this a known 
>> issue with embind?
>>
>> To clarify, here's an example:
>>
>> a. Library customString.a has a customStringBindings.cpp file that gets 
>> built into customString.a. This bindings file specifies the following 
>> binding:
>> EMSCRIPTEN_BINDINGS(custom_string_module) {
>>     class_<CustomString>("CustomString")
>>         .constructor<const std::string&>()
>>         .function("toStdString", &CustomString::ToStdString)
>> }
>>
>> b. The final JS gets built with a link dependency on customString.a
>>
>> c. I have some custom non ASM JS that attempts to create a new custom 
>> string: var customString = new Module.CustomString("tempString");
>>
>> This doesn't seem to work and I see an error saying that the Module has 
>> no member named CustomString. However, if I move the bindings file into a 
>> separate CPP file that gets used in step b, I can access 
>> Module.CustomString just fine. Am I missing something here?
>>
>> Thanks!
>> -Arnab
>>
>>
>>

-- 
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