From: Julian Seward Date: Tue, 17 Jan 2006 16:41:34 +0000 (+0000) Subject: Make the selection of the default platform a bit more sophisticated, X-Git-Tag: svn/VALGRIND_3_2_0~368 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f53ef345a09616c18a6a891fac245d32c9451a7e;p=thirdparty%2Fvalgrind.git Make the selection of the default platform a bit more sophisticated, so it does the right thing on ppc64-linux rigs. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5543 --- diff --git a/coregrind/launcher.c b/coregrind/launcher.c index e962a964ff..866695bd3d 100644 --- a/coregrind/launcher.c +++ b/coregrind/launcher.c @@ -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