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

Handle linking to liblog when [cross] building for Android using meson. #2784

Merged
merged 2 commits into from
Dec 28, 2023

Conversation

Kagetsuki
Copy link
Contributor

Description

When cross building with meson for the Android NDK, and additional link to liblog is required but was missing from the meson build directives. This adds checking in the meson build directives for if the system is android. Without linking the build will give the following error:

ld.lld: error: undefined symbol: __android_log_write
>>> referenced by catch_debug_console.cpp:24 (../src/catch2/internal/catch_debug_console.cpp:24)
>>>               internal_catch_debug_console.cpp.o:(Catch::writeToDebugConsole(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>> const&)) in archive src/catch2/libCatch2.a
clang-17: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

While testing I also tried a build on Termux and found that it too needed to have liblog linked, but in meson on Termux the system is reported as 'linux' instead of 'android', so I added a big of a hack to detect Termux by checking for its system data folder.

Test for both builds ran successfully on my Android device under Termux, but I had to copy over some .so libraries for the NDK build as the test doesn't statically link them - it doesn't seem particularly necessary for me but if this is an issue please comment and I'll try to add detection for NDK and impose a static build on the self test.

Also note I added the 'fs' module include toward the top of the meson.build file because that feels more "correct" to me.

Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c809cb4) 91.54% compared to head (c10f329) 91.51%.
Report is 11 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #2784      +/-   ##
==========================================
- Coverage   91.54%   91.51%   -0.04%     
==========================================
  Files         198      198              
  Lines        8241     8241              
==========================================
- Hits         7544     7541       -3     
- Misses        697      700       +3     

@horenmar horenmar added the Building and Packaging Issues affecting build/packaging scripts and utilities label Dec 28, 2023
@horenmar
Copy link
Member

Thanks, that looks reasonable.

What libraries did you have to copy manually?

@horenmar horenmar merged commit c8262e1 into catchorg:devel Dec 28, 2023
74 checks passed
@Kagetsuki
Copy link
Contributor Author

Thanks, that looks reasonable.

What libraries did you have to copy manually?

I don't remember off hand but it was some basic ~system level shared libraries. Basically if you just copy it to the device and run it in Termux it will complain that it's missing a few .so's. I didn't try to force a static build of the self test when android is detected because there's probably other use cases and environments other than Termux, and it did run with the extra libs copied from the NDK.

If this is actually an issue then it's probably an issue on other cross builds (EG with mingw) so adding a 'static' option that imposes a static build all the way down to the tests would be a general solution; but since nobody else has brought it up I think this is maybe something that can be ignored.

@Kagetsuki Kagetsuki deleted the android-crossbuild-log-dep branch December 30, 2023 04:32
@horenmar
Copy link
Member

Yeah, sounds like ignoring it for now is the best approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Building and Packaging Issues affecting build/packaging scripts and utilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants