Tran Chien
Tran Chien

Reputation: 629

clang++ warning "could not find object file symbol for symbol" when linking v8 engine's static library in debug mode

I'm trying to run V8 engine's samples from here: Getting started with embedding V8. The output static library is built in release mode, locate at out.gn/libv8_monolith.a and clearly has no debugging symbols in it.

The sample can be built and run well in release mode:

clang++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS

However, when I want to build the hello-world sample in debug mode by adding -g option add the end of the command like this:

clang++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS -g

Tons of warning with this format come out and the compiler stuck:

warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeListC2Ev
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeList5ClearEv
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeListC1Ev
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeListC2EOS1_
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeListC1EOS1_
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeListaSEOS1_
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeList6AppendEOS1_
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeList3AddENS1_5BlockE
warning: (x86_64)  could not find object file symbol for symbol __ZN5cppgc8internal8FreeList8AllocateEm
warning: (x86_64)  could not find object file symbol for symbol __ZNK5cppgc8internal8FreeList4SizeEv
warning: (x86_64)  could not find object file symbol for symbol __ZNK5cppgc8internal8FreeList7IsEmptyEv

I'm pretty sure that I don't want to debug any of V8 engine's source code. Instead, I just want to debug the hello-world.

The last time I tried this, debugging flag still working fine and I can still debug the hello-world source code with lldb embedded inside VS Code.

I'm not sure whether MacOS has been updated recent days or not.

Upvotes: 2

Views: 1706

Answers (1)

Tran Chien
Tran Chien

Reputation: 629

I finally figured it out. What I actually need to do is to build the runtime.cpp to runtime object with debug flag:

clang++ -I/Users/chientran/localDocs/v8_engine/v8/include -c runtime.cpp -o runtime_debug.o -std=c++17 -g

And then link the runtime object with v8 engine static library without debug flag:

clang++ -I/Users/chientran/localDocs/v8_engine/v8/include -o runtime_debug runtime_debug.o -lv8_monolith -L/Users/chientran/localDocs/v8_engine/v8/out.gn/x64.release.sample/obj -pthread -std=c++17 -DV8_COMPRESS_POINTERS

Upvotes: 2

Related Questions