davidmoreno/onion

cross compile for arm error

Opened this issue · 4 comments

1. software version

onion v0.8
ubuntu 16.04

2. arm.txt config

//specify the cross compiler
SET(CMAKE_C_COMPILER /home/vincent/bin/android-19-toolchain/bin/arm-linux-androideabi-gcc)
SET(CMAKE_CXX_COMPILER /home/vincent/bin/android-19-toolchain/bin/arm-linux-androideabi-g++)

// where is the target environment
SET(CMAKE_FIND_ROOT_PATH /home/vincent/bin/android-19-toolchain/)

// search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
// for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(ONION_USE_SSL false)
SET(ONION_USE_PAM false)
SET(LIBPATH /home/vincent/bin/android-19-toolchain/arm-linux-androideabi/lib)
SET(CMAKE_INSTALL_LIBDIR /home/vincent/bin/onion-android-19/lib)
SET(CMAKE_INSTALL_BINDIR /home/vincent/bin/onion-android-19/bin)
SET(CMAKE_INSTALL_INCLUDEDIR /home/vincent/bin/onion-android-19/include)

3. cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain/arm.txt

-- Compiling for ARM
-- search otemplate, opack
-- Otemplate at /home/vincent/bin/onino/bin/otemplate
-- Opack at /home/vincent/bin/onino/bin/opack
-- Onion version is 0.8.0.GIT
-- Using epoll as poller
SQLite not found. Sqlite session support is not compiled in.
Hiredis not found. Redis session support is not compiled in.
pthreads not found. Threading is not supported.
libxml2 not found. WebDAV is not supported. XML2_HEADERS-NOTFOUND XML2_LIB-NOTFOUND
libpng not found. No png support.
libjpeg not found. No jpeg support.
-- libgc not found, NOT compiling Boehm GC examples
curl not found. Some examples wil not be built.
libsystemd not found. Systemd support is not compiled in. Install libsystemd-dev | systemd-devel
md2man-roff NOT found, NOT compiling manpages. Install it via 'gem install md2man'
-- Prepared for packaging
-- Found include files
-- Found include files onion.hpp;dict.hpp;request.hpp;response.hpp;url.hpp;handler.hpp;extrahandlers.hpp;shortcuts.hpp;exceptions.hpp;listen_point.hpp;http.hpp;https.hpp;mime.hpp
CMake Warning at examples/CMakeLists.txt:9 (message):
Oterm without authentication support! May be very unsecure.

CMake Warning at examples/CMakeLists.txt:14 (message):
Some examples are disabled as you dont have PAM: otop, basic, fileserver.

-- jQuery not found. Using onion provided one.
-- Using onion provided jquery for oterm
CMake Warning at examples/CMakeLists.txt:37 (message):
Some examples are disabled as you dont have libpng: mandelbrot

CMake Warning at examples/CMakeLists.txt:46 (message):
Some examples are disabled as you dont have cairo: cairo

-- No 09-webdav example as no libxml2 available
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PTHREADS_LIB
linked by target "opack" in directory /home/vincent/tmp/onion-0.8/tools/opack

-- Configuring incomplete, errors occurred!
See also "/home/vincent/tmp/onion-0.8/arm/CMakeFiles/CMakeOutput.log".

Looks like pthreads is not found.

I just pushed a patch to make you go tpast that problem, but quite probably will not compile. There were some talks to make pthreads mandatory, but no code yet.

Just now I would recommend:

  1. Try the latest version with the compilation patch, and if everything works... tell me! Maybe 18.04 on ARM does not need libpthread for thread support..
  2. or install pthreads (which should be libc6-dev, it would be really weird you dont have it).
  3. or execute cmake with -DONION_USE_PTHREAD=false and use onion without pthreads (which is not efficient at all).

I would have to look more deeply into it, but until next week I dont have access to my raspberry to check properly.

  1. I use the laterst version, cmake is ok. but then i use make apperar follow erros

[ 0%] Building C object src/onion/CMakeFiles/onion_static.dir/poller.c.o
/home/vincent/tmp/onion/src/onion/poller.c:32:25: fatal error: sys/timerfd.h: No such file or directory
#include <sys/timerfd.h>
^
compilation terminated.

  1. I use android ndk compile, install:
    $NDK/build/tools/make_standalone_toolchain.py
    --arch arm --api 19 --install-dir /tmp/my-android-toolchain

  2. can i use some mechanism to replace timerfd?

I dug around the Android NDK sources and it appears that timerfd.h wasn't included until API level 20. I don't think there is an easy work around to this issue. Have you tried building with a higher API level? I'd be interested to know we can compile on any version of Android.

A possible workaround is to create a pipe, use the read end as a timerfd, and on another thread sleep and write whenever the timer has to expire, with proper communication between the threads.

So basically reimplement it in user space, losing a lot of precision, and adding many context switches. But should work.

If you decide to implement it, please encapsulate it properly so at compile time we can chose native timerfd or not.

Regads,
David.