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

Add Android support #374

Merged
merged 1 commit into from
Jan 5, 2021
Merged

Add Android support #374

merged 1 commit into from
Jan 5, 2021

Conversation

finagolfin
Copy link
Contributor

Works both completely locally in Termux without root, and when connecting to a linux server. Only remaining issue is that etserver --help doesn't work: I think that's because cxxopts is incompatible with LLVM libc++, as this patch runs fine on linux x86_64 with GNU libstdc++. I will look into that and patch that last bug later.

@@ -157,6 +162,10 @@ include_directories(
${UTEMPTER_INCLUDE_DIR}
)

IF(NOT ANDROID)
include_directories( external/UniversalStacktrace/ust )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No libexecinfo on Android.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ust uses libunwind now, can you try latest master and tell me what error you get if any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to work, as Android uses the LLVM libunwind but UniversalStacktrace seems to expect the nongnu one? I get errors about missing symbols like UNW_REG_IP when compiling, after changing external/UniversalStacktrace/ust/ust.hpp to include unwind.h instead of libunwind.h.

@@ -288,7 +296,7 @@ inline string GetTempDirectory() {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
std::string tmpDir = converter.to_bytes(wstring(buf, retval));
#else
string tmpDir = "/tmp";
string tmpDir = _PATH_TMP;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a trailing slash, the Windows one may need to be checked for that.

@@ -12,7 +12,7 @@ int TcpSocketHandler::connect(const SocketEndpoint &endpoint) {
memset(&hints, 0, sizeof(addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
#if __NetBSD__
#if defined(__NetBSD__) || defined(__ANDROID__)
hints.ai_flags = (AI_CANONNAME | AI_ADDRCONFIG);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted on SO, Android doesn't support these flags just like BSD, which is where its source comes from.

@@ -34,6 +34,8 @@
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */

#include "Headers.hpp"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missing when cross-compiling to Android, but is reproducible on linux too if cotire is turned off. I guess precompiling the headers pulls in other headers that weren't included originally.

@@ -157,6 +162,10 @@ include_directories(
${UTEMPTER_INCLUDE_DIR}
)

IF(NOT ANDROID)
include_directories( external/UniversalStacktrace/ust )
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ust uses libunwind now, can you try latest master and tell me what error you get if any?

@@ -64,9 +64,9 @@ int main(int argc, char** argv) {
el::Loggers::setVerboseLevel(3);
// default max log file size is 20MB for etserver
string maxlogsize = "20971520";
LogHandler::setupLogFile(&defaultConf, "/tmp/htm.log", maxlogsize);
LogHandler::setupLogFile(&defaultConf, GetTempDirectory() + "htm.log", maxlogsize);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up!

@finagolfin
Copy link
Contributor Author

Updated to replace /tmp in the tests too and built trunk natively on Android for the first time, passes all tests natively on Android.

@finagolfin
Copy link
Contributor Author

I found the cause of etserver --help choking: it's because one of the help strings was a certain length, worked around in termux/termux-packages@79de94f. Probably also related to libc++, still unsure why it happens as I haven't dug that deep.

@MisterTea MisterTea merged commit da43a44 into MisterTea:master Jan 5, 2021
@finagolfin finagolfin deleted the droid branch January 6, 2021 13:55
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

Successfully merging this pull request may close these issues.

2 participants