Bugs item #738381, was opened at 2003-05-15 18:58
Message generated for change (Settings changed) made by drieseng
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=738381&group_id=31650
Category: None
Group: None
>Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: David Keber (dkeber)
Assigned to: Nobody/Anonymous (nobody)
Summary: vbc task optionoptimize attribute broken and ambiguous
Initial Comment:
The documentation for the /optimize switch in the VB Language reference states:
------------------------------------------------------------------------------
/optimize[ + | - ]
Arguments
+ | -
/optimize- disables compiler optimizations.
/optimize+ enables optimizations.
By default, optimizations are disabled.
------------------------------------------------------------------------------
As of release 0.8.2, if you use the following build file
<!-- The VB amb1 build file (option optimize broken and ambiguous) -->
<?xml version="1.0"?>
<project name="Bare Bones" default="build">
<target name="build" description="compiles the source code">
<vbc verbose="true" target="library" output="BareBones.dll">
debug="False"
optionoptimize="True">
<references>
<includes name="System.dll"/>
</references>
<resources>
<includes name="*.resx"/>
</resources>
<sources>
<includes name="*.vb"/>
</sources>
</vbc>
</target>
</project>
You get the following output:
build:
[vbc] Compiling 1 files to D:\...\BareBones.dll
[vbc] Contents of d:\...\tmpCC.tmp
/nologo
"/target:library"
"/out:D:\...\BareBones.dll"
"D:\...\amb1.vb"
The expected output is:
build:
[vbc] Compiling 1 files to D:\...\BareBones.dll
[vbc] Contents of d:\...\tmpCC.tmp
/nologo
"/target:library"
/optimize+
"/out:D:\...\BareBones.dll"
"D:\...\amb1.vb"
Similarly, if you change the build script above so that optionoptimize="False" you get
the following output:
build:
[vbc] Compiling 1 files to D:\...\BareBones.dll
[vbc] Contents of d:\...\tmpCC.tmp
/nologo
"/target:library"
"/out:D:\...\BareBones.dll"
"D:\...\amb1.vb"
The expected output is:
build:
[vbc] Compiling 1 files to D:\...\BareBones.dll
[vbc] Contents of d:\...\tmpCC.tmp
/nologo
"/target:library"
/optimize-
"/out:D:\...\BareBones.dll"
"D:\...\amb1.vb"
A work-around this problem for now is to leave the optionoptimize attribute out
altogether, then add a:
<arg value="/optimize+" />
to the build script. However, I would like to see the optionoptimize attribute working
as documented in the future.
----------------------------------------------------------------------
Comment By: David Keber (dkeber)
Date: 2003-07-10 21:40
Message:
Logged In: YES
user_id=778929
What I am asking is that you change line 236 in VbcTask.cs
(revision 1.11) from:
WriteOption(writer, "optimize");
to:
WriteOption(writer, "optimize+");
This will be an acceptable solution for me to this bug report,
as I am a 1.1 SDK user, and it should be an acceptable
solution for you to this bug report, because things will remain
status-quo.
However, for those poor people still using the 1.0 compiler, I
still believe the way it is presently structured is a bug, at
least according to the documentation that comes with it.
Check out:
ms-
help://MS.NETFrameworkSDK/vblr7net/html/valrfOptimizeEnabl
edisableOptimizations.htm
on a computer that has just the 1.0 framework installed, and
compare it to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vblr7/html/valrfoptimizeenabledisableoptimizations.asp
(or a computer that has the latest 1.1 SDK installed). You will
find that the documentation states in the 1.0 SDK on the
third line of the remarks section "the only way to prevent an
optimized output file is to specify "/optimize-" explicitly".
The new 1.1 SDK states that "By default, optimizations are
disabled". This is a change from the 1.0 SDK.
I don't know how the compilers were actually implemented,
but it seems to be going strictly by the respective
documentation, nant has a bug exactly because it "doesn't
assume the user wants /optimize[ + | - ]".
If you put "optionoptimize="False"" in your build file, nant will
write out NO "/optimize" option in this case (essentially, doing
absolutely nothing), which means that it will generate an
optimized output file in vbc.exe 1.0, and a non-optimized
output file in vbc.exe 1.1. This inconsistent behavior is due to
nant dodging responsibility for the question!
I believe that for nant to do "the right thing" in all cases, you
should change lines 235-237 in VbcTask.cs (revision 1.11)
from:
if (OptionOptimize) {
WriteOption(writer, "optimize");
}
to:
if (OptionOptimize) {
WriteOption(writer, "optimize+");
} else {
WriteOption(writer, "optimize-");
}
If you still want to "not assume what the user wants", then
you can use a Three-Value Boolean internally instead of a
straight boolean to represent this value:
enum ThreeValueBool {
Unspecified = 0,
False,
True
}
and default to "Unspecified" i.e. change line 67 from:
bool _optionOptimize = false;
to:
ThreeValueBool _optionOptimize = Unspecified;
This implementation of the optimize option would guarantee
that nant would work exactly like you want AND how I want.
Agreed?
----------------------------------------------------------------------
Comment By: Gert Driesen (drieseng)
Date: 2003-07-08 23:27
Message:
Logged In: YES
user_id=707851
NAnt uses a bool to see if it should output the optimize
command-line option or not.
If the user does not specify the optionoptimize attribute in
the buildfile than that bool is false too, and we can't just
assume he wants /optimize-
That why we only output /optimize is the user specified
optionoptimize="true" in the buildfile.
----------------------------------------------------------------------
Comment By: David Keber (dkeber)
Date: 2003-07-08 21:00
Message:
Logged In: YES
user_id=778929
Gert,
Excuse me, I made a typo when I was writing the initial
email. However, if you just eliminate the ">" from the "vbc"
line, then it actually is correct, but the behavior of nant is
still WRONG. To address my initial concern,
when "optionoptimize="False", nant should output:
/optimize-
Right now, it is outputting N O T H I N G. While technically,
this may be correct, it is not good or right.
Also, when "optionoptimize="True", nant should output:
/optimize+
Right now, it is outputting "/optimize". While technically, this
may be correct, it is not good or right.
Could you please address these issues before closing it? Or, if
you want, I can correct the code and send the changes to
you.
----------------------------------------------------------------------
Comment By: Gert Driesen (drieseng)
Date: 2003-07-03 13:20
Message:
Logged In: YES
user_id=707851
The example you provided is actually invalid, you have to
specify the optionoptimize on the vbc element.
so, it shouldn't be
<vbc verbose="true" target="library" output="BareBones.dll">
debug="False"
optionoptimize="True">
(notice that you've closed the vbc element before the debug
attribute)
but
<vbc verbose="true" target="library" output="BareBones.dll"
debug="False"
optionoptimize="True">
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=738381&group_id=31650
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers