为什么使用clang的2阶段命令行构建不会生成dSYM目录? [英] Why does a 2-stage command-line build with clang not generate a dSYM directory?

查看:159
本文介绍了为什么使用clang的2阶段命令行构建不会生成dSYM目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



运行:



我有一个简单的项目,我想调试想要生成带有调试符号的dSYM文件夹

clang ++ -std = c ++ 14 -stdlib = libc ++ -g -o Lazy Lazy.cpp



按照我的预期创建Lazy.dSYM。



但是:

  clang ++ -std = c ++ 14 -stdlib = libc ++ -g -c Lazy.cpp 
clang ++ -stdlib = libc ++ -g -o Lazy Lazy.o

不创建Lazy.dSYM(似乎这些符号嵌入在二进制文件中)。



两步构建是我修改的makefile所做的。如何从两阶段编译链接生成Lazy.dSYM?



我不需要一个dSYM目录,只是调试符号,但是想了解它的创建时间和原因。

解决方案

完成.dSYM包的创建通过一个名为 dsymutil 的工具。当Apple添加了对DWARF调试信息的支持时,他们决定将可执行链接与调试信息链接分开。因此,调试信息链接不是由普通链接器完成的,它由 dsymutil 完成。



方便,当您一步一步构建程序时,编译器将代您调用 dsymutil 。这是因为它知道它具有所有的输入。如果您在编译命令中添加 -v (aka - verbose )选项,则会看到 dsymutil 作为它的最后一步。



在其他情况下,它不会这样做。它留下调试信息链接步骤供用户手动执行。您可以通过简单地发出命令:

  dsymutil Lazy 

这里是,他帮助设计和实施了苹果支持DWARF解释他们的想法。他也回答这个问题在这个堆栈溢出关于这个东西。


I have a simple project I want to debug want to produce dSYM folder with debugging symbols.

Running:

clang++ -std=c++14 -stdlib=libc++ -g -o Lazy Lazy.cpp

Creates Lazy.dSYM as I expect.

However:

clang++ -std=c++14 -stdlib=libc++ -g -c Lazy.cpp
clang++ -stdlib=libc++ -g -o Lazy Lazy.o

Does not create Lazy.dSYM (It seems that the symbols are embedded in the binary).

Sadly the 2-step build is what my modified makefile does. How can I generate Lazy.dSYM from a 2-stage compile-and-link build?

I don't need a dSYM directory, just debugging symbols, but would like to understand when and why it is created.

解决方案

The creation of the .dSYM bundle is done by a tool called dsymutil. When Apple added support for DWARF debugging information, they decided to separate "executable linking" from "debug information linking". As such, the debug information linking is not done by the normal linker, it's done by dsymutil.

As a convenience, when you build a program all in one step, the compiler invokes dsymutil on your behalf. That's because it knows it has all of the inputs. If you add the -v (a.k.a. --verbose) option to the compile command, you will see the invocation of dsymutil as the last step it does.

In other cases, though, it doesn't do that. It leaves the debug information linking step for the user to do manually. You can do it by simply issuing the command:

dsymutil Lazy

Here's an article by an Apple engineer who helped design and implement Apple's support for DWARF explaining their thinking. He also answered a question here on Stack Overflow about this stuff.

这篇关于为什么使用clang的2阶段命令行构建不会生成dSYM目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆