Skip to content

Commit

Permalink
Merge pull request #4433 from kumpera/android-fixes
Browse files Browse the repository at this point in the history
Fix a few issues on Android
  • Loading branch information
kumpera committed Feb 27, 2017
2 parents b7f7f8c + 34012db commit 6025544
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
33 changes: 27 additions & 6 deletions configure.ac
Expand Up @@ -1428,8 +1428,6 @@ if test x$host_win32 = xno; then

AC_CHECK_FUNCS(getgrgid_r)
AC_CHECK_FUNCS(getgrnam_r)
AC_CHECK_FUNCS(getpwnam_r)
AC_CHECK_FUNCS(getpwuid_r)
AC_CHECK_FUNCS(getresuid)
AC_CHECK_FUNCS(setresuid)
AC_CHECK_FUNCS(kqueue)
Expand All @@ -1450,6 +1448,11 @@ if test x$host_win32 = xno; then
AC_CHECK_FUNCS(sched_setaffinity)
AC_CHECK_FUNCS(sched_getcpu)

if test x$platform_android != xyes; then
AC_CHECK_FUNCS(getpwnam_r)
AC_CHECK_FUNCS(getpwuid_r)
fi

dnl ****************************************************************
dnl *** Check for sched_setaffinity from glibc versions before ***
dnl *** 2.3.4. The older versions of the function only take 2 ***
Expand Down Expand Up @@ -3310,7 +3313,6 @@ if test "x$host" != "x$target"; then
TARGET=ARM;
arch_target=arm;
AC_DEFINE(TARGET_ARM, 1, [...])
AC_DEFINE(TARGET_ANDROID, 1, [...])
ACCESS_UNALIGNED="no"
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
# Can't use tls, since it depends on the runtime detection of tls offsets
Expand All @@ -3323,6 +3325,11 @@ if test "x$host" != "x$target"; then
CPPFLAGS="$CPPFLAGS"
;;
armv5-*-linux-androideabi*)
AC_DEFINE(TARGET_ANDROID, 1, [...])
CPPFLAGS="$CPPFLAGS"
;;
*-linux-androideabi*)
AC_DEFINE(TARGET_ANDROID, 1, [...])
CPPFLAGS="$CPPFLAGS"
;;
esac
Expand All @@ -3342,23 +3349,33 @@ if test "x$host" != "x$target"; then
TARGET=X86;
arch_target=x86;
AC_DEFINE(TARGET_X86, 1, [...])
AC_DEFINE(TARGET_ANDROID, 1, [...])
CPPFLAGS="$CPPFLAGS"
# Can't use tls, since it depends on the runtime detection of tls offsets
# in mono-compiler.h
with_tls=pthread
target_mach=no

case "$target" in
*-linux-android*)
AC_DEFINE(TARGET_ANDROID, 1, [...])
;;
esac
;;
x86_64*-linux-*)
TARGET=AMD64;
arch_target=amd64;
AC_DEFINE(TARGET_AMD64, 1, [...])
AC_DEFINE(TARGET_ANDROID, 1, [...])
CPPFLAGS="$CPPFLAGS"
# Can't use tls, since it depends on the runtime detection of tls offsets
# in mono-compiler.h
with_tls=pthread
target_mach=no

case "$target" in
*-linux-android*)
AC_DEFINE(TARGET_ANDROID, 1, [...])
;;
esac
;;
x86_64-ps4-freebsd)
TARGET=AMD64;
Expand All @@ -3377,12 +3394,16 @@ if test "x$host" != "x$target"; then
TARGET=ARM64;
arch_target=arm64;
AC_DEFINE(TARGET_ARM64, 1, [...])
AC_DEFINE(TARGET_ANDROID, 1, [...])
CPPFLAGS="$CPPFLAGS"
# Can't use tls, since it depends on the runtime detection of tls offsets
# in mono-compiler.h
with_tls=pthread
target_mach=no
case "$target" in
*-linux-android*)
AC_DEFINE(TARGET_ANDROID, 1, [...])
;;
esac
;;
aarch64-*)
TARGET=ARM64
Expand Down
13 changes: 10 additions & 3 deletions mono/mini/alias-analysis.c
Expand Up @@ -159,10 +159,17 @@ lower_memory_access (MonoCompile *cfg)
for (ins = bb->code; ins; ins = ins->next) {
handle_instruction:
switch (ins->opcode) {
case OP_LDADDR:
g_hash_table_insert (addr_loads, GINT_TO_POINTER (ins->dreg), ins);
if (cfg->verbose_level > 2) { printf ("New address: "); mono_print_ins (ins); }
case OP_LDADDR: {
MonoInst *var = (MonoInst*)ins->inst_p0;
if (var->flags & MONO_INST_VOLATILE) {
if (cfg->verbose_level > 2) { printf ("Found address to volatile var, can't take it: "); mono_print_ins (ins); }
} else {
g_hash_table_insert (addr_loads, GINT_TO_POINTER (ins->dreg), ins);
if (cfg->verbose_level > 2) { printf ("New address: "); mono_print_ins (ins); }
}
break;
}

case OP_MOVE:
tmp = (MonoInst*)g_hash_table_lookup (addr_loads, GINT_TO_POINTER (ins->sreg1));
/*
Expand Down
3 changes: 1 addition & 2 deletions mono/mini/liveness.c
Expand Up @@ -231,8 +231,7 @@ analyze_liveness_bb (MonoCompile *cfg, MonoBasicBlock *bb)

#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("\t");
mono_print_ins (ins);
mono_print_ins_index (1, ins);
}
#endif

Expand Down
15 changes: 10 additions & 5 deletions mono/mini/method-to-ir.c
Expand Up @@ -348,14 +348,19 @@ mono_print_bb (MonoBasicBlock *bb, const char *msg)
{
int i;
MonoInst *tree;
GString *str = g_string_new ("");

printf ("\n%s %d: [IN: ", msg, bb->block_num);
g_string_append_printf (str, "%s %d: [IN: ", msg, bb->block_num);
for (i = 0; i < bb->in_count; ++i)
printf (" BB%d(%d)", bb->in_bb [i]->block_num, bb->in_bb [i]->dfn);
printf (", OUT: ");
g_string_append_printf (str, " BB%d(%d)", bb->in_bb [i]->block_num, bb->in_bb [i]->dfn);
g_string_append_printf (str, ", OUT: ");
for (i = 0; i < bb->out_count; ++i)
printf (" BB%d(%d)", bb->out_bb [i]->block_num, bb->out_bb [i]->dfn);
printf (" ]\n");
g_string_append_printf (str, " BB%d(%d)", bb->out_bb [i]->block_num, bb->out_bb [i]->dfn);
g_string_append_printf (str, " ]\n");

g_print ("%s", str->str);
g_string_free (str, TRUE);

for (tree = bb->code; tree; tree = tree->next)
mono_print_ins_index (-1, tree);
}
Expand Down
2 changes: 1 addition & 1 deletion mono/mini/mini-arm64.c
Expand Up @@ -1902,7 +1902,7 @@ mono_arch_create_vars (MonoCompile *cfg)
if (cfg->method->save_lmf) {
cfg->create_lmf_var = TRUE;
cfg->lmf_ir = TRUE;
#ifndef TARGET_MACH
#ifdef HAVE_GET_TLS_ADDR
cfg->lmf_ir_mono_lmf = TRUE;
#endif
}
Expand Down

0 comments on commit 6025544

Please sign in to comment.