kohler / click

The Click modular router: fast modular packet processing and analysis
Other
743 stars 321 forks source link

compilation error on Ubuntu 21.04 (g++ 11.1) #493

Closed tomhenderson closed 2 years ago

tomhenderson commented 3 years ago

While testing ns-3 with the most recent click code, I encountered a compilation error on Ubuntu 21.04 with g++ version gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~21.04).

Steps to reproduce:

$ git clone https://github.com/kohler/click && cd click
$ configure && make

Error reported:

...
  CXX ../elements/icmp/icmperror.cc
In file included from ../include/clicknet/ip.h:5,
                 from ../include/clicknet/icmp.h:4,
                 from ../elements/icmp/icmperror.cc:20:
../include/click/cxxprotect.h:12:25: error: ‘linux_true’ was not declared in this scope
   12 | # define true           linux_true
      |                         ^~~~~~~~~~
...

Workaround: The below patch works for me on this system; have not checked other systems.

diff --git a/include/click/cxxprotect.h b/include/click/cxxprotect.h
index 65662aff7..f199df45a 100644
--- a/include/click/cxxprotect.h
+++ b/include/click/cxxprotect.h
@@ -9,7 +9,6 @@
 # define public                linux_public
 # define namespace     linux_namespace
 # define false         linux_false
-# define true          linux_true
 #endif

 #ifndef CLICK_CXX_PROTECT
tbarbette commented 3 years ago

You need to give a few parameters to configure to build for ns3. Here you're compiling for a Kernel module ;)

tomhenderson commented 3 years ago

You need to give a few parameters to configure to build for ns3. Here you're compiling for a Kernel module ;)

Sorry, I simplified for the issue report. Here are the arguments being passed to configure:

./configure --disable-linuxmodule --enable-nsclick --enable-wifi

It results in the same error. This configuration works on earlier Ubuntu, but not on Ubuntu 21.04.

sriharshAmur commented 2 years ago

Has anybody found a solution for this? I'm facing the same issue

kyechou commented 2 years ago

The above workaround works for me too (Arch Linux, kernel 5.17.8, GCC 12.1.0).

Workaround: The below patch works for me on this system; have not checked other systems.

diff --git a/include/click/cxxprotect.h b/include/click/cxxprotect.h
index 65662aff7..f199df45a 100644
--- a/include/click/cxxprotect.h
+++ b/include/click/cxxprotect.h
@@ -9,7 +9,6 @@
 # define public                linux_public
 # define namespace     linux_namespace
 # define false         linux_false
-# define true          linux_true
 #endif

 #ifndef CLICK_CXX_PROTECT
botbotty commented 2 years ago

Same error on Ubuntu 22.04

The problem seems to be with # include <netinet/in.h> inside ./include/clicknet/ip.h

If I add #undef true right before # include <netinet/in.h>, the compilation error disappears. It doesn't work if I add it after the include statement.

tbarbette commented 2 years ago

Is there a way to do that so it works also on old system without the define true? I think the define in netinet/in.h should be found at configure time and then expose the true or not according to the result of that.

What are your compile flags so I can try?

yxxu commented 2 years ago

@tomhenderson dear tomhenderson, how do you correct? I meet same error on ubuntu 22.04

kyechou commented 2 years ago

Hi @tbarbette, the build is still broken for me with #502. Here's the complete build output: https://pastebin.com/TsUtmApV.

$ ./configure --prefix=/usr --sbindir=/usr/bin --enable-all-elements
$ make -j1
...
  CREATE elements.mk
  CXX ../lib/userutils.cc
  CXX ../elements/ip6/addresstranslator.cc
  CXX ../elements/ip6/icmp6error.cc
  CXX ../elements/ip6/ip6routetable.cc
  CXX ../elements/ip6/lookupip6route.cc
  CXX ../elements/ip6/markip6header.cc
  CXX ../elements/ip6/protocoltranslator64.cc
  CXX ../elements/ip6/setip6address.cc
  CXX ../elements/ip6/protocoltranslator46.cc
  CXX ../elements/ip6/setip6dscp.cc
  CXX ../elements/ip/checkipheader2.cc
In file included from ../include/clicknet/ip6.h:6,
                 from ../include/clicknet/icmp6.h:4,
                 from ../elements/ip6/icmp6error.cc:19:
../include/click/cxxprotect.h:12:25: error: ‘linux_true’ was not declared in this scope
   12 | # define true           linux_true
      |                         ^~~~~~~~~~

It looks like we need to do the same thing for include/clicknet/ip6.h, which I assume is not enabled for Ubuntu? But wouldn't it make more sense to fix the issue by including or defining/adding macro checks in include/click/cxxprotect.h directly, instead of modifying all the other files that include that file?

tbarbette commented 2 years ago

Ah yes I did not try with ip6. Yes it would be great but I could not find what to check in the incriminated file, nor exactly where is the clashing use...