编译gcc时关于工具链的调整

来源:互联网 发布:阿里云代理商返点 编辑:程序博客网 时间:2024/06/04 18:17

例如:把链接器指向/tools 目录中的版本
SPECS=`dirname $(gcc -print-libgcc-file-name)`/specs
gcc -dumpspecs | sed \
  -e 's@/lib\(64\)\?/ld@/tools&@g' \
  -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS
echo "New specs file is: $SPECS"
unset SPECS

再设置成默认值
gcc -dumpspecs | sed -e 's@/tools@@g' \
    -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
    -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \
    `dirname $(gcc --print-libgcc-file-name)`/specs



验证GCC 工作是否正常

echo "int main(){}" > dummy.c
gcc -v -Wl,--verbose &>dummy.log dummy.c

验证dynamic linker
readelf -l a.out | grep ': /lib'

验证 startfiles

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log

验证 search header files

grep -B2 '^ /usr/include' dummy.log

验证 search libraries path

grep 'SEARCH.*/usr/lib' dummy.log | sed 's|; |\n|g'

验证 correct libc

grep "/lib.*/libc.so.6 " dummy.log

验证 使用 correct dynamic linker

grep "found" dummy.log
原创粉丝点击