shournal icon indicating copy to clipboard operation
shournal copied to clipboard

Android/bionic support

Open tathastu871 opened this issue 2 years ago • 16 comments

if possible patch use of backtrace and prevent using execinfo.h needed Trying to compile and include shournal in termux official repo

tathastu871 avatar Dec 18 '21 11:12 tathastu871

Hi. This should be possible, but would you mind telling me what exactly your platform is? (; execinfo.h seems to be part of (g)libc on Linux, so I guess it should be available.

tycho-kirchner avatar Dec 18 '21 12:12 tycho-kirchner

Hi. This should be possible, but would you mind telling me what exactly your platform is? (; execinfo.h seems to be part of (g)libc on Linux, so I guess it should be available.

Termux aarch64 on bionic(android)

Wrapping the execinfo.h in

#ifndef __ANDROID__ 
#include <execinfo.h>
#endif 

is current workaround being used for other packages that were built. But in shournal it was producing unidentified/undefined backtrace functions.

Hence developers of termux recommened to patch program to not use execinfo.h and backtrace related functions.

tathastu871 avatar Dec 18 '21 13:12 tathastu871

Since smartphones are faster than laptops nowadays with octa core most people use termux as desktop linux replacement.

Linux applications can either be used directly on termux by compiling them as aarch64 and linking with bionic. Or inside proot distros like ubuntu-termux, arch-termux as arm64 binaries.

Hence having shournal on termux is quite beneficial

tathastu871 avatar Dec 18 '21 13:12 tathastu871

See this patch https://wiki.termux.com/images/9/9d/OF_5.0_termux.patch all execinfo and backtrace and related functions are enclosed within #ifndef __ANDROID__ .. #endif

tathastu871 avatar Dec 18 '21 13:12 tathastu871

Wow. Haven't considered porting shournal to Android yet. Just checked: at least fanotify seems to be available in bionic: ./libc/kernel/uapi/linux/fanotify.h. I suspect this is only the tip of the iceberg of compilation problems (did you check?), so if the port is within scope I'd perform that as a common patch series. Would you like to support?

tycho-kirchner avatar Dec 18 '21 13:12 tycho-kirchner

on termux gcc toolchain has many problems. although gcc 9,10,11 are available. Hence all packages are built using clang as CC Missing execinfo.h workaround: src/common/util/util.cpp Around line 211 is function that uses backtrace and execinfo.h enclose it entirely with if endif as shown above. this seems to supress error.

Next error missing stdio_filebuf.h

tathastu871 avatar Dec 18 '21 13:12 tathastu871

stdio_filebuf.h and referencing functions parseGenericKeyValFile, parseRealUidOf can be removed, they are not used.

tycho-kirchner avatar Dec 18 '21 13:12 tycho-kirchner

/data/data/com.termux/files/home/home/shournal/shournal/src/common/stdiocpp.cpp:20:73: error: member access into incomplete type 'const FILE' (aka 'const __sFILE')
/data/data/com.termux/files/home/home/shournal/shournal/src/common/stdiocpp.cpp:81:12: error: no member named 'fgetc_unlocked' in the global namespace; did you mean simply 'fgetc_unlocked'?
/data/data/com.termux/files/home/home/shournal/shournal/src/common/stdiocpp.cpp:87:28: error: no member named 'fwrite_unlocked' in the global namespace; did you mean simply 'fwrite_unlocked'?
/data/data/com.termux/files/home/home/shournal/shournal/src/common/stdiocpp.cpp:107:12: error: no member named 'fread_unlocked' in the global namespace; did you mean simply 'fread_unlocked'?
4 errors generated.

tathastu871 avatar Dec 18 '21 16:12 tathastu871

Those are simple. Use the locked ones instead (without _unlocked-suffix) (#ifndef __ANDROID__). I'm setting up an Android VM, so later I'll be able to test myself as well.

tycho-kirchner avatar Dec 18 '21 16:12 tycho-kirchner

Before digging further into this, could you please check the following points:

  • is your kernel compiled with fanotify support?
  • initializing fanotify requires CAP_SYS_ADMIN, which is normally implemented using a setuid-binary. Will Android sandboxing mechanisms allow for that?
  • Otherwise/additionally shournal's kernel module may be ported as well, which again requires a rooted device (access to /sys). I'm not sure whether this is going to get too exhaustive here...

tycho-kirchner avatar Dec 18 '21 20:12 tycho-kirchner

Another tool named fsmon with fanotify and inotify backends is properly working on termux.

tathastu871 avatar Dec 19 '21 05:12 tathastu871

Another tool named fsmon with fanotify and inotify backends is properly working on termux.

Did you check? Reading this

* inotify (linux / android)
* fanotify (linux > 2.6.36 / android with custom kernel)

implies that while inotify works out of the box, fanotify requires a custom kernel (whatever that means).

See also this SO post.

tycho-kirchner avatar Dec 19 '21 10:12 tycho-kirchner

Another tool named fsmon with fanotify and inotify backends is properly working on termux.

Did you check? Reading this

* inotify (linux / android)
* fanotify (linux > 2.6.36 / android with custom kernel)

implies that while inotify works out of the box, fanotify requires a custom kernel (whatever that means).

Root is required

tathastu871 avatar Dec 19 '21 11:12 tathastu871

@tathastu871 I just check in my Android x86 virtual machine:

$ zgrep -i fanotify /proc/config.gz
# CONFIG_FANOTIFY is not set

Does your kernel include fanotify support? Otherwise I guess instead of compiling a custom kernel it may be more feasible to rather use shournal's kernel module if and only if the kernel was compiled with CONFIG_TRACEPOINTS=y and CONFIG_FTRACE=y. Is that the case on your machine?

tycho-kirchner avatar Dec 19 '21 12:12 tycho-kirchner

Well my phone is not easily rootable so i cant test it. maybe termux developers can

tathastu871 avatar Dec 19 '21 13:12 tathastu871

The termux developers can't test whether your phone's kernel supports these features, it may be a vendor-specific compile time option (;

Let's conclude:

shournal requires a rooted phone and most likely a custom kernel or the installation of shournal's kernel module. I don't know the peculiarities of compiling and using a kernel module on Android yet, e.g. does an equivalent to DKMS exist and is module signing mandatory? Among other questions.

These requirements are not trivial, rooting the device can already be a painful process and I'm not sure whether the next installation steps in order to run shournal can be simplified.

tycho-kirchner avatar Dec 19 '21 14:12 tycho-kirchner