Add new compiler platform options
authorMarek Safar <marek.safar@gmail.com>
Thu, 1 Mar 2012 15:06:32 +0000 (15:06 +0000)
committerMarek Safar <marek.safar@gmail.com>
Fri, 2 Mar 2012 16:57:07 +0000 (16:57 +0000)
man/mcs.1
mcs/errors/cs1672.cs [new file with mode: 0644]
mcs/errors/cs4023.cs [new file with mode: 0644]
mcs/mcs/assembly.cs
mcs/mcs/driver.cs
mcs/mcs/settings.cs

index 71915a29c225c1f2d6a2470f67b2db17c119bf5f..959a8e56c0e386bbde355dc359ba0f1ce7a017ff 100644 (file)
--- a/man/mcs.1
+++ b/man/mcs.1
@@ -277,8 +277,8 @@ For more details see the PACKAGE section in this document
 .TP
 .I \-platform:ARCH
 Used to specify the target platform. The possible values are: anycpu,
-x86, x64 or itanium. As of June 2009, the Mono runtime only have support
-to emit anycpu and x86 assemblies.
+anycpu32bitpreferred, arm, x86, x64 or itanium. The default option is
+anycpu.
 .TP
 .I -resource:RESOURCE[,ID]
 Embeds to the given resource file.  The optional ID can be used to
diff --git a/mcs/errors/cs1672.cs b/mcs/errors/cs1672.cs
new file mode 100644 (file)
index 0000000..36cbc92
--- /dev/null
@@ -0,0 +1,3 @@
+// CS1672: Invalid -platform option `any'. Valid options are `anycpu', `anycpu32bitpreferred', `arm', `x86', `x64' or `itanium'
+// Line: 0
+// Compiler options: -platform:any
\ No newline at end of file
diff --git a/mcs/errors/cs4023.cs b/mcs/errors/cs4023.cs
new file mode 100644 (file)
index 0000000..628dd53
--- /dev/null
@@ -0,0 +1,3 @@
+// CS4023: Platform option `anycpu32bitpreferred' is valid only for executables
+// Line: 0
+// Compiler options: -platform:anycpu32bitpreferred -target:library
index b5c97b038da847d9f04bdc708f20671609f9ae42..a4299ea300ba148b6f29e90216712b39f8c0200b 100644 (file)
@@ -784,25 +784,38 @@ namespace Mono.CSharp
 
                public void Save ()
                {
-                       PortableExecutableKinds pekind;
+                       PortableExecutableKinds pekind = PortableExecutableKinds.ILOnly;
                        ImageFileMachine machine;
 
                        switch (Compiler.Settings.Platform) {
                        case Platform.X86:
-                               pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly;
+                               pekind |= PortableExecutableKinds.Required32Bit;
                                machine = ImageFileMachine.I386;
                                break;
                        case Platform.X64:
-                               pekind = PortableExecutableKinds.ILOnly;
+                               pekind |= PortableExecutableKinds.PE32Plus;
                                machine = ImageFileMachine.AMD64;
                                break;
                        case Platform.IA64:
-                               pekind = PortableExecutableKinds.ILOnly;
                                machine = ImageFileMachine.IA64;
                                break;
+                       case Platform.AnyCPU32Preferred:
+#if STATIC
+                               pekind |= PortableExecutableKinds.Preferred32Bit;
+                               machine = ImageFileMachine.I386;
+                               break;
+#else
+                               throw new NotSupportedException ();
+#endif
+                       case Platform.Arm:
+#if STATIC
+                               machine = ImageFileMachine.ARM;
+#else
+                               throw new NotSupportedException ();
+#endif
+                               break;
                        case Platform.AnyCPU:
                        default:
-                               pekind = PortableExecutableKinds.ILOnly;
                                machine = ImageFileMachine.I386;
                                break;
                        }
index 920951ea2efa225dacd25689325bd6be545db0f9..d3e2f2fad09f57090cad658bab5c3dce09bcaf1d 100644 (file)
@@ -211,6 +211,11 @@ namespace Mono.CSharp
                                return false;
                        }
 
+                       if (settings.Platform == Platform.AnyCPU32Preferred && (settings.Target == Target.Library || settings.Target == Target.Module)) {
+                               Report.Error (4023, "Platform option `anycpu32bitpreferred' is valid only for executables");
+                               return false;
+                       }
+
                        TimeReporter tr = new TimeReporter (settings.Timestamps);
                        ctx.TimeReporter = tr;
                        tr.StartTotal ();
index b82fec2872aa8e2fce774f5c5bdfe28c93088743..a1de45e3a7c9fbe0f79a83b0e333e6f709c90863 100644 (file)
@@ -47,7 +47,12 @@ namespace Mono.CSharp {
 
        public enum Platform
        {
-               AnyCPU, X86, X64, IA64
+               AnyCPU,
+               AnyCPU32Preferred,
+               Arm,
+               X86,
+               X64,
+               IA64
        }
 
        public class CompilerSettings
@@ -1045,7 +1050,10 @@ namespace Mono.CSharp {
                                        return ParseResult.Error;
                                }
 
-                               switch (value.ToLower (CultureInfo.InvariantCulture)) {
+                               switch (value.ToLowerInvariant ()) {
+                               case "arm":
+                                       settings.Platform = Platform.Arm;
+                                       break;
                                case "anycpu":
                                        settings.Platform = Platform.AnyCPU;
                                        break;
@@ -1058,8 +1066,12 @@ namespace Mono.CSharp {
                                case "itanium":
                                        settings.Platform = Platform.IA64;
                                        break;
+                               case "anycpu32bitpreferred":
+                                       settings.Platform = Platform.AnyCPU32Preferred;
+                                       break;
                                default:
-                                       report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'");
+                                       report.Error (1672, "Invalid -platform option `{0}'. Valid options are `anycpu', `anycpu32bitpreferred', `arm', `x86', `x64' or `itanium'",
+                                               value);
                                        return ParseResult.Error;
                                }
 
@@ -1518,7 +1530,7 @@ namespace Mono.CSharp {
                void Usage ()
                {
                        output.WriteLine (
-                               "Mono C# compiler, Copyright 2001 - 2011 Novell, Inc.\n" +
+                               "Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc\n" +
                                "mcs [options] source-files\n" +
                                "   --about              About the Mono C# compiler\n" +
                                "   -addmodule:M1[,Mn]   Adds the module to the generated assembly\n" +
@@ -1543,7 +1555,8 @@ namespace Mono.CSharp {
                                "   -out:FILE            Specifies output assembly name\n" +
                                "   -pkg:P1[,Pn]         References packages P1..Pn\n" +
                                "   -platform:ARCH       Specifies the target platform of the output assembly\n" +
-                               "                        ARCH can be one of: anycpu, x86, x64 or itanium\n" +
+                               "                        ARCH can be one of: anycpu, anycpu32bitpreferred, arm,\n" +
+                               "                        x86, x64 or itanium. The default is anycpu.\n" +
                                "   -recurse:SPEC        Recursively compiles files according to SPEC pattern\n" +
                                "   -reference:A1[,An]   Imports metadata from the specified assembly (short: -r)\n" +
                                "   -reference:ALIAS=A   Imports metadata using specified extern alias (short: -r)\n" +