如何从 llvm / clang 打印依赖项(相当于 gcc -MD)?

发布于 2024-10-31 04:44:33 字数 145 浏览 2 评论 0原文

我们的构建系统在编译时使用 gcc 生成源文件对 *.d 文件的头依赖项:

gcc -MD -MF foo.d -c foo.o foo.cc 

但是,我不知道如何使用 llvm clang 生成类似的输出。

Our build system is using gcc to generate source file's header dependencies to *.d files, when compiling:

gcc -MD -MF foo.d -c foo.o foo.cc 

However, I can't figure out how to produce similar output with llvm clang.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爺獨霸怡葒院 2024-11-07 04:44:33

完全相同:

clang -MD -MF foo.d -c foo.o foo.cc 

一个例子:

$ cat example.c 
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("Hello, world!\n");
  return 0;
}

$ clang -MD -MF example-clang.d -c -o example-clang.o example.c

$ gcc -MD -MF example-gcc.d -c -o example-gcc.o example.c

$ cat example-clang.d 
example-clang.o: example.c /usr/include/stdio.h /usr/include/_types.h \
  /usr/include/sys/_types.h /usr/include/sys/cdefs.h \
  /usr/include/machine/_types.h /usr/include/i386/_types.h \
  /usr/include/secure/_stdio.h /usr/include/secure/_common.h

$ cat example-gcc.d 
example-gcc.o: example.c /usr/include/stdio.h /usr/include/_types.h \
  /usr/include/sys/_types.h /usr/include/sys/cdefs.h \
  /usr/include/machine/_types.h /usr/include/i386/_types.h \
  /usr/include/secure/_stdio.h /usr/include/secure/_common.h

$ diff example-clang.d example-gcc.d 
1c1
< example-clang.o: example.c /usr/include/stdio.h /usr/include/_types.h \
---
> example-gcc.o: example.c /usr/include/stdio.h /usr/include/_types.h \

It's exactly the same:

clang -MD -MF foo.d -c foo.o foo.cc 

An example:

$ cat example.c 
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("Hello, world!\n");
  return 0;
}

$ clang -MD -MF example-clang.d -c -o example-clang.o example.c

$ gcc -MD -MF example-gcc.d -c -o example-gcc.o example.c

$ cat example-clang.d 
example-clang.o: example.c /usr/include/stdio.h /usr/include/_types.h \
  /usr/include/sys/_types.h /usr/include/sys/cdefs.h \
  /usr/include/machine/_types.h /usr/include/i386/_types.h \
  /usr/include/secure/_stdio.h /usr/include/secure/_common.h

$ cat example-gcc.d 
example-gcc.o: example.c /usr/include/stdio.h /usr/include/_types.h \
  /usr/include/sys/_types.h /usr/include/sys/cdefs.h \
  /usr/include/machine/_types.h /usr/include/i386/_types.h \
  /usr/include/secure/_stdio.h /usr/include/secure/_common.h

$ diff example-clang.d example-gcc.d 
1c1
< example-clang.o: example.c /usr/include/stdio.h /usr/include/_types.h \
---
> example-gcc.o: example.c /usr/include/stdio.h /usr/include/_types.h \
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文