在 64 位 debian 上编译 GCC 的代码可视化补丁



我正在尝试在 64 位 Debian 上编译 CodeViz。 但是,我发现包含的 GCC 补丁导致 GCC 无法编译。 当我提取 GCC 4.6 并手动编译它时(通过运行

$ ../gcc-4.6.4/configure --prefix=/home/jeremy/gcc-codeviz --enable-languages=c,c++ --disable-bootstrap
$ make

) 编译时没有错误。 但是,当我应用包含的补丁时,它失败并显示错误

/usr/bin/ld: ../libsupc++/.libs/libsupc++convenience.a(cp-demangle.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
../libsupc++/.libs/libsupc++convenience.a(cp-demangle.o): error adding symbols: Bad value
collect2: ld returned 1 exit status

补丁可以在这里看到 http://pastebin.com/djSQYe5a .它真的没有那么复杂,不会更改任何构建选项或包含,也不会使用任何高级语言功能。 我真的不明白这如何导致在原版 gcc 版本中未显示的链接错误。 此外,错误本身发生在"cp-demangle.o"中,我认为补丁甚至不应该触及它! 我最好的猜测是它与声明的 extern int cdepn_dump 或 tree.h 中函数的声明有关。

任何帮助,不胜感激。

这个补丁可以应用于 Debian gcc-4.6 的源代码

apt-get source gcc-4.6
cp gcc-4.6.2-cdepn.diff gcc-4.6-4.6.3/debian/patches

到 rules.patch

nano gcc-4.6-4.6.3/debian/rules.patch
debian_patches += 
        libstdc++-pic 
        ...
        gcc-4.6.2-cdepn 

发生主要错误是因为函数 fprintf。默认编译器标志包括 -Wformat -Wformat-security,这就是导致此错误的原因。在 CPPFLAGS 或/和 CFLAGS 中使用 -Wformat=0 或 -Wno-format-security 禁用。

另请参阅 gcc-4.6-4.6.3/debian/

patches/fix-warnings.diff for src/gcc/toplev.c 和 gcc-4.6-4.6.3/debian/rules2, dpkg-buildflags 仅供参考。

export DEB_BUILD_MAINT_OPTIONS=hardening=-all,-format
export DEB_CFLAGS_MAINT_APPEND=-fPIC,-Wformat=0,-Wno-format-security
export DEB_CPPFLAGS_MAINT_APPEND=-fPIC,-Wformat=0,-Wno-format-security
export DEB_CXXFLAGS_MAINT_APPEND=-fPIC,-Wformat=0,-Wno-format-security
dpkg-buildflags
dpkg-buildpackage -b -d -rfakeroot -us -uc

最新更新