[PATCH] winebuild: Use Clang to assemble if its integrated assembler is being used.

Charles Davis cdavis5x at gmail.com
Tue Jan 1 19:56:13 CST 2013


The configure script invokes the system 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 a) Clang
is detected and b) it is using (whether by request or by default) its
built-in assembler.
---
 aclocal.m4              | 19 +++++++++++++++++++
 configure.ac            |  3 +++
 tools/winebuild/utils.c | 12 ++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/aclocal.m4 b/aclocal.m4
index 14cf916..4c0101c 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -137,6 +137,25 @@ esac
 AC_CHECK_PROGS([$1],[$ac_prefix_list],[$3],[$4])])
 
 
+dnl **** Check if $CC is Clang and (if so) if integrated-as is being used ****
+dnl
+dnl Usage: WINE_CHECK_CLANG_AS
+dnl
+AC_DEFUN([WINE_CHECK_CLANG_AS],
+[AC_MSG_CHECKING([if the C compiler $CC is Clang])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#ifndef __clang__
+                                    #error not clang
+                                    #endif]])],
+                  [AC_MSG_RESULT(yes)
+                   AC_MSG_CHECKING([if the Clang compiler $CC is using its built-in assembler])
+                   AS_IF([$CC -### -c -x c - </dev/null 2>&1 | grep "-emit-obj" >/dev/null],
+                         [AC_MSG_RESULT(yes)
+                          AC_DEFINE_UNQUOTED(CLANG_AS,["]$CC["],
+                                             [Define to the path to the Clang binary to use to assemble.])],
+                         AC_MSG_RESULT(no))],
+                  AC_MSG_RESULT(no))])
+
+
 dnl **** Define helper functions for creating config.status files ****
 dnl
 dnl Usage: AC_REQUIRE([WINE_CONFIG_HELPERS])
diff --git a/configure.ac b/configure.ac
index 2cfa4d8..bf94dc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -827,6 +827,9 @@ case $host_os in
                                        AC_MSG_ERROR([Xcode 3.x cannot build 16-bit code correctly. Use --disable-win16 if you don't need 16-bit support.])],
                                        AC_MSG_RESULT([[cross-compiling, assuming yes]]))
     fi
+
+    dnl Check for Clang's integrated-as
+    WINE_CHECK_CLANG_AS
     ;;
   *)
     DLLFLAGS="$DLLFLAGS -fPIC"
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 09f9b73..faef341 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -345,10 +345,22 @@ struct strarray *get_as_command(void)
 
     if (!as_command)
     {
+#ifdef CLANG_AS
+        /* The native assembler might not support CFI pseudo-ops,
+         * but clang does. So if we were compiled with
+         * clang, we should assemble with clang, too.
+         */
+        static const char * const commands[] = { CLANG_AS, "clang", NULL };
+        as_command = find_tool( "clang", commands );
+#else
         static const char * const commands[] = { "gas", "as", NULL };
         as_command = find_tool( "as", commands );
+#endif
     }
     strarray_add_one( args, as_command );
+#ifdef CLANG_AS
+    strarray_add( args, "-xassembler", "-c", NULL );
+#endif
 
     if (force_pointer_size)
     {
-- 
1.7.12.4




More information about the wine-patches mailing list