On 10/19/2012 05:03 AM, Thierry Reding wrote:
The builtin_compiler binary is used during the build process to generate
code for the builtin GLSL functions. Since this binary needs to be run
on the build host, it must not be cross-compiled.

This patch fixes the build system to compile a second version of the
source files and the builtin_compiler binary itself for the build
system. It does so by defining the CC_FOR_BUILD and CXX_FOR_BUILD
variables, which are searched for by the configure script and point to
the location of native C and C++ compilers.

In order for this to work properly, builtin_function.cpp is removed
from BUILT_SOURCES, otherwise the build system would try to generate it
before having had a chance to descend into the builtin_compiler
subdirectory. With the builtin_compiler and glsl_compiler now being
generated at different stages, the build instructions for glsl_compiler
can be simplified a bit.

Signed-off-by: Thierry Reding <thierry.red...@avionic-design.de>
---
Changes in v2:
- extend CFLAGS_FOR_BUILD and CXXFLAGS_FOR_BUILD with necessary flags
   (-Wall -fno-builtin-memcmp -fno-strict-aliasing) and introduce the new
   DEFINES_FOR_BUILD variable
- remove builtin_function.cpp from BUILT_SOURCES
- clean up source file lists for glsl_compiler and drop the now unneeded
   libglslcommon.la convenience library

  configure.ac                                      |  40 ++++++-
  m4/ax_prog_cc_for_build.m4                        | 140 ++++++++++++++++++++++
  m4/ax_prog_cxx_for_build.m4                       | 123 +++++++++++++++++++
  src/glsl/.gitignore                               |   1 -
  src/glsl/Makefile.am                              |  48 ++------
  src/glsl/builtin_compiler/.gitignore              |   6 +
  src/glsl/builtin_compiler/Makefile.am             |  67 +++++++++++
  src/glsl/{ => builtin_compiler}/builtin_stubs.cpp |   0
  8 files changed, 385 insertions(+), 40 deletions(-)
  create mode 100644 m4/ax_prog_cc_for_build.m4
  create mode 100644 m4/ax_prog_cxx_for_build.m4
  create mode 100644 src/glsl/builtin_compiler/.gitignore
  create mode 100644 src/glsl/builtin_compiler/Makefile.am
  rename src/glsl/{ => builtin_compiler}/builtin_stubs.cpp (100%)

diff --git a/configure.ac b/configure.ac
index ca24856..f0edd95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,7 +10,7 @@ AC_INIT([Mesa], [9.1.0],
      [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
  AC_CONFIG_AUX_DIR([bin])
  AC_CONFIG_MACRO_DIR([m4])
-AC_CANONICAL_HOST
+AC_CANONICAL_SYSTEM
  AM_INIT_AUTOMAKE([foreign])

  dnl http://people.gnome.org/~walters/docs/build-api.txt
@@ -24,9 +24,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

  m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

-LT_PREREQ([2.2])
-LT_INIT([disable-static])
-
  dnl Set internal versions
  OSMESA_VERSION=8
  AC_SUBST([OSMESA_VERSION])
@@ -45,7 +42,9 @@ LIBKMS_XORG_REQUIRED=1.0.0
  dnl Check for progs
  AC_PROG_CPP
  AC_PROG_CC
+AX_PROG_CC_FOR_BUILD
  AC_PROG_CXX
+AX_PROG_CXX_FOR_BUILD
  AM_PROG_CC_C_O
  AM_PROG_AS
  AC_CHECK_PROGS([MAKE], [gmake make])
@@ -54,6 +53,9 @@ AC_PROG_SED
  AC_PROG_MKDIR_P
  AC_PATH_PROG([MKDEP], [makedepend])

+LT_PREREQ([2.2])
+LT_INIT([disable-static])
+
  if test "x$MKDEP" = "x"; then
      AC_MSG_ERROR([makedepend is required to build Mesa])
  fi
@@ -155,6 +157,21 @@ dnl Cache LDFLAGS and CPPFLAGS so we can add to them and 
restore later
  _SAVE_LDFLAGS="$LDFLAGS"
  _SAVE_CPPFLAGS="$CPPFLAGS"

+dnl build host compiler macros
+DEFINES_FOR_BUILD=""
+AC_SUBST([DEFINES_FOR_BUILD])
+case "$build_os" in
+linux*|*-gnu*|gnu*)
+    DEFINES_FOR_BUILD="$DEFINES_FOR_BUILD -D_GNU_SOURCE"
+    ;;
+solaris*)
+    DEFINES_FOR_BUILD="$DEFINES_FOR_BUILD -DSVR4"
+    ;;
+cygwin*)
+    DEFINES_FOR_BUILD="$DEFINES_FOR_BUILD"
+    ;;
+esac
+
  dnl Compiler macros
  DEFINES=""
  AC_SUBST([DEFINES])
@@ -177,6 +194,7 @@ if test "x$GCC" = xyes; then
          CFLAGS="$CFLAGS -Wall -std=gnu99"
          ;;
      *)
+        CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD -Wall -std=c99"
          CFLAGS="$CFLAGS -Wall -std=c99"
          ;;
      esac
@@ -206,13 +224,16 @@ if test "x$GCC" = xyes; then
      CFLAGS=$save_CFLAGS

      # Work around aliasing bugs - developers should comment this out
+    CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD -fno-strict-aliasing"
      CFLAGS="$CFLAGS -fno-strict-aliasing"

      # gcc's builtin memcmp is slower than glibc's
      # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
+    CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD -fno-builtin-memcmp"
      CFLAGS="$CFLAGS -fno-builtin-memcmp"
  fi
  if test "x$GXX" = xyes; then
+    CXXFLAGS_FOR_BUILD="$CXXFLAGS_FOR_BUILD -Wall"
      CXXFLAGS="$CXXFLAGS -Wall"

      # Enable -fvisibility=hidden if using a gcc that supports it
@@ -229,10 +250,12 @@ if test "x$GXX" = xyes; then
      CXXFLAGS=$save_CXXFLAGS

      # Work around aliasing bugs - developers should comment this out
+    CXXFLAGS_FOR_BUILD="$CXXFLAGS_FOR_BUILD -fno-strict-aliasing"
      CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"

      # gcc's builtin memcmp is slower than glibc's
      # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
+    CXXFLAGS_FOR_BUILD="$CXXFLAGS_FOR_BUILD -fno-builtin-memcmp"
      CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp"
  fi

@@ -316,6 +339,14 @@ AC_ARG_ENABLE([debug],
      [enable_debug=no]
  )
  if test "x$enable_debug" = xyes; then
+    DEFINES_FOR_BUILD="$DEFINES_FOR_BUILD -DDEBUG"
+    if test "x$GCC_FOR_BUILD" = xyes; then
+        CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD -g"
+    fi
+    if test "x$GXX_FOR_BUILD" = xyes; then
+        CXXFLAGS_FOR_BUILD="$XXCFLAGS_FOR_BUILD -g"

Typo here...I changed this to $CXXFLAGS_FOR_BUILD and went ahead and pushed it. Thanks so much for doing this, and I'm sorry it took so absurdly long to get the patch upstream...

--Ken
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to