OpenWrt Forum Archive

Topic: Bandwidthd package does not compile anymore in trunk

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Sorry is this is a trivial issue, but since Nov. 18, the package bandwidthd does not want to compile anymore in the trunk built (https://downloads.openwrt.org/snapshots/trunk/): I saw that yesterday afternoon (Nov. 22).  As the maintainer of the package, I would like to resolve the problem.  Take in  account that I am far from being a pro in C.  The package compile fine for the CC branch (I compiled it on Nov. 21st).

I saw that the GCC version changed in trunk, and I am wondering if that could be the source of the problem.

I therefore updated my built environment for trunk, rebuilt the tools and toolchain (vmebu) and tried to compile the package (after doing a make clean) and effectively, it does not compile anymore.  I want to fix the problem, but I would like some help to point me in the right direction.  Here is part of the compile message that I get with the compile (sorry for the length):

bandwidthd.c: In function 'RecoverDataFromCDF':
bandwidthd.c:1189:10: warning: variable 'logname2' set but not used [-Wunused-but-set-variable]
     char logname2[] = "log.1.1.cdf";
          ^
In file included from bandwidthd.c:1:0:
bandwidthd.c: At top level:
bandwidthd.h:218:17: warning: inline function 'DstCredit' declared but never defined
inline void     DstCredit(uint32_t ipaddr, unsigned int psize);
                 ^
In file included from bandwidthd.c:1:0:
bandwidthd.h:199:17: warning: inline function 'IpAddr' declared but never defined
inline uint32_t IpAddr(unsigned char q1, unsigned char q2, unsigned char q3, unsigned char q4);
                 ^
arm-openwrt-linux-muslgnueabi-gcc -Wall -Os -pipe -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=soft -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include  -DHAVE_CONFIG_H -DINSTALL_DIR="\"/usr/bandwidthd\""   -c -o graph.o graph.c
graph.c: In function 'GraphIp':
graph.c:381:9: warning: variable 'white' set but not used [-Wunused-but-set-variable]
     int white;
         ^
graph.c: In function 'GraphData':
graph.c:697:57: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
  gdImageString(im, gdFontSmall, XOFFSET+5,  YHEIGHT-20, Buffer, black);
                                                         ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c:698:66: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
  gdImageString(im, gdFontSmall, XWIDTH/2+XOFFSET/2,  YHEIGHT-20, Buffer2, black);
                                                                  ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c:712:61: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
     gdImageString(im2, gdFontSmall, XOFFSET+5,  YHEIGHT-20, Buffer, black2);
                                                             ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c:713:70: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
     gdImageString(im2, gdFontSmall, XWIDTH/2+XOFFSET/2,  YHEIGHT-20, Buffer2, black2);
                                                                      ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c: In function 'PrepareYAxis':
graph.c:762:48: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
         gdImageString(im, gdFontSmall, 3, y-7, buffer, black);
                                                ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c: In function 'PrepareXAxis':
graph.c:814:68: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
          gdImageString(im, gdFontSmall, x-30,  YHEIGHT-YOFFSET+10, buffer, black);
                                                                    ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c:848:67: warning: pointer targets in passing argument 5 of 'gdImageString' differ in signedness [-Wpointer-sign]
          gdImageString(im, gdFontSmall, x-6,  YHEIGHT-YOFFSET+10, buffer, black);
                                                                   ^
In file included from bandwidthd.h:48:0,
                 from graph.c:12:
/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include/gd.h:620:19: note: expected 'unsigned char *' but argument is of type 'char *'
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
                   ^
graph.c:772:26: warning: variable 'sample_end' set but not used [-Wunused-but-set-variable]
     time_t sample_begin, sample_end;
                          ^
In file included from graph.c:12:0:
graph.c: At top level:
bandwidthd.h:218:17: warning: inline function 'DstCredit' declared but never defined
inline void     DstCredit(uint32_t ipaddr, unsigned int psize);
                 ^
In file included from graph.c:12:0:
bandwidthd.h:205:23: warning: inline function 'FindIp' declared but never defined
inline struct IPData *FindIp(uint32_t ipaddr);
                       ^
bandwidthd.h:202:17: warning: inline function 'Credit' declared but never defined
inline void     Credit(struct Statistics *Stats, const struct ip *ip);
                 ^
bandwidthd.h:199:17: warning: inline function 'IpAddr' declared but never defined
inline uint32_t IpAddr(unsigned char q1, unsigned char q2, unsigned char q3, unsigned char q4);
                 ^
bandwidthd.h:196:15: warning: inline function 'HostIp2CharIp' declared but never defined
char inline  *HostIp2CharIp(unsigned long ipaddr, char *buffer);
               ^
arm-openwrt-linux-muslgnueabi-gcc -Wall -Os -pipe -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=soft -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include  -DHAVE_CONFIG_H -DINSTALL_DIR="\"/usr/bandwidthd\""   -c -o conf.tab.o conf.tab.c
In file included from conf.y:12:0:
bandwidthd.h:218:17: warning: inline function 'DstCredit' declared but never defined
inline void     DstCredit(uint32_t ipaddr, unsigned int psize);
                 ^
In file included from conf.y:12:0:
bandwidthd.h:205:23: warning: inline function 'FindIp' declared but never defined
inline struct IPData *FindIp(uint32_t ipaddr);
                       ^
bandwidthd.h:202:17: warning: inline function 'Credit' declared but never defined
inline void     Credit(struct Statistics *Stats, const struct ip *ip);
                 ^
bandwidthd.h:199:17: warning: inline function 'IpAddr' declared but never defined
inline uint32_t IpAddr(unsigned char q1, unsigned char q2, unsigned char q3, unsigned char q4);
                 ^
bandwidthd.h:196:15: warning: inline function 'HostIp2CharIp' declared but never defined
char inline  *HostIp2CharIp(unsigned long ipaddr, char *buffer);
               ^
arm-openwrt-linux-muslgnueabi-gcc -Os -pipe -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=soft -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include  -DHAVE_CONFIG_H -c -o conf.l.o conf.l.c
arm-openwrt-linux-muslgnueabi-gcc -Wall -Os -pipe -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=soft -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/include -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include/fortify -I/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/include  -DHAVE_CONFIG_H -DINSTALL_DIR="\"/usr/bandwidthd\"" bandwidthd.o graph.o conf.tab.o conf.l.o -o bandwidthd -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/lib -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/lib -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/lib -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/lib -znow -zrelro -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/lib -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/lib -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/usr/lib -L/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/lib -znow -zrelro -Wl,-rpath-link,/home/lacroix/openwrt-dev/openwrt-trunk/staging_dir/target-arm_cortex-a9+vfpv3_musl-1.1.11_eabi/usr/lib -lpcap -lgd -lpng -lm -lresolv
graph.o: In function `rdns':
graph.c:(.text+0x2d4): undefined reference to `HostIp2CharIp'
graph.o: In function `PrintTableLine':
graph.c:(.text+0x564): undefined reference to `HostIp2CharIp'
graph.o: In function `MakeIndexPages':
graph.c:(.text+0x8c8): undefined reference to `HostIp2CharIp'
graph.c:(.text+0x9b8): undefined reference to `HostIp2CharIp'
graph.c:(.text+0xa50): undefined reference to `HostIp2CharIp'
graph.o:graph.c:(.text+0xb88): more undefined references to `HostIp2CharIp' follow
collect2: error: ld returned 1 exit status
make[3]: *** [bandwidthd] Error 1

(Last edited by jmlacroix on 23 Nov 2015, 15:52)

My input based on 5 minute googling:
https://www.google.fi/search?q=bandwidthd+gcc+5

you might be running into problems with 10+ year old source code (bandwidthd 2.0.1 is from 2005, right???), when you try to compile it with a compiler that is now following the year 1999 C standard instead of 1989. Apparently the handling of inline functions has changed etc.

Some similar reports:
https://bugs.debian.org/cgi-bin/bugrepo … bug=777794
One patch (removing inline):
https://www.mail-archive.com/debian-bug … 43897.html
Second:
https://launchpad.net/ubuntu/+source/ba … 20090917-8
http://launchpadlibrarian.net/209261825 … -8.diff.gz

GC 5 background:
https://gcc.gnu.org/gcc-5/porting_to.html
http://clang.debian.net/status.php?vers … =UNDEF_REF

You might try either:
* defining in Makefile CFLAGS (?) the option "-std=gnu89"  to use the older standard
* patching the source to remove the offending inline definition.

The source code is so old, that I might try the C standard change first.

(Last edited by hnyman on 23 Nov 2015, 16:37)

hnyman wrote:

My input based on 5 minute googling:
https://www.google.fi/search?q=bandwidthd+gcc+5

you might be running into problems with 10+ year old source code (bandwidthd 2.0.1 is from 2005, right???), when you try to compile it with a compiler that is now following the year 1999 C standard instead of 1989. Apparently the handling of inline functions has changed etc.

....

You might try either:
* defining in Makefile CFLAGS (?) the option "-std=gnu89"  to use the older standard
* patching the source to remove the offending inline definition.

The source code is so old, that I might try the C standard change first.

Yes: this is old source code indeed!  Thank you for the various pointers: I read the various links you provided and others, and I understand the problem.

I will try the CFLAGS with the option "-std=gnu89" first: as you said the code is old, and trying to fix it for C99 may be more error prone and raise other problems.

Thanks a lot for everything!

EDIT: just to let know that it worked fine with the option "-std=gnu89"

(Last edited by jmlacroix on 24 Nov 2015, 00:54)

The discussion might have continued from here.