Merge pull request #2532 from lambdageek/monoerror-mono_object_new
[mono.git] / mono / utils / mono-hwcap.c
index d62be0b5ff537fc60a82cd6aea053fb54ea4e4ef..38c032696bb3052623064683ec599073fe63b2c6 100644 (file)
@@ -18,6 +18,9 @@
  * Copyright 2011-2013 Xamarin Inc
  */
 
+#include <stdlib.h>
+#include <string.h>
+
 #include "mono/utils/mono-hwcap.h"
 
 static gboolean hwcap_inited = FALSE;
@@ -25,8 +28,25 @@ static gboolean hwcap_inited = FALSE;
 void
 mono_hwcap_init (void)
 {
+       const char *verbose = g_getenv ("MONO_VERBOSE_HWCAP");
+       const char *conservative = g_getenv ("MONO_CONSERVATIVE_HWCAP");
+
        if (hwcap_inited)
                return;
 
-       mono_hwcap_arch_init ();
+#ifdef MONO_CROSS_COMPILE
+       /*
+        * If we're cross-compiling, we want to be as
+        * conservative as possible so that we produce
+        * code that's portable. Default to that.
+        */
+       if (!conservative)
+               conservative = "1";
+#endif
+
+       if (!conservative || strncmp (conservative, "1", 1))
+               mono_hwcap_arch_init ();
+
+       if (verbose && !strncmp (verbose, "1", 1))
+               mono_hwcap_print (stdout);
 }