调试 Makefile
让我用我对 Makefile 或 make 知之甚少的评论来开头这个问题。
有一个非常大的项目,每晚都会自动构建。它以调试和发布模式构建,调试用于像 Valgrind 这样的实用程序来提供代码分析。不知何故,一些构建的库在制作过程中丢失了调试标志,这使得一些分析输出毫无帮助。我的任务是找到错误,我需要一些关于如何定位/修复问题的建议。
提前致谢
Let me prefice this question with the comment that I know very little about Makefiles or make.
There is a very large project that is automatically built nightly. It is built in both Debug and Release mode, Debug being used for utilities like Valgrind to provide code analysis. Somehow, some of the built libraries are losing the debug flag during the make process, which makes some analysis output unhelpful. I was tasked with finding the bug and I need some suggestions on how to go about locating/repairing the issue.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
make 本身还支持调试标志 -d;根据您的 Makefile 相互调用的方式,可能可以传递它(如果没有,您可以使用脚本重写它们以实现此目的);然后,如果将结果输出提供给文件,您就可以开始寻找线索。
make itself also supports a debug flag, -d; depending on how your Makefiles call each other, it may be possible to pass it through (and if not, you can rewrite them to do so with a script); then if you feed the resulting output to a file you can start looking for clues.
鉴于信息稀疏,我只能根据我在少数大型项目的 Makefile 使用方面所看到的情况来勾勒出一个非常笼统的策略。
如果您还不知道这些标志的来源,请搜索 Makefile 来查找答案。
类似于:(
如果您的项目使用诸如 foo.mk 或 bar.mak 等包含的 Makefiles,则调整 -name 模式。如果您的调试标志是其他内容,则调整“-g”。)
您可能会发现它分配给像 CFLAGS 这样的变量。看看这个变量被赋值的地方,它可能是有条件设置的(例如
ifeq($(RELEASE),1)
)。现在查看库中未获取这些标志的 Makefile。找到编译命令所在的位置。它使用了正确的变量吗?这些 Makefile 是否覆盖了变量?
将构建的输出捕获到文件并搜索可能未设置调试标志的任何其他位置也可能会有所帮助。
Given the sparse information, I can only sketch a very general strategy based on what I've seen in terms of Makefile usage for a handful of large projects.
If you don't already know where the flags originate, search through the Makefiles to find out.
Something like:
(Adjusting the -name pattern if your project uses included Makefiles like foo.mk or bar.mak or something. And adjusting the "-g" if your debug flag is something else.)
You'll probably find it assigned to a variable like CFLAGS. Look around the spot where this variable is assigned, it is probably set conditionally (e.g.
ifeq($(RELEASE),1)
).Now look at the Makefile(s) in the library that isn't getting those flags. Find the spot where the compile command lives. Is it using the right variable? Are these Makefiles overriding the variable?
It may also be helpful to capture the output of a build to a file and search around for any other places that might not have the debug flags set.
使用重制版,确实不错
use remake, its really good