kohler / click

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

problem cross-compiling to openwrt (lede) #389

Closed cm281273 closed 6 years ago

cm281273 commented 6 years ago

Hi all, I'm trying to cross compile click to openwrt (lede) and I'm having the following error when make reaches anonipaddr.cc. Apparently the ioctl.h has no definition for _IOC_DIRSHIFT macro. Thing is that sys/ioctl.h includes bits/ioctl.h which should contain the macro but it doesn't. Any thoughts?

This may give some idea of the linux version I'd like to compile it to:

prefix = /home/andres/Desktop/openwrt-image-for-APU2/LEDE-APU2/lede/build_dir/target-x86_64_musl/linux-x86_64/linux-4.9.76
exec_prefix = ${prefix}
includedir = /home/andres/Desktop/openwrt-image-for-APU2/LEDE-APU2/lede/build_dir/target-x86_64_musl/linux-x86_64/linux-4.9.76/include

and...

$make

make[1]: Entering directory '/home/andres/Desktop/openwrt-image-for-APU2/LEDE-APU2/lede/click/userlevel'
elements.mk:461: warning: overriding recipe for target 'odinagent.o'
elements.mk:454: warning: ignoring old recipe for target 'odinagent.o'
elements.mk:463: warning: overriding recipe for target 'odinagent.s'
elements.mk:456: warning: ignoring old recipe for target 'odinagent.s'
elements.mk:465: warning: overriding recipe for target 'odinagent.ii'
elements.mk:458: warning: ignoring old recipe for target 'odinagent.ii'
  CXX ../elements/analysis/anonipaddr.cc
In file included from ../elements/analysis/anonipaddr.cc:27:0:
../elements/analysis/anonipaddr.cc: In member function 'virtual int AnonymizeIPAddr::llrpc(unsigned int, void*)':
../include/click/llrpc.h:33:40: error: '_IOC_DIRSHIFT' was not declared in this scope
 #define _CLICK_IOC_IN  (_IOC_WRITE << _IOC_DIRSHIFT)
                                        ^
../include/click/llrpc.h:47:32: note: in definition of macro '_CLICK_IOX'
 #define _CLICK_IOX(d, n, sz) ((d) | ((sz) << 16) | (n))
                                ^
../include/click/llrpc.h:65:40: note: in expansion of macro '_CLICK_IOC_IN'
 #define _CLICK_IOWRF(n, sz) _CLICK_IOX(_CLICK_IOC_IN|_CLICK_IOC_OUT|_CLICK_IOC_FLAT, (n), (sz))
                                        ^
../include/click/llrpc.h:77:36: note: in expansion of macro '_CLICK_IOWRF'
 #define CLICK_LLRPC_MAP_IPADDRESS  _CLICK_IOWRF(7, 4)
                                    ^
../elements/analysis/anonipaddr.cc:307:20: note: in expansion of macro 'CLICK_LLRPC_MAP_IPADDRESS'
     if (command == CLICK_LLRPC_MAP_IPADDRESS) {
                    ^
../elements/analysis/anonipaddr.cc:315:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
elements.mk:412: recipe for target 'anonipaddr.o' failed
make[1]: *** [anonipaddr.o] Error 1
make[1]: Leaving directory '/home/andres/Desktop/openwrt-image-for-APU2/LEDE-APU2/lede/click/userlevel'
Makefile:57: recipe for target 'userlevel' failed
make: *** [userlevel] Error 2
sonjinho commented 5 years ago

Is it solve?

sonjinho commented 4 years ago

LEDE project still have problems Use git://git.archive.openwrt.org/15.05/openwrt.git version chaos_calmer

then do #336

andredcoliveira commented 4 years ago

I fixed (bypassed) this by changing line 26 of "include/click/llrpc.h". Instead of testing the " linux " macro, I changed it to test the " GLIBC " macro, since musl I believe does not contain " IOC DIRSHIFT ". I attached a .patch file. Just ignore the .txt extension at the end of the filename and run the following command

patch include/click/llrpc.h < ${PATCH_DIR}/llrpc.patch

Then run

make elemlist make

as you normally would. My configuration for compiling click looks like the following (using OpenWRT 18.06.4):

./configure --disable-app-fuzzer --disable-app-performance --disable-app-sniffer --enable-app-tunnel --disable-app-stats --disable-doc --disable-doc-man --enable-local --enable-wifi --disable-linuxmodule --enable-userlevel --host=i486-openwrt-linux-musl --build=x86_64-pc-linux-gnu --with-linux=/home/Andre/Documents/thesis/openwrt/build_dir/toolchain-i386_pentium_gcc-7.4.0_musl/linux

I had to patch a few other things, in order for it to work. Feel free to reach out if you want me to go into further detail.

llrpc.patch.txt

sonjinho commented 4 years ago

I also found another solution

https://github.com/5g-empower/empower-openwrt-packages/blob/master/empower-lvap-agent/patches/100-empower-lvap-agent.patch

https://github.com/Wi5/odin-wi5/tree/master/Odin_Wi5_firmware_build/custom/click/files

Device : TP-LINK archer c7 v2