Desperately need help embedding V8 on android with c++_shared

164 views
Skip to first unread message

Mike Farrell

unread,
Feb 4, 2021, 9:48:09 PM2/4/21
to v8-users
I'll start out by saying my engine uses c++_shared as the STL runtime.  This is absolutely critical for a 200+ line engine with dozens of dependencies that i've already got building and going this way.

I've spent 8 hours completely pulling my hair out trying to desperately get V8 to for the love of god just link properly without spamming 1000's of C++ linker errors.

I've tried literally everything I can think of.  Please please help me.  Android is the final build I have to do for a v8 integration.  

My current build args (I've tried just about every combination of these):
target_os = "android"
is_debug = false
is_clang = false
use_sysroot = false
v8_use_snapshot = true
treat_warnings_as_errors = false
target_cpu = "arm64"       # as v8gen.py assumes a simulator build.
v8_target_cpu = "arm64"
is_component_build = false
v8_enable_i18n_support = false
v8_monolithic = true
v8_static_library = true
v8_use_external_startup_data = false
use_custom_libcxx = false
use_custom_libcxx_for_host=false
use_libfuzzer=false
v8_enable_test_features=""
v8_experimental_extra_library_files=[]
v8_extra_library_files=[]
use_glib = false
use_drfuzz=false
android32_ndk_api_level = 19
android_ndk_major_version = 19
android_ndk_version = "r19"
android_sdk_platform_version = 19
android_sdk_version = 19
android64_ndk_api_level = 19

I've also manually changed -std=c++14 (not gnu) to match what I have in my engine, this also has no effect on the errors.  

Here's an example build line.  These settings are spot-on-exact with what i'm using my main engine's code.  

[2/82] ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/v8_compiler/compiler-source-position-table.o.d -DANDROID -DHAVE_SYS_UIO_H -DANDROID_NDK_VERSION_ROLL=r19_1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DENABLE_MINOR_MC -DV8_USE_SNAPSHOT -DV8_CONCURRENT_MARKING -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_EMBEDDED_BUILTINS -DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_TARGET_ARCH_ARM64 -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -I../.. -Igen -I../.. -Igen -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pipe -ffunction-sections -fno-short-enums --target=aarch64-linux-android19 -DHAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC=1 -mno-outline -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Wall -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comments -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-unused-parameter -fno-omit-frame-pointer -g1 -Wno-strict-overflow -Wno-return-type -O2 -fno-ident -fdata-sections -ffunction-sections -fvisibility=default -std=c++14 -Wno-narrowing -Wno-class-memaccess -fno-exceptions -fno-rtti --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -c ../../src/compiler/compiler-source-position-table.cc -o obj/v8_compiler/compiler-source-position-table.o



When I link with my engine I can't ever get past thousands of C++ related linker errors:


/Users/mike/comp/googlesource-android/v8/v8/out.gn/arm.release/obj/libv8_monolith.a(turbo-assembler.o): In function `~basic_stringbuf':

/Users/mike/comp/googlesource-android/v8/v8/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/iosfwd:130: undefined reference to `std::__1::basic_streambuf<char, std::__1::char_traits<char> >::~basic_streambuf()'

/Users/mike/comp/googlesource-android/v8/v8/out.gn/arm.release/obj/libv8_monolith.a(turbo-assembler.o): In function `~basic_ostringstream':

/Users/mike/comp/googlesource-android/v8/v8/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/iosfwd:136: undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::~basic_ostream()'

/Users/mike/comp/googlesource-android/v8/v8/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/iosfwd:136: undefined reference to `std::__1::basic_ios<char, std::__1::char_traits<char> >::~basic_ios()'

/Users/mike/comp/googlesource-android/v8/v8/out.gn/arm.release/obj/libv8_monolith.a(turbo-assembler.o): In function `~basic_stringbuf':

/Users/mike/comp/googlesource-android/v8/v8/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/iosfwd:130: undefined reference to `std::__1::basic_streambuf<char, std::__1::char_traits<char> >::~basic_streambuf()'

/Users/mike/comp/googlesource-android/v8/v8/out.gn/arm.release/obj/libv8_monolith.a(turbo-assembler.o): In function `~basic_ostringstream':

/Users/mike/comp/googlesource-android/v8/v8/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/iosfwd:136: undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::~basic_ostream()'

/Users/mike/comp/googlesource-android/v8/v8/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/iosfwd:136: undefined reference to `std::__1::basic_ios<char, std::__1::char_traits<char> >::~basic_ios()'

/Users/mike/comp/googlesource-android/v8/v8/out.gn/arm.release/obj/libv8_monolith.a(turbo-assembler.o): In function `~basic_stringbuf':


I'm really at my wits end here.  I simply cannot spend another 8 hour day on this with nothing to show for it.  

Mike Farrell

unread,
Feb 4, 2021, 11:04:45 PM2/4/21
to v8-users

More things I've tried .. that also gave me the exact same linker errors..  this is so frustrating

-fexceptions -frtti (my own host engine builds with these)

Mike Farrell

unread,
Feb 5, 2021, 12:39:12 PM2/5/21
to v8-users

I still need help...

questions -

How do I get the android build to stop using the C++ headers under "Release+Asserts/include" next to its own clang path?  Those are absolutely conflicting with the ones in my ndk.  If I move the dir out of the way, it builds the arm64 files fine, but the mac (host) builds fail to find c++ headers which brings me to..

I care zero about the host files, why is this thing building files for x64 mac when I'm trying to build for andriod??  Can I force the build system to skip building for mac and only build the android libs?  All I need is a working libv8_monolithic.a.  I care nothing about d8 or any unit tests or any of the other stuff.

Mike Farrell

unread,
Feb 5, 2021, 4:33:12 PM2/5/21
to v8-users
Okay.  Posting for the sad guy who lands here having the same problem and got no help.

I suspect nobody at google has tried building for android from a mac host before.

Everything above was required, but the biggest culprit was those "Release+Asserts/include/c++" headers which infected the arm build and conflicted with my final linker step.  I basically had to hack it to not use those headers (so it defaulted to the ones from my ndk toolchain) but ONLY for the arm64 build.  The host build still required those to be in place.  It took alot of messing around, but doing that that finally got it to link.

Reply all
Reply to author
Forward
0 new messages