5c ios10系統(tǒng),debug一切正常堕花, adhoc 環(huán)境下就崩潰文狱,小伙伴查了很久發(fā)現(xiàn)是一個(gè)配置項(xiàng)引起
在buildsetting中, 找到optimization level 缘挽, debug環(huán)境設(shè)置的是none瞄崇, a d ho c環(huán)境設(shè)置的是smallest fastest ,若把a(bǔ) d ho c 環(huán)境設(shè)置為none就解決了壕曼。?
這個(gè)編譯策略呢苏研,就是編譯器的優(yōu)化程度。早期因?yàn)橛布Y源不夠強(qiáng)大腮郊,編譯器在編譯過程中會(huì)對(duì)代碼進(jìn)行優(yōu)化摹蘑,提高代碼的效率。不過這個(gè)優(yōu)化過程轧飞,因?yàn)楸容^靠近硬件一層纹蝴,所以可能導(dǎo)致一些不兼容的問題庄萎。
很多Release包有問題而Debug包沒問題,就是因?yàn)镽elease默認(rèn)的是Fastest,Smallest而Debug默認(rèn)是None
作者:悟空沒空
鏈接:http://www.reibang.com/p/8637d95fe558
來源:簡(jiǎn)書
簡(jiǎn)書著作權(quán)歸作者所有塘安,任何形式的轉(zhuǎn)載都請(qǐng)聯(lián)系作者獲得授權(quán)并注明出處糠涛。
查了一下optimization level 代表的意義:
6.3.1.3 Optimization Levels
Without any optimization option, the compiler’s goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the subprogram and get exactly the results you would expect from the source code.
Turning on optimization makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program.
If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.
The default is optimization off. This results in the fastest compile times, but GNAT makes absolutely no attempt to optimize, and the generated programs are considerably larger and slower than when optimization is enabled. You can use the?-O?switch (the permitted forms are?-O0,?-O1?-O2,?-O3, and?-Os) to?gcc?to control the optimization level:
*?
-O0
No optimization (the default); generates unoptimized code but has the fastest compilation time.
Note that many other compilers do substantial optimization even if ’no optimization’ is specified. With gcc, it is very unusual to use?-O0?for production if execution time is of any concern, since?-O0?means (almost) no optimization. This difference between gcc and other compilers should be kept in mind when doing performance comparisons.
*?
-O1
Moderate optimization; optimizes reasonably well but does not degrade compilation time significantly.
*?
-O2
Full optimization; generates highly optimized code and has the slowest compilation time.
*?
-O3
Full optimization as in?-O2; also uses more aggressive automatic inlining of subprograms within a unit (Inlining of Subprograms) and attempts to vectorize loops.
*?
-Os
Optimize space usage (code and data) of resulting program.
Higher optimization levels perform more global transformations on the program and apply more expensive analysis algorithms in order to generate faster and more compact code. The price in compilation time, and the resulting improvement in execution time, both depend on the particular application and the hardware environment. You should experiment to find the best level for your application.
Since the precise set of optimizations done at each level will vary from release to release (and sometime from target to target), it is best to think of the optimization settings in general terms. See the `Options That Control Optimization' section in?Using the GNU Compiler Collection (GCC)?for details about the?-O?settings and a number of?-f?options that individually enable or disable specific optimizations.
Unlike some other compilation systems,?gcc?has been tested extensively at all optimization levels. There are some bugs which appear only with optimization turned on, but there have also been bugs which show up only in `unoptimized' code. Selecting a lower level of optimization does not improve the reliability of the code generator, which in practice is highly reliable at all optimization levels.
Note regarding the use of?-O3: The use of this optimization level ought not to be automatically preferred over that of level?-O2, since it often results in larger executables which may run more slowly. See further discussion of this point in?Inlining of Subprograms.