[Mono-dev] Question regarding compiler optimizations causing floating point failure on Arm
Koushik K. Dutta
koush at koushikdutta.com
Mon Jan 19 16:04:33 EST 2009
Hi, I am building Mono/Arm under the Android build environment. The Android build environment uses various gcc architecture and optimizations flags which I detail at the bottom of this mail.
If I use the default flags of their build system, the following C# program has some very interesting/buggy results with regard to floating point values!
public static class Program
{
public static int Main(string[] args)
{
float num = 1.0f;
Console.WriteLine(num); // this prints 2.561887???!
return 0;
}
}
But if in my Android.mk (Android build's makefile), I use the "-O0" flag (turn off all optimizations), the program displays "1" as expected.
Does anyone have any thoughts/ideas as to why this is happening?
I have tried using ARM_FPU_VFP, ARM_FPU_NONE, and ARM_FPU_FPA.
Default Android "Release" Flags:
my @compile_args = (
"-march=armv5te",
"-mtune=xscale",
"-msoft-float",
"-mthumb-interwork",
"-fpic",
"-fno-exceptions",
"-ffunction-sections",
"-funwind-tables", # static exception-like tables
"-fstack-protector", # check guard variable before return
"-fmessage-length=0"); # No line length limit to error messages
my @optimize_args = (
"-O2",
"-finline-functions",
"-finline-limit=300",
"-fno-inline-functions-called-once",
"-fgcse-after-reload",
"-frerun-cse-after-loop", # Implicit in -O2 per texinfo
"-frename-registers",
"-fomit-frame-pointer",
"-fstrict-aliasing", # Implicit in -O2 per texinfo
"-funswitch-loops");
Koushik Dutta
www.koushikdutta.com<http://www.koushikdutta.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090119/33b9eeae/attachment.html
More information about the Mono-devel-list
mailing list