From: André Hentschel Subject: winegcc: Add support for Multiarch Architecture Specifiers (try 2) Message-Id: <51619A56.3040208@dawncrow.de> Date: Sun, 07 Apr 2013 18:09:58 +0200 http://bugs.winehq.org/show_bug.cgi?id=31790 (I'm traveling this week and most likely can't respond to questions from Mo-Fr) try 2: Fix allocation size --- tools/winegcc/winegcc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 06aa200..7e68d9f 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -358,12 +358,18 @@ static int check_platform( struct options *opts, const char *file ) static char *get_lib_dir( struct options *opts ) { static const char *stdlibpath[] = { LIBDIR, "/usr/lib", "/usr/local/lib", "/lib" }; + /* see http://wiki.debian.org/Multiarch/Tuples */ + static const char *archext32[] = { "32", "/i386-linux-gnu", "/i386-kfreebsd-gnu", + "/arm-linux-gnueabihf", "/arm-linux-gnueabi", + "/arm-linux-gnu", "/powerpc-linux-gnu" }; + static const char *archext64[] = { "64", "/x86_64-linux-gnu", "/x86_64-kfreebsd-gnu", + "/aarch64-linux-gnu", "/ppc64-linux-gnu" }; static const char libwine[] = "/libwine.so"; - unsigned int i; + unsigned int i, j; for (i = 0; i < sizeof(stdlibpath)/sizeof(stdlibpath[0]); i++) { - char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + strlen(libwine) + 3 ); + char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + strlen(libwine) + 21 ); strcpy( buffer, stdlibpath[i] ); p = buffer + strlen(buffer); while (p > buffer && p[-1] == '/') p--; @@ -372,15 +378,21 @@ static char *get_lib_dir( struct options *opts ) if (p > buffer + 2 && (!memcmp( p - 2, "32", 2 ) || !memcmp( p - 2, "64", 2 ))) p -= 2; if (opts->force_pointer_size == 4 || (!opts->force_pointer_size && opts->target_cpu != CPU_x86_64 && opts->target_cpu != CPU_ARM64)) { - strcpy( p, "32" ); - strcat( p, libwine ); - if (check_platform( opts, buffer )) goto found; + for (j = 0; j < sizeof(archext32)/sizeof(archext32[0]); j++) + { + strcpy( p, archext32[j] ); + strcat( p, libwine ); + if (check_platform( opts, buffer )) goto found; + } } if (opts->force_pointer_size == 8 || (!opts->force_pointer_size && (opts->target_cpu == CPU_x86_64 || opts->target_cpu == CPU_ARM64))) { - strcpy( p, "64" ); - strcat( p, libwine ); - if (check_platform( opts, buffer )) goto found; + for (j = 0; j < sizeof(archext64)/sizeof(archext64[0]); j++) + { + strcpy( p, archext64[j] ); + strcat( p, libwine ); + if (check_platform( opts, buffer )) goto found; + } } free( buffer ); continue; -- 1.7.10.4