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

Building libressl on Android #707

Closed
advancedwebdeveloper opened this issue Dec 8, 2021 · 10 comments
Closed

Building libressl on Android #707

advancedwebdeveloper opened this issue Dec 8, 2021 · 10 comments

Comments

@advancedwebdeveloper
Copy link

[ 0%] Built target date-tz
[ 1%] Built target spdlog-external
[ 2%] Built target ossp-uuid-external
[ 4%] Built target zlib-external
[ 5%] Built target yaml-cpp-external
[ 5%] Performing build step for 'libressl-portable'
Consolidate compiler generated dependencies of target crypto
[ 0%] Building C object crypto/CMakeFiles/crypto.dir/cryptlib.c.o
In file included from /data/data/com.termux/files/home/nifi-minifi-cpp/build/thirdparty/libressl-src/crypto/cryptlib.c:121:
/data/data/com.termux/files/home/nifi-minifi-cpp/build/thirdparty/libressl-src/crypto/../include/compat/syslog.h:32:6: error: conflicting types for 'android_polyfill_syslog_r'
void syslog_r(int, struct syslog_data , const char , ...);
^
/data/data/com.termux/files/usr/include/syslog.h:176:18: note: expanded from macro 'syslog_r'
#define syslog_r android_polyfill_syslog_r
^
/data/data/com.termux/files/usr/include/syslog.h:161:24: note: previous definition is here
static inline void android_polyfill_syslog_r(int syslog_priority, void
d, const char
format, ...)
^
In file included from /data/data/com.termux/files/home/nifi-minifi-cpp/build/thirdparty/libressl-src/crypto/cryptlib.c:121:
/data/data/com.termux/files/home/nifi-minifi-cpp/build/thirdparty/libressl-src/crypto/../include/compat/syslog.h:33:6: error: conflicting types for 'android_polyfill_vsyslog_r'
void vsyslog_r(int, struct syslog_data , const char , va_list);
^
/data/data/com.termux/files/usr/include/syslog.h:177:19: note: expanded from macro 'vsyslog_r'
#define vsyslog_r android_polyfill_vsyslog_r
^
/data/data/com.termux/files/usr/include/syslog.h:170:24: note: previous definition is here
static inline void android_polyfill_vsyslog_r(int syslog_priority, void
d, const char
fmt, va_list ap)
^
2 errors generated.
make[5]: *** [crypto/CMakeFiles/crypto.dir/build.make:188: crypto/CMakeFiles/crypto.dir/cryptlib.c.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:197: crypto/CMakeFiles/crypto.dir/all] Error 2
make[3]: *** [Makefile:146: all] Error 2
make[2]: *** [CMakeFiles/libressl-portable.dir/build.make:86: libressl-portable-prefix/src/libressl-portable-stamp/libressl-portable-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:1076: CMakeFiles/libressl-portable.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

@advancedwebdeveloper
Copy link
Author

That is on behalf of Apache MiNiFi (C++ port)

@kinichiro
Copy link
Contributor

@kinichiro
Copy link
Contributor

CI build for Android 11 succeeds on Github Actions, here.
https://github.com/libressl-portable/portable/runs/4469672475?check_suite_focus=true

It runs on ubuntu 18.04 and you can see how it execute cmake in scripts/test.
https://github.com/libressl-portable/portable/blob/master/scripts/test#L99

Your log seems that other products had built LibreSSL as its library to use with.
Can you clarify the difference between your build and CI build ?
And what OS and version did you use to build your product ?

@advancedwebdeveloper
Copy link
Author

Version 3.0.2 was picked up.
$ make --version
GNU Make 4.3
$ as --version
GNU assembler (GNU Binutils) 2.37
$ clang --version clang version 13.0.0 Target: aarch64-unknown-linux-android24 Thread model: posix InstalledDir: /data/data/com.termux/files/usr/bin

@advancedwebdeveloper
Copy link
Author

I might assume that you would provide a patch, for CMake - I could reproduce, with an applied patch

@advancedwebdeveloper
Copy link
Author

You can reproduce with Termux

@advancedwebdeveloper
Copy link
Author

Android 11 has kernel's version 4.19.127-g127475f6d88e-dirty
#1 Mon Jul 12 12:27:52 CST 2021
It is HiOS v 7.5.0 on Tecno Spark 7 (KF6n)

@busterb
Copy link
Contributor

busterb commented Jul 7, 2023

Hey, I don't think we're to interested in supporting termux directly, since it can be difficult to get things working in that environment even in the best of times. If you want to send a diff for any CMake changes needed to build directly in that environment, feel free, but we're probably not going to be able to help much more than that.

@busterb busterb closed this as completed Jul 7, 2023
@d3x0r
Copy link
Contributor

d3x0r commented Feb 21, 2024

I was able to get libressl 3.8.0 to build under termux with only a few modifications.

in CMakeLists.txt root can add

if( CMAKE_HOST_SYSTEM_NAME STREQUAL "Android" )
	set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__ANDROID_HOST__" )
endif()

and then the syslog.h headers define syslog_r and vsyslog_r to pass to android syslog functions; somehow the test for HAVE_SYSLOG fails (Oh that must test for 'vsyslog'), so the include/compat/syslog.h ends up getting used, which then at the start I added

#ifdef __ANDROID_HOST__
#  undef syslog_r
#  undef vsyslog_r
#endif

and I had to reverse the function declarations in crypto/compat/syslog_r.c

void syslog_r(...){...}
void vsyslog_r(...){...}

to

void vsyslog_r(...){...}
void syslog_r(...){...}

where the above functions are meant to be a shorthand representing their full definition with args and code....
The last change might be necessary, but I think the wrong <syslog.h> gets pulled, so syslog_r references vsyslog_r, and reversing the definitions it doesn't matter if the header is included or not.

Was surprised - termux has come a long way, and most of my largest library compiled just fine (other than this small issue with libressl)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants