cloudius-systems / osv-apps

OSv Applications
135 stars 75 forks source link

iperf compile fails on gcc 6.3 #55

Closed justinc1 closed 7 years ago

justinc1 commented 7 years ago

On fedora 25 with gcc 6.3:

scripts/build mode=debug image=iperf nfs=false
...
make[3]: Entering directory '/home/justin_cinkelj/devel/mikelangelo/osv-t1/osv/apps/iperf/iperf-2.0.5/compat'
if g++ -DHAVE_CONFIG_H -I. -I. -I..  -I../include -I../include  -Wall -fPIC  -MT delay.o -MD -MP -MF ".deps/delay.Tpo" -c -o delay.o delay.cpp; \
then mv -f ".deps/delay.Tpo" ".deps/delay.Po"; else rm -f ".deps/delay.Tpo"; exit 1; fi
In file included from /usr/include/c++/6.3.1/cmath:42:0,
                 from /usr/include/c++/6.3.1/math.h:36,
                 from ../include/headers.h:85,
                 from ../include/Timestamp.hpp:63,
                 from delay.cpp:53:
/usr/include/c++/6.3.1/bits/cpp_type_traits.h:205:12: error: redefinition of ‘struct std::__is_integer<int>’
     struct __is_integer<int> /*---------------------------------------------------------------*/
            ^~~~~~~~~~~~~~~~~
/usr/include/c++/6.3.1/bits/cpp_type_traits.h:138:12: error: previous definition of ‘struct std::__is_integer<int>’
     struct __is_integer<bool> /*------------------------------------------------------------------------------*/
            ^~~~~~~~~~~~~~~~~~
Makefile:273: recipe for target 'delay.o' failed

Problem comes from

justin_cinkelj@jcpc:~/devel/mikelangelo/osv-t1/osv/apps/iperf$ less iperf-2.0.5/config.h
/* The size of `bool', as computed by sizeof. */
#define SIZEOF_BOOL 0
...
#define bool int
justin_cinkelj@jcpc:~/devel/mikelangelo/osv-t1/osv/apps/iperf$ less iperf-2.0.5/config.log
configure:6939: checking size of bool
configure:6944: gcc -o conftest  -fPIC    conftest.c  >&5
conftest.c: In function 'longval':
conftest.c:98:57: error: 'bool' undeclared (first use in this function)
 static long int longval () { return (long int) (sizeof (bool)); }
justinc1 commented 7 years ago

Changing :

index 6a79af1..1c0d7f3 100644
--- a/iperf/Makefile
+++ b/iperf/Makefile
@@ -17,7 +17,7 @@ iperf: $(iperfv)/src/iperf
 $(iperfv)/src/iperf: $(tarball)
        tar xzf $^
        patch -p0 < so.patch
-       cd $(iperfv) && CFLAGS='-fPIC -g' CXXFLAGS='-fPIC -g' ./configure
+       cd $(iperfv) && CC='gcc' CXX='g++' CFLAGS='-fPIC -g' CXXFLAGS='-fPIC -g' ./configure
        +$(MAKE) -C $(iperfv)

 $(tarball):

didn't help, as many .c files then fail to compile.

It helps to comment out #define bool int in config.h.

Or to use iperf-2.0.10 from http://sourceforge.net/projects/iperf2. It is a sort of maintenance fork, with new features, and emphasis on compatibility with orig iperf 2 client/servers.

nyh commented 7 years ago

I can reproduce this problem.

The "#define bool int" is a really bad thing to do in C++ because "bool" is a different type. The problem is that iperf's configure (see configure.ac and output in config.log) checks "bool" in a run of "gcc" without parameters - and that used to default to C89 and not C99. This is silly - to check "bool" in C and then compile with c++...

Maybe by adding "-std=c99" to CFLAGS when running configure we can fix that. I'll check.

nyh commented 7 years ago

What a mess... The code doesn't compile with -std=c99. I'll try to hack config.h and see if helps.

justinc1 commented 7 years ago

try to hack config.h

If you mean to comment out '#define bool int' - code compiled, and both server and client worked afterwards.

justinc1 commented 7 years ago

:D :D :D for

There is simply no reason for this test - none of the C files actually use "bool"!

I didn't notice that.

nyh commented 7 years ago

Yes, instead of hacking config.h after it was created, I wanted to see if I could cause it not to create the bad definition. And it's actually easy - just don't ask autoconf to do this bool test... It's not needed in the first place, the code doesn't even use "bool", so why did this test exist in the first place?

By the way, I'm worried that -std=c99 didn't work - it means will have problems in the future when compilers start to default to that. Maybe someone will fix the iperf code by then...