[PATCH] winebuild: Use Clang to assemble if found. (try 5)

Charles Davis cdavis5x at gmail.com
Fri Jan 25 12:38:09 CST 2013


Try 5: Don't use strstr(3).

The configure script invokes the C compiler to figure out if .cfi
pseudo-ops are supported, on the assumption that it will invoke the
system assembler. Winebuild, on the other hand, invokes the system
assembler directly. This caused a problem on Mac OS hosts when compiling
with Clang: configure would detect that .cfi ops were supported, because
Clang's integrated assembler supports them; however, when winebuild then
emitted assembly with .cfi ops in them, the system assembler would then
choke. This patch makes winebuild invoke Clang's assembler if it is
found in the path.

Note that if you have Clang installed, winebuild will now always invoke
it to assemble.
---
 tools/winebuild/utils.c | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 559e476..10a50cf 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -288,8 +288,6 @@ char *find_tool( const char *name, const char * const *names )
     unsigned int i, len;
     struct stat st;
 
-    if (target_alias) return strmake( "%s-%s", target_alias, name );
-
     if (!dirs)
     {
         char *path;
@@ -322,6 +320,8 @@ char *find_tool( const char *name, const char * const *names )
     while (*names)
     {
         len = strlen(*names) + sizeof(EXEEXT) + 1;
+        if (target_alias)
+            len += strlen(target_alias) + 1;
         file = xmalloc( maxlen + len );
 
         for (i = 0; i < count; i++)
@@ -330,6 +330,12 @@ char *find_tool( const char *name, const char * const *names )
             p = file + strlen(file);
             if (p == file) *p++ = '.';
             if (p[-1] != '/') *p++ = '/';
+            if (target_alias)
+            {
+                strcpy( p, target_alias );
+                p += strlen(p);
+                *p++ = '-';
+            }
             strcpy( p, *names );
             strcat( p, EXEEXT );
 
@@ -338,21 +344,38 @@ char *find_tool( const char *name, const char * const *names )
         free( file );
         names++;
     }
-    return xstrdup( name );
+    return NULL;
 }
 
 struct strarray *get_as_command(void)
 {
+    static int as_is_clang = 0;
     struct strarray *args = strarray_init();
 
     if (!as_command)
     {
+        as_command = find_tool( "clang", NULL );
+        if (as_command) as_is_clang = 1;
+    }
+
+    if (!as_command)
+    {
         static const char * const commands[] = { "gas", "as", NULL };
         as_command = find_tool( "as", commands );
     }
+
+    if (!as_command)
+        fatal_error( "cannot find suitable assembler\n" );
+
     strarray_add_one( args, as_command );
 
-    if (force_pointer_size)
+    if (as_is_clang)
+    {
+        strarray_add( args, as_command, "-xassembler", "-c", NULL );
+        if (force_pointer_size)
+            strarray_add_one( args, (force_pointer_size == 8) ? "-m64" : "-m32" );
+    }
+    else if (force_pointer_size)
     {
         switch (target_platform)
         {
@@ -386,6 +409,10 @@ struct strarray *get_ld_command(void)
         static const char * const commands[] = { "ld", "gld", NULL };
         ld_command = find_tool( "ld", commands );
     }
+
+    if (!ld_command)
+        fatal_error( "cannot find suitable linker\n" );
+
     strarray_add_one( args, ld_command );
 
     if (force_pointer_size)
@@ -421,6 +448,9 @@ const char *get_nm_command(void)
         static const char * const commands[] = { "nm", "gnm", NULL };
         nm_command = find_tool( "nm", commands );
     }
+
+    if (!nm_command)
+        fatal_error( "cannot find suitable name lister\n" );
     return nm_command;
 }
 
-- 
1.7.12.4




More information about the wine-patches mailing list