我正在尝试从这里运行 V8 引擎的示例:Getting started with embedding V8 。输出静态库是在 Release模式下构建的,位于out.gn/libv8_monolith.a,并且其中显然没有调试符号。
该示例可以在 Release模式下构建并良好运行:
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 选项在 Debug模式下构建 hello-world 示例时,请添加如下命令结尾:
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
出现大量这种格式的警告,编译器卡住了:
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
我很确定我不想调试任何 V8 引擎的源代码。相反,我只想调试 hello-world。
上次我尝试此操作时,调试标志仍然工作正常,我仍然可以使用 VS Code 中嵌入的 lldb 来调试 hello-world 源代码。
我不确定最近几天 MacOS 是否更新了。
最佳答案
我终于明白了。我实际上需要做的是将runtime.cpp构建为带有调试标志的运行时对象:
clang++ -I/Users/chientran/localDocs/v8_engine/v8/include -c runtime.cpp -o runtime_debug.o -std=c++17 -g
然后将运行时对象与不带调试标志的 v8 引擎静态库链接:
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
关于debugging - 在 Debug模式下链接 v8 引擎静态库时出现 clang 警告 "could not find object file symbol for symbol",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67420246/