[m-dev.] Cross-Compiling for Android

null at nowhere-dense.com null at nowhere-dense.com
Thu Apr 9 09:14:00 AEST 2020


On 08.04.2020 00:52, Peter Wang wrote:
> On Sat, 04 Apr 2020 17:22:28 -0400, null at nowhere-dense.com wrote:
>> Hello,
>> 
>> I wrote a small script to build Mercury cross-compilers for Android:
>> https://github.com/mephistopheles-8/mercury-cross-android
>> 
>> The process went more smoothly than I had expected, though I would not
>> use this for anything serious without careful testing. Feel free to
>> provide feedback.
>> 
>> I have only attempted to build the hlc.gc grade.  I was finally able 
>> to
>> test it with the 2020-03-29 ROTD and it still seems to work.
>> - mmc: mmc-DEV, built from 2020-03-28
>> - host: linux_x86_64
>> - target: armv7a, Android 5.1.1
>> - NDK: android-ndk-r20b
>> - SDK Version: 21
>> 
>> I tested statically linked binaries for other architectures with QEMU
>> and they also appeared to work (a good sign, though real devices would
>> be better).
>> 
>> I see that there has been a change to fetch clang version.  This fixes
>> an error parsing the Mercury.config file, though be advised that
>> `-dumpversion` would output the "equivalent" GCC version for older
>> versions of Clang (like the ones included in the NDK).  I am not sure 
>> if
>> there is a reliable solution for retrieving the clang version when
>> cross-compiling with older clang versions (aside from setting it
>> manually).
>> 
>> I am wondering now: Is it possible to build the test suite without
>> running it?
> 
> Hi Mark,
> 
> You could hack the %.out and %.res rules in tests/Mmake.common
> to not run the built executable, and to not compare the .out file
> with the .exp* files.
> 
> You might be able to use binfmt_misc to transparently run the test 
> suite
> under QEMU. Perhaps you've tried it already.
> 
> Peter

Thanks Peter,

I tried tests today using binfmt_misc/QEMU for armv7a-linux-androideabi.

I needed to add `--linkage static` to TESTS_FLAGS and invoked mmake with 
the following settings:

mmake \
     MMAKE_USE_MMC_MAKE=yes \
     MERCURY_CONFIG_DIR=$MERCURYDIR/lib/mercury \
     MERCURY_STDLIB_DIR=$MERCURYDIR/lib/mercury \
     MERCURY_DEFAULT_GRADE=hlc.gc

A number of tests failed, but I believe many to be an artifact of my 
setup (eg,
all of `recompilation` failed, many tests in `warnings`, etc).  I think 
most
of these are due to mmake or mmc being invoked in a way that is 
incompatible
with cross-compiling.  I don't think anything can be gleaned from these.

Other tests required parts of the Anroid system (eg, 
`hard_coded/dst_test`),
and were expected to fail on QEMU.

I narrowed the list down to failures that did not seem to involve the 
testing
process itself:

Segfaults occurred for the following tests:
- hard_coded/test_pretty_printer_defaults in grade hlc.gc
- tabling/boyer in grade hlc.gc
- tabling/expand_poly in grade hlc.gc
- tabling/expand_tuple in grade hlc.gc
- tabling/expand_tuple2 in grade hlc.gc
- tabling/fast_loose in grade hlc.gc
- tabling/fib_list in grade hlc.gc
- tabling/fib_string in grade hlc.gc

This test hung, and needed to be killed:
- hard_coded/weak_ptr in grade hlc.gc

This test printed an empty string instead of a zero in one location:
- string_format/string_format_o in grade hlc.gc

There were a total of 54 failures, many of which were in 
`recompilation`.
Here is a full list of failures, with those from `recompilation`
omitted:

hard_coded/dst_test in grade hlc.gc
hard_coded/system_sort in grade hlc.gc
hard_coded/target_mlobjs in grade hlc.gc
hard_coded/test_pretty_printer_defaults in grade hlc.gc
hard_coded/weak_ptr in grade hlc.gc
invalid_purity/purity_nonsense2-nodepend in grade hlc.gc
mmc_make/complex_test in grade hlc.gc
  ----- recompilation -----
string_format/string_format_o in grade hlc.gc
tabling/boyer in grade hlc.gc
tabling/expand_poly in grade hlc.gc
tabling/expand_tuple in grade hlc.gc
tabling/expand_tuple2 in grade hlc.gc
tabling/fast_loose in grade hlc.gc
tabling/fib_list in grade hlc.gc
tabling/fib_string in grade hlc.gc
valid_seq/opt_det_warn in grade hlc.gc
warnings/arg_order_rearrangment in grade hlc.gc
warnings/foreign_term_invalid in grade hlc.gc
warnings/non_term_user_special in grade hlc.gc
warnings/pragma_term_conflict in grade hlc.gc
warnings/term_indirect_warning in grade hlc.gc
warnings/unused_args_analysis in grade hlc.gc
warnings/warn_dead_procs in grade hlc.gc
warnings/warn_dead_procs_trace in grade hlc.gc

It may be a bit early to do anything with this information, but I 
thought it may be
of interest.

Best,
Mark






More information about the developers mailing list