[Android] Build with -O2

Rafaël Carré funman at videolan.org
Sat Jan 12 08:22:55 CET 2013


Hello,

Le 11/01/2013 22:58, Edward Wang a écrit :
> On 13-01-11 05:18 AM, git at videolan.org (Rafaël Carré) <git at videolan.org 
> (Rafaël Carré)> wrote:
>> +EXTRA_CFLAGS="${EXTRA_CFLAGS} -O2"
>> +
> Maybe we should add -O2 only to release builds to aid in debugging?

Not really, -O2 was already used within VLC as it is automake default.

Extract from generated configure:

  if test "$GCC" = yes; then
    CFLAGS="-g -O2"
  else
    CFLAGS="-g"
  fi

So for VLC it effectively changed absolutely nothing.

I became concerned about this when checking MXPlayer's configuration for
FFmpeg; I noticed that we didn't use any -O for ffmpeg.

So basically the situation is:

- VLC : no change
- FFmpeg : -O2 instead of nothing
- other contribs : -O2 except if individual packages append another -O
option (only the last -O option specified on the command line will apply).


To aid in debugging here is what I recommand:

- Use default flags (i.e. -O2), sometimes it just works anyway.
- When the interesting variable you wanna see is 'optimized away', read
the source code to see how it is assigned.
   * from a struct member : print struct_instance->member
   * from a function : use 'up' command of gcc and print the variable
that was passed down to the function

- If above shortcuts failed:
   * go to the particular folder of what you want to debug (i.e. cd
vlc/android/src/ or cd vlc/android/modules/demux ..)
   * sed -i s/-O2/-O0/g Makefile
   * make clean ; make -j8
   * cd ../.....
   * vim compile.sh
   * comment out the call to *VLC* bootstrap and configure.sh (it is a
good thing to do anyway when you're not changing VLC code or only
selected bits, to speed up compilation).
   * ./compile.sh

=> the interesting source code will be rebuilt with -O0, so you keep
overall speed anyway, and rebuild is quite fast because you don't fully
rebuild VLC.


HTH,


More information about the Android mailing list