]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make the selection of the default platform a bit more sophisticated,
authorJulian Seward <jseward@acm.org>
Tue, 17 Jan 2006 16:41:34 +0000 (16:41 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 17 Jan 2006 16:41:34 +0000 (16:41 +0000)
so it does the right thing on ppc64-linux rigs.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5543

coregrind/launcher.c

index e962a964ff37affb04b8852309ed9ea69ba80813..866695bd3d7866b74f1758ab9336b9fb3e755020 100644 (file)
@@ -59,6 +59,7 @@
 #endif
 
 /* Report fatal errors */
+__attribute__((noreturn))
 static void barf ( const char *format, ... )
 {
    va_list vargs;
@@ -70,6 +71,8 @@ static void barf ( const char *format, ... )
    va_end(vargs);
 
    exit(1);
+   /*NOTREACHED*/
+   assert(0);
 }
 
 /* Search the path for the client program */
@@ -185,6 +188,7 @@ int main(int argc, char** argv, char** envp)
    const char *toolname = NULL;
    const char *clientname = NULL;
    const char *platform;
+   const char *default_platform;
    const char *cp;
    char *toolfile;
    char launcher_name[PATH_MAX+1];
@@ -224,15 +228,40 @@ int main(int argc, char** argv, char** envp)
       toolname = "memcheck";
    }
 
-   /* Work out what platform to use */
+   /* Select a platform to use if we can't decide that by looking at
+      the executable (eg because it's a shell script).  Note that the
+      default_platform is not necessarily either the primary or
+      secondary build target.  Instead it's chosen to maximise the
+      chances that /bin/sh will work on it.  Hence for a primary
+      target of ppc64-linux we still choose ppc32-linux as the default
+      target, because on most ppc64-linux setups, the basic /bin,
+      /usr/bin, etc, stuff is built in 32-bit mode, not 64-bit
+      mode. */
+   if (0==strcmp(VG_PLATFORM,"x86-linux"))
+      default_platform = "x86-linux";
+   else if (0==strcmp(VG_PLATFORM,"amd64-linux"))
+      default_platform = "amd64-linux";
+   else if (0==strcmp(VG_PLATFORM,"ppc32-linux"))
+      default_platform = "ppc32-linux";
+   else if (0==strcmp(VG_PLATFORM,"ppc64-linux"))
+      default_platform = "ppc32-linux";
+   else
+      barf("Unknown VG_PLATFORM '%s'", VG_PLATFORM);
+
+   /* Work out what platform to use, or use the default platform if
+      not possible. */
    if (clientname == NULL) {
-      VG_(debugLog)(1, "launcher", "no client specified, defaulting platform to '%s'\n", VG_PLATFORM);
-      platform = VG_PLATFORM;
+      VG_(debugLog)(1, "launcher", 
+                       "no client specified, defaulting platform to '%s'\n",
+                        default_platform);
+      platform = default_platform;
    } else if ((platform = select_platform(clientname)) != NULL) {
       VG_(debugLog)(1, "launcher", "selected platform '%s'\n", platform);
    } else {
-      VG_(debugLog)(1, "launcher", "no platform detected, defaulting platform to '%s'\n", VG_PLATFORM);
-      platform = VG_PLATFORM;
+      VG_(debugLog)(1, "launcher", 
+                       "no platform detected, defaulting platform to '%s'\n",
+                       default_platform);
+      platform = default_platform;
    }
    
    /* Figure out the name of this executable (viz, the launcher), so