openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.83k stars 2.56k forks source link

ANDROID_COMPILER_OPTIMIZATION Settings seems to have no affect #2074

Open cerupcat opened 11 years ago

cerupcat commented 11 years ago

When changing the ANDROID_COMPILER_OPTIMIZATION in config.make for Android to -Os, -O2, -O3 the apk sizes are always the same. So, it's assumed that this setting is having no affect.

Expected result: apk file size should be different in each optimization setting and the app should probably run faster in -O2 and -O3.

Actual result: No difference in size or speed.

How can we set the optimization level for an app?

bakercp commented 11 years ago

First, what version of oF are you using? If you are using the develop branch, have you tried

PROJECT_OPTIMIZATION_CFLAGS_RELEASE = PROJECT_OPTIMIZATION_CFLAGS_DEBUG =

documented in the config.make file?

bakercp commented 11 years ago

Here's a link to an example config.make file: https://github.com/openframeworks/openFrameworks/blob/develop/scripts/linux/template/linux64/config.make#L130-L131

cerupcat commented 11 years ago

I should specify, this is for Android. The config.make you pointed to seems to be for linux. In the Android project config.make there's a "ANDROID_COMPILER_OPTIMIZATION" but changing it seems to have no affect.

bakercp commented 11 years ago

I'm not exactly sure -- the new makefile system has a common config.make file for all platforms (including android). What version of oF are you using?

cerupcat commented 11 years ago

I believe I'm using 0.7.4, but with the dev version of ofAndroid. Even in the develop branch, if you go into a Android project you can see the config.make file and it has "ANDROID_COMPILER_OPTIMIZATION".

bakercp commented 11 years ago

Yeah, I think that is an artifact of the old make system -- I'd try modifying/adding the https://github.com/openframeworks/openFrameworks/blob/develop/scripts/linux/template/linux64/config.make#L130-L131 variables. Right now android systems should be using the following for the platform:

https://github.com/openframeworks/openFrameworks/blob/develop/libs/openFrameworksCompiled/project/android/config.android.default.mk#L191-L195

If the

PROJECT_OPTIMIZATION_CFLAGS_RELEASE = PROJECT_OPTIMIZATION_CFLAGS_DEBUG =

vars don't have an effect, then I think we need to ask @arturoc what he thinks :)

cerupcat commented 11 years ago

Hmm ok. Maybe I'm not using develop version of ofAndroid because I don't have a config.android.default.mk file and the only place there's a 'PROJECT_OPTIMIZATION_CFLAGS_RELEASE' is in the linux make files (in the version I'm using). Which would probably mean it's an issue in 0.7.4. I'll look into updating to develop.

cerupcat commented 11 years ago

Ok, I just updated to the dev branch and put in "PROJECT_OPTIMIZATION_CFLAGS_RELEASE =" and "PROJECT_OPTIMIZATION_CFLAGS_DEBUG =" to the projects config.make, but it still has no affect unfortunately.

danzeeeman commented 10 years ago

this can be closed. @cerupcat you have a misunderstanding of what the different compiler optimization options are and what they do. In the newer NDK these options have been changed to '''release''' and '''debug''' and they involved stripping or not stripping debugging symbols.

from the NDK Documentation:

'''This optional variable can be defined to either 'release' or 'debug'. This is used to alter the optimization level when building your application's modules.

A 'release' mode is the default, and will generate highly optimized binaries. The 'debug' mode will generate un-optimized binaries which are much easier to debug.

Note that if your application is debuggable (i.e. if your manifest sets the android:debuggable attribute to "true" in its tag), the default will be 'debug' instead of 'release'. This can be overridden by setting APP_OPTIM to 'release'.

Note that it is possible to debug both 'release' and 'debug' binaries, but the 'release' builds tend to provide less information during debugging sessions: some variables are optimized out and can't be inspected, code re-ordering can make stepping through the code difficult, stack traces may not be reliable, etc..'''