Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android/bionic support #5

Open
tathastu871 opened this issue Dec 18, 2021 · 16 comments
Open

Android/bionic support #5

tathastu871 opened this issue Dec 18, 2021 · 16 comments
Labels
enhancement New feature or request

Comments

@tathastu871
Copy link

tathastu871 commented Dec 18, 2021

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

@tycho-kirchner
Copy link
Owner

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.

@tathastu871
Copy link
Author

tathastu871 commented Dec 18, 2021

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
Copy link
Author

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
Copy link
Author

tathastu871 commented Dec 18, 2021

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

@tycho-kirchner
Copy link
Owner

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?

@tathastu871
Copy link
Author

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

@tycho-kirchner
Copy link
Owner

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

@tathastu871
Copy link
Author

/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.

@tycho-kirchner
Copy link
Owner

tycho-kirchner commented Dec 18, 2021

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
Copy link
Owner

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...

@tathastu871
Copy link
Author

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

@tycho-kirchner
Copy link
Owner

tycho-kirchner commented Dec 19, 2021

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.

@tathastu871
Copy link
Author

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

@tycho-kirchner
Copy link
Owner

@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?

@tathastu871
Copy link
Author

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

@tycho-kirchner
Copy link
Owner

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 tycho-kirchner changed the title execinfo.h not available on some platform Android/bionic support Dec 26, 2021
@tycho-kirchner tycho-kirchner added the enhancement New feature or request label Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants