繁体   English   中英

在64位Debian上为GCC编译CodeViz补丁

[英]Compiling CodeViz patch for GCC on 64 bit debian

我正在尝试在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禁用。

还要查看src / gcc / toplev.c的gcc-4.6-4.6.3 / debian / patches / fix-warnings.diff以及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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM