a fix for CPU and compiler detection pyrit
authorRadek Brich <radek.brich@devl.cz>
Tue, 15 Apr 2008 17:12:50 +0200
branchpyrit
changeset 70 4b84e90325c5
parent 69 303583d2fb97
child 71 4fedf7290929
a fix for CPU and compiler detection
SConstruct
tools/cpuflags.c
--- a/SConstruct	Mon Apr 14 12:51:50 2008 +0200
+++ b/SConstruct	Tue Apr 15 17:12:50 2008 +0200
@@ -71,6 +71,7 @@
 		intelcversion = str(testenv['INTEL_C_COMPILER_VERSION']/10.)
 		context.Result(intelcversion)
 	else:
+		intelcversion = ''
 		context.Result(intelc)
 	return intelc
 
@@ -82,6 +83,7 @@
 		gccversion = env['CCVERSION']
 		context.Result(gccversion)
 	else:
+		gccversion = ''
 		context.Result(False)
 	return gcc
 
--- a/tools/cpuflags.c	Mon Apr 14 12:51:50 2008 +0200
+++ b/tools/cpuflags.c	Tue Apr 15 17:12:50 2008 +0200
@@ -221,14 +221,10 @@
      {
        if (model <= 1) arch = "pentiumpro";
        else if (model < 7) arch = "pentium2";
-       else if (model == 7) arch = "pentium3";
-       else if (model < 15) arch = "pentium-m";
-       else if (model == 15)
-       {
-         if (stepping < 6) arch = "core";
-         else arch = "core2";
-       }
-
+       else if (model < 12) arch = "pentium3";
+       else if (model < 14) arch = "pentium-m";
+       else if (model == 14) arch = "prescott"; // core
+       else if (model == 15) arch = "core2";
      }
      else if (family > 6)
      { /* family == 15 */
@@ -295,7 +291,12 @@
    gccarch = arch;
    if (gccver < (float)4.3)
    {
-     if (!strcmp(gccarch, "core2")) gccarch = "pentium3";
+     if (!strcmp(gccarch, "core2")) gccarch = "pentium-m";
+   }
+   if (gccver < (float)3.41)
+   {
+     if (!strcmp(gccarch, "prescott")) gccarch = "pentium4";
+     if (!strcmp(gccarch, "pentium-m")) gccarch = "pentium4";
    }
    if (gccver < (float)3.4)
    {
@@ -314,7 +315,6 @@
      || !strcmp(gccarch, "pentium4"))
        gccarch = "pentiumpro";
    }
-
    if (gccver < (float)3.0)
    {
      if (!strcmp(gccarch, "athlon"))
@@ -322,8 +322,7 @@
      else if (!strcmp(gccarch, "k6"))
        gccarch = "pentium";
    }
-
-   if (gccver < (float)2.9)
+   if (gccver < (float)2.95)
    {
      if (!strcmp(gccarch, "pentiumpro"))
        gccarch = "i686";
@@ -351,7 +350,7 @@
      }
    }
 
-   /* intelc options */
+   /* IntelC options */
    iccarch = arch;
    icctune = arch;
    iccsimd = "";
@@ -361,8 +360,19 @@
    else if (simd.has_sse2) iccsimd = "-msse2";
 
    printf("%s\n", arch);
+
+   /* GCC flags */
    if (gccver >= 4.2) gccarch = "native";
-   printf("-march=%s -mtune=%s %s\n", gccarch, gccarch, gccsimd);
+#ifdef __x86_64__
+   /* do not output i386 flags on x86_64 */
+   if (strcmp(gccarch, "core2") != 0 && strcmp(gccarch, "native") != 0)
+     printf("%s\n", gccsimd);
+   else
+#endif
+   printf("-march=%s %s\n", gccarch, gccsimd);
+
+   /* IntelC flags */
    printf("-march=%s -mtune=%s %s\n", iccarch, icctune, iccsimd);
+
    return 0;
 }