简体   繁体   中英

Compiling CodeViz patch for GCC on 64 bit debian

I am trying to compile CodeViz on 64 bit Debian. However, I am finding that the included patch for GCC causes GCC not to compile. When I extract GCC 4.6 and compile it manually (by running

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

) it compiles without error. However, when I apply the included patch, it fails with the error

/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

The patch can be seen here http://pastebin.com/djSQYe5a . It's really not that complicated, doesn't change any build options or includes, and doesn't use any advanced language features. I really don't understand how this causes a linking error which doesn't show up in the vanilla gcc build. Furthermore, the error itself occurs in "cp-demangle.o", which I don't think should even be touched by the patch! My best guess is that it has something to do with the extern int cdepn_dump which is declared, or the declaration of the functions in tree.h.

Any help is appreciated.

This patch can be applied to the source of 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

to rules.patch

nano gcc-4.6-4.6.3/debian/rules.patch

debian_patches += \
        libstdc++-pic \
        ...
        gcc-4.6.2-cdepn \

The main error occurs because the function fprintf . The default compiler flags includes -Wformat -Wformat-security which is what gives this error. Disabled with -Wformat=0 or -Wno-format-security in CPPFLAGS or/and CFLAGS.

Also look to gcc-4.6-4.6.3/debian/patches/fix-warnings.diff for src/gcc/toplev.c and to gcc-4.6-4.6.3/debian/rules2, dpkg-buildflags just for information.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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