This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Android] -fpic default option

By default in Android we always compile with -fpic or -fPIC, even when
compiling executable. Because of that we have some test fails on

For example:
/* { dg-do run } */
/* { dg-options "-O2" } */

void exit (int);
void noreturn_autodetection_failed ();
__attribute__ ((noinline))
detect_noreturn ()
  exit (0);
main (void)
  detect_noreturn ();
  noreturn_autodetection_failed ();
  return 0;

If gcc knew, that we are not going to make a shared library (which is
implied if we are using pic option), then it would delete the call of
noreturn_autodetection_failed as a dead code. But in case of pic we
cannot rely on the fact that detect_noreturn () will not be
overwritten on runtime, eventhough we are compiling executable and
that will never happen! So in addition to several testfails, it seems
that we are losing an optimization opportunity here also.
I'm wondering, maybe we can use -fpie instead of -fpic by default in
the compiler (of course if there are no -shared or -c options; those
cases will mean that we cannot rely on the fact that we will have an
executable after linking)? It seems that it would solve the problem..
Of course we always can add something like { target nonpic } to all
tests that fail on Android, but probably the problem is deeper than
that and that would be only hiding our head in the sand.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]