我正在尝试编译CodeViz在 64 位 Debian 上。但是,我发现包含的 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
到规则.patch
nano gcc-4.6-4.6.3/debian/rules.patch
debian_patches += \
libstdc++-pic \
...
gcc-4.6.2-cdepn \
主要错误发生是因为函数fprintf。 The default compiler flags includes -Wformat -Wformat-security这就是导致此错误的原因。在 CPPFLAGS 或/和 CFLAGS 中使用 -Wformat=0 或 -Wno-format-security 禁用。
另请参阅 gcc-4.6-4.6.3/debian/patches/fix-warnings.diff 中的 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
关于c++ - 在 64 位 debian 上编译 GCC 的 CodeViz 补丁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20853313/