我使用arm-none-eabi-gcc 4.8.4
Target: arm-none-eabi
Configured with: /home/build/work/GCC-4-8-build/src/gcc/configure --target=arm-none-eabi --prefix=/home/build/work/GCC-4-8-build/install-native --libexecdir=/home/build/work/GCC-4-8-build/install-native/lib --infodir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/home/build/work/GCC-4-8-build/install-native/arm-none-eabi --build=i686-linux-gnu --host=i686-linux-gnu --with-gmp=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-mpfr=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-mpc=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-isl=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-cloog=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-libelf=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r
Thread model: single
gcc version 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147] (GNU Tools for ARM Embedded Processors)
我写了一个简单的示例c文件:
volatile int v;
static inline void a(void)
{
v = 4;
}
static inline void b(void)
{
a();
}
int main(void)
{
a();
b();
return 0;
}
我用
编译它 /opt/toolchain/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g3 -std=gnu99 -Wa,-adhlns="inline_test.o.lst" -MMD -MP -MF"inline_test.d" -MT"inline_test.o" -c -o inline_test.o inline_test.c
并且函数没有内联
相反,如果我添加-O1
,那么。
使用--help=optimizers
参数我可以看到-O1
启用的参数是:
-fcombine-stack-adjustments [enabled]
-fcompare-elim [enabled]
-fcprop-registers [enabled]
-fdefer-pop [enabled]
-fforward-propagate [enabled]
-fguess-branch-probability [enabled]
-fif-conversion [enabled]
-fif-conversion2 [enabled]
-finline-functions-called-once [enabled]
-fipa-profile [enabled]
-fipa-pure-const [enabled]
-fipa-reference [enabled]
-fmerge-constants [enabled]
-fomit-frame-pointer [enabled]
-fsched-pressure [enabled]
-fsection-anchors [enabled]
-fshrink-wrap [enabled]
-fsplit-wide-types [enabled]
-ftree-bit-ccp [enabled]
-ftree-ccp [enabled]
-ftree-ch [enabled]
-ftree-copy-prop [enabled]
-ftree-copyrename [enabled]
-ftree-dce [enabled]
-ftree-dominator-opts [enabled]
-ftree-dse [enabled]
-ftree-fre [enabled]
-ftree-sink [enabled]
-ftree-slsr [enabled]
-ftree-sra [enabled]
-ftree-ter [enabled]
所以我尝试编译删除-O1
,但添加所有其他选项:
/opt/toolchain/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdefer-pop -fforward-propagate -fguess-branch-probability -fif-conversion -fif-conversion2 -finline-functions-called-once -fipa-profile -fipa-pure-const -fipa-reference -fmerge-constants -fomit-frame-pointer -fsched-pressure -fsection-anchors -fshrink-wrap -fsplit-wide-types -ftree-bit-ccp -ftree-ccp -ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-sink -ftree-slsr -ftree-sra -ftree-ter -g3 -std=gnu99 -Wa,-adhlns="inline_test.o.lst" -MMD -MP -MF"inline_test.d" -MT"inline_test.o" -c -o inline_test.o inline_test.c
但函数没有内联。
我需要替换哪些其他参数-O1
?
最好的问候
最高
答案 0 :(得分:0)
这不是保证,而是尝试-finline-functions。