分析gcc -v的详细信息的意义
首先我们需要清楚一点,我们并不能完全弄清楚gcc -v的所有信息,因为毕竟我们并不是GCC编译器集合的实现者,对于这些信息,他们才是最清楚的。由于我们不能将所有的信息都搞清楚,所以我们只分析关键信息。虽然我们不能将所有信息都全部弄清楚,但是分析里面的关键信息还是非常有意义的,我们可以通过这些信息弄清楚很多事情,比如:
①通过这些信息,我就知道gcc其实最终还是调用ccp/cc1/as/collect2(或ld)等程序来实现编译的四个过程的。
②知道c的启动代码是怎么来的
③知道为什么在程序中调用printf、scanf、malloc等函数时,我们不需要主动链接这些函数的动态库,但是依然能够使用这些函数
gcc -v详细信息分析
源代码
#include <stdio.h> #include <stdlib.h> #define NUM 100 int main() { #if 0 printf("Test condition macro\n"); #endif printf("Hello World\n"); return 0; }
gcc test.c -o test -v
[root@localhost ~]# gcc test.c -o test -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.