[SPRNET-1267] Add optimize compiler flag for release build Created: 09/Nov/09  Updated: 07/Dec/09  Resolved: 07/Dec/09

Status: Resolved
Project: Spring.NET
Component/s: Spring-NET-CORE
Affects Version/s: 1.3.0 RC1
Fix Version/s: 1.3.0

Type: Improvement Priority: Minor
Reporter: Mark Pollack Assignee: Mark Pollack
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The build scripts did not include the optimize compiler flag. This results (in at least) the IsJITOptimizerDisabled flag set to true in the current build for RELEASE mode. It should be set to false.

The correct flag settings are

RELEASE: IsJITTrackingEnabled=false and IsJITOptimizerDisabled=false
DEBUG: IsJITTrackingEnabled=true and IsJITOptimizerDisabled=true



 Comments   
Comment by Mark Pollack [ 09/Nov/09 ]

Fixed by adding

<property name="build.optimize" value="false"/> to <target name="set-debug-build-configuration">

and

<property name="build.optimize" value="true"/> to <target name="set-release-build-configuration">

NAnt Build files updated to add optimize="${build.optimize}" option to csc task

Added test cases to check for the correct flag settings in the assembly metadata.

Good background information to investvate release/debug builds are

http://blog.vuscode.com/malovicn/archive/2007/08/05/releasing-the-build.aspx
http://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx
http://www.undermyhat.org/blog/2009/07/in-depth-determine-whether-a-type-method-variable-or-assembly-is-debug-or-release-build/

Comment by Mark Pollack [ 09/Nov/09 ]

A useful tip, in case you want to run the existing Spring.NET dlls with optimization turned on is on this post

http://www.hanselman.com/blog/DebugVsReleaseTheBestOfBothWorlds.aspx

<quote>

You can have the best of both worlds with a rather neat trick. The major differences between the default debug build and default release build are that when doing a default release build, optimization is turned on and debug symbols are not emitted. So:

Step 1: Change your release config to emit debug symbols. This has virtually no effect on the performance of your app, and is very useful if (when?) you need to debug a release build of your app.

Step 2: Compile using your new release build config, i.e. with debug symbols and with optimization. Note that 99% of code optimization is done by the JIT compiler, not the language compiler, so read on...

Step 3: Create a text file in your app's folder called xxxx.ini (or dll or whatever), where xxxx is the name of your executable. This text file should initially look like:

[.NET Framework Debugging Control]
GenerateTrackingInfo=0
AllowOptimize=1

Step 4: With these settings, your app runs at full speed. When you want to debug your app by turning on debug tracking and possibly turning off (CIL) code optimization, just use the following settings:

[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0

</quote>

Note that this applies to Foo.dll and/or Foo.exe, create a Foo.ini with the above information.

Generated at Fri Jan 24 04:44:11 UTC 2020 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.