debugging - 在 Debug模式下链接 v8 引擎静态库时出现 clang 警告 "could not find object file symbol for symbol"

标签 debugging clang static-libraries cannot-find-symbol

我正在尝试从这里运行 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/

相关文章:

c++ - 为什么使用 clang 的 2 阶段命令行构建不会生成 dSYM 目录?

java - 如何调试部署在 jar 文件中的 stub 类?

ios - 链接器命令失败,退出代码为1

c - ffmpeg 与 CodeBlocks 的链接错误

Linux - 有没有办法拥有一个包含资源的简单静态库?

c - 使用 GDB : I crash (segfault). 我怎样才能看到导致它的代码行?

debugging - 应用程序调试在 Visual Studio 2012 中的经典 ASP 调试中被禁用

c++ - 在 clang 插件中,如何查看编译翻译单元是否出错?

c++ - 在 10.15 之前的 mac 版本上,llvm 9 是否支持 std::filesystem?

ios - 如何为 armv6、armv7 和 i386 构建胖静态库