0

Here are some details:

  • Host/Test OS, Toolchain:

    Linux Mint 19.3 Tricia (Ubuntu 18.04), GCC 7
    
  • V8 GN build arguments:

     is_debug=true
     target_os="linux"
     target_cpu="x64"
     is_clang = false
     is_component_build=false
     use_glib=false
     use_custom_libcxx = false
     v8_static_library=true
     v8_enable_i18n_support=false
     v8_use_external_startup_data=false
    

The v8 engine is successfully built and I got all expected static libraries. Then I tried to build Hello_World app (provided in v8 source), linking with generated static libs. I got the following linking errors:

/usr/bin/g++-7 -o ./build-Debug/bin/Hello_World @./build-Debug//ObjectsList.txt -L. -L../../out.gn/linux.x86_64.Debug -L../../out.gn/linux.x86_64.Debug/obj -L../../out.gn/linux.x86_64.Debug/obj/tools/debug_helper -L../../out.gn/linux.x86_64.Debug/obj/third_party/zlib -L../../out.gn/linux.x86_64.Debug/obj/third_party/zlib/google  -lv8_libbase -lv8_libplatform -lv8_base_without_compiler -lv8_bigint -lv8_compiler_opt -lv8_compiler -lv8_cppgc_shared -lv8_debug_helper -lv8_init -lv8_initializers -lv8_snapshot -lchrome_zlib -ltorque_base -ltorque_ls_base -ltorque_generated_initializers -ltorque_generated_definitions -lwee8 -lcompression_utils_portable -lpthread

../../out.gn/linux.x86_64.Debug/obj/torque_generated_initializers/promise-misc-tq-csa.o: In function `v8::internal::PromiseInit_0(v8::internal::compiler::CodeAssemblerState*, v8::internal::TNode<v8::internal::JSPromise>)':
/media/hongkun/Windows/Users/hongkun/v8/v8/out.gn/linux.x86_64.Debug/gen/torque-generated/src/builtins/promise-misc-tq-csa.cc:297: undefined reference to `v8::internal::PromiseBuiltinsAssembler::ZeroOutEmbedderOffsets(v8::internal::TNode<v8::internal::JSPromise>)'
../../out.gn/linux.x86_64.Debug/obj/torque_generated_initializers/promise-misc-tq-csa.o: In function `v8::internal::InnerNewJSPromise_0(v8::internal::compiler::CodeAssemblerState*, v8::internal::TNode<v8::internal::Context>)':
/media/hongkun/Windows/Users/hongkun/v8/v8/out.gn/linux.x86_64.Debug/gen/torque-generated/src/builtins/promise-misc-tq-csa.cc:377: undefined reference to `v8::internal::PromiseBuiltinsAssembler::AllocateJSPromise(v8::internal::TNode<v8::internal::Context>)'
../../out.gn/linux.x86_64.Debug/obj/torque_generated_initializers/promise-misc-tq-csa.o: In function `v8::internal::NewJSPromise_2(v8::internal::compiler::CodeAssemblerState*, v8::internal::TNode<v8::internal::Context>, v8::Promise::PromiseState, v8::internal::TNode<v8::internal::Object>)':
/media/hongkun/Windows/Users/hongkun/v8/v8/out.gn/linux.x86_64.Debug/gen/torque-generated/src/builtins/promise-misc-tq-csa.cc:1143: undefined reference to `v8::internal::PromiseBuiltinsAssembler::ZeroOutEmbedderOffsets(v8::internal::TNode<v8::internal::JSPromise>)'

Obviously, linker cannot find the class v8::internal::PromiseBuiltinsAssembler in any of the provided libraries. I have added all generated v8 libraries in the linker options.

How can I fix this error? Thanks for any suggestions.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Hongkun Wang
  • 717
  • 8
  • 22

1 Answers1

0

Neither PromiseBuiltinsAssembler nor promise-misc-tq-csa.o should go into final binaries, both are only used by mksnapshot.

Have you tried following the official documentation?

jmrk
  • 34,271
  • 7
  • 59
  • 74
  • Frankly, this is only my third day of building v8 and embed it in an app. In past two days, I have made it working on Windows and macOS. Today I started doing it on Linux. I tried to follow offcial docs but may be not 100% precisely. Is there GN build options I should have used to avoid this issue? – Hongkun Wang May 10 '21 at 22:11
  • Double checked the v8 official docs, there is not much differences in instructions for Linux from thoese for Windows / macOS (except the build dependencies), so I have no clue what I missed for Linux. – Hongkun Wang May 10 '21 at 22:17
  • Following the official instructions (including GN args and command lines mentioned there) avoids this issue. – jmrk May 11 '21 at 18:27
  • @jmrk Could you please provide the link to the "Command lines mentioned there "? – Shikha Shah Dec 09 '22 at 15:33
  • @ShikhaShah The link is already in my answer: https://v8.dev/docs/embed#run-the-example – jmrk Dec 09 '22 at 16:18