0

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.

Jeremy Salwen
  • 8,061
  • 5
  • 50
  • 73
  • according to http://fossies.org/linux/privat/codeviz-1.0.12.tar.gz/index_ap.html the packages has the `debian/` and specifically `debian/rules` file, which can be used to compile using `dpkg-buildpackage` program without needing to do "anything" – Noam Rathaus Dec 31 '13 at 07:08
  • I have tried this, as well as trying various debian patched versions of gcc. As for the debian/rules file, it just calls a bash script which downloads vanilla gcc, applies the patch, and compiles gcc as I did above. – Jeremy Salwen Dec 31 '13 at 07:11
  • ok, I thought u didn't notice – Noam Rathaus Dec 31 '13 at 07:12

1 Answers1

0

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
Community
  • 1
  • 1