I used icc to build some projects, such as ffmpeg. I disabled all compiler's optimization by using '-O0' instead of '-O3', but icc reported some error as shown below:
Part of source code is:
#define ARCH_ARM 0
Error messages are shown as follow:
libavutil/libavutil.a(float_dsp.o): In function `avpriv_float_dsp_init':
/export/qiang/sourceCode/ffmpeg-2.8.3/libavutil/float_dsp.c:132: undefined reference to `ff_float_dsp_init_aarch64'
/export/qiang/sourceCode/ffmpeg-2.8.3/libavutil/float_dsp.c:134: undefined reference to `ff_float_dsp_init_arm'
/export/qiang/sourceCode/ffmpeg-2.8.3/libavutil/float_dsp.c:136: undefined reference to `ff_float_dsp_init_ppc'
/export/qiang/sourceCode/ffmpeg-2.8.3/libavutil/float_dsp.c:140: undefined reference to `ff_float_dsp_init_mips'
If '-O3' is used, the above error messages don't exist. I want to disable all optimization options and remove useless condition branch. Which icc option is only used to remove useless condition?
The icc information is shown as follow:
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 184.108.40.206 Build 20140120
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
It looks like you would need to guard that section with #if ARCH_ARM .... #endif to avoid having the dead code elimination depend on optimization level. At -O0 there probably isn't enough analysis of possible code paths to accomplish dead code elimination on that basis.
I would have thought that -O1 or -Os would eliminate such a branch, as we needed in the past to get icc to minimize code size.
Thanks for your quick response.
There is too much source code like:
#define ARCH_ARM 0
It will take too much time to replace conditional branch with ' #if ARCH_ARM .... #endif'. Does icc have some specific compiling option to roll out this sort of useless conditional branch?
An alternative is when NOT ARM architecture, is to supply your own dummy functions (that should never get called)
printf("??? ff_float_dsp_init_arm called\n");
Do this as a separate .obj and place into a library.
When you build without dead code elimination then you will link in a function that should never be called.
When you build with dead code elimination, then the function will not be linked in.