控制编译器标志在Android NDK? [英] Controlling compiler flags in the Android NDK?

查看:155
本文介绍了控制编译器标志在Android NDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用 LOCAL_CFLAGS 将参数传递给编译器。然而, NDK建造正在插入选项后,我的 LOCAL_CFLAGS ,因此他们采取precedence。例如,我想指定 -Ofast ,而 NDK建造添加 -O2 之后,我自己的标志,并因为只有最后一个选项是一个具有任何影响,我无法用设置一定的优化标志测试我的code。

I know I can use LOCAL_CFLAGS to pass arguments to the compiler. However, ndk-build is inserting options after my LOCAL_CFLAGS, and therefore they take precedence. For example, I want to specify -Ofast, but ndk-build adds -O2 after my own flags, and since only the last option is the one that has any effect, I'm unable to test my code with certain optimization flags set.

有没有办法要么逼我的 LOCAL_CFLAGS 要在构建命令的最后一个选项,或禁用 NDK建造

Is there any way to either force my LOCAL_CFLAGS to be the last options on the build command, or to disable ndk-build from using certain flags?

例如,我的 LOCAL_CFLAGS 设置为:

-Wall -Wno-psabi -Ofast -D CP_USE_DOUBLES=0 -D USE_CHIPMUNK

和调用 G ++ NDK建造做的是:

<$c$c>/Library/Android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/$p$pbuilt/darwin-x86/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi-v7a/objs/native-activity/Main.od -fpic -ffunction截面-funwind桌-fstack-保护-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march =的ARMv7-A -mfloat-ABI = softfp -mfpu = VFP -f​​no-异常-fno-RTTI -mthumb -Os -fomit-frame-pointer的-fno严格走样-finline-上限= 64 -Ijni -Ijni /花栗鼠/包括/花栗鼠-I /库/安卓/ Android的NDK-R8B /来源/安卓/ native_app_glue -I /库/安卓/ Android的NDK-R8B /来源/ CXX-STL / STLport的/ STLport的-I /库/安卓/ Android的NDK-R8B /来源/ CXX-STL //加比++ /包括-Ijni -DANDROID -Wall -Wno-psabi -Ofast -D CP_USE_DOUBLES = 0 -D USE_CHIPMUNK -Wa, - noexecstack -frtti -O2 -DNDEBUG -g -I /库/安卓/ Android的NDK-R8B /平台/ Android的9 /弓臂/ usr / include目录-c JNI / Main.cpp的-o ./obj/local/armeabi-v7a/objs/native-activity /Main.o

有很多在那里,但特别注意到它首先指定 -Os ,再有就是我的 -Ofast ,并在那之后还有 -O2 。为什么它指定 -Os ,如果它要后来说 -O2 ,我不知道,但我我沮丧 -Ofast 被覆盖。

There's a lot in there, but specifically notice that it first specifies -Os, then there's my -Ofast, and then after that there's -O2. Why it specifies -Os if it's going to later say -O2, I don't know, but I'm frustrated my -Ofast is being overridden.

推荐答案

添加

APP_CFLAGS += -Ofast

您Application.mk。

to your Application.mk.

它不会加入 -O2 停止NDK但经过NDK的它会将你的标志。 这对我的作品与NDK R8B。

It will not stop NDK from adding -O2 but it will place your flag after the NDK's. This works for me with NDK r8b.

这篇关于控制编译器标志在Android NDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆