Hello, I had some issues while integrating v8 with the project I'm working on, so I have some questions and (maybe) a suggestion, and I'd like to hear what you think about that.
I was experiencing some cryptic std::bad_alloc errors. While investigating them, I realized that v8, by default, uses a sysroot image (Debian Wheezy for v8 5.4) to build itself (this fact is not mentioned anywhere in the Wiki <https://github.com/v8/v8/wiki/>). The use of a sysroot causes libv8.so to have weak versions of the symbols from the C++ standard library. However, if you link against libv8.so like this: $ clang++ -L/path/to/v8/out.gn/x64.debug -lv8 -o test test.cc These weak symbols override some symbols from the system's libstdc++.so, since the linker won't search for them in libstdc++.so after having found them in libv8.so. This can be seen by using the linker's trace-symbol option (I'll use std::__detail::_Prime_rehash_policy::_M_need_rehash, used by unordered_map, as an example, since this function was giving me trouble). $ # With v8 $ clang++ -std=c++11 -L/home/andre/Develop/v8/v8/out.gn/x64.debug -lv8 -Wl,--trace-symbol=_ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm -o test test.cc /tmp/andre/test-56ed0e.o: reference to _ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm /home/andre/Develop/v8/v8/out/x64.debug/obj.target/src/*libv8.so*: definition of _ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm $ # Without v8 $ clang++ -std=c++11 -Wl,--trace-symbol=_ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm -o test test.cc /tmp/andre/test-7b1f80.o: reference to _ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm /usr/bin/../lib/gcc/x86_64-redhat-linux/6.3.1/*libstdc++.so*: definition of _ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm What ended up happening in my project was that my cc files were compiled against the system's standard library, but v8 wasn't. That lead to the following scenario: 1. My code calls function X from the standard library. 2. Control flows to the version of function X present in the system's standard library. 3. Function X calls another function Y from the standard library. 4. Control moves to the version of function Y present in libv8.so, due to the linker's symbol resolution. 5. Error occurs due to different versions of the standard library. I found that I could pass use_sysroot=false to gn, and that solved the problem, since it produces a libv8.so that contains only undefined references to (instead of weak versions of) symbols from the standard library. (use_sysroot=false doesn't seem to work with gyp; I know gyp support is deprecated, but I'm mentioning it anyway). So, my question for you is: is this behavior expected? If I'm integrating v8 with a project of mine, should I always compile it with use_sysroot=false? If that is the case, shouldn't this fact be mentioned in the Wiki? Thank you, and apologies for the long email. Andre -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.