[x264-devel] [patch] improve configure for Solaris with Sun Workshop compilers

Tim Mooney Tim.Mooney at ndsu.edu
Tue Jan 3 19:46:55 CET 2012


[I'm not subscribed to the mailing list so please Cc: me on any replies,
assuming this post is approved by the moderator]

I recently built the x264 snapshot on x86_64-sun-solaris2.10 with
the no-cost Sun/Oracle Workshop compiler.  Below my sig you'll find a
patch that improves support for Solaris and the Workshop compiler in
particular.

I tried to make the patch as minimally-invasive as possible, so it
shouldn't have any negative impact on other platforms.

Of note from the patch:

- I created a suncc_cflags() routine, modeled after intel_cflags(), that
   translates many of the gcc flags into the Workshop equivalent.

   Note that this one routine isn't enough, because (like intel_cflags)
   it's called relatively early in the configure script, and later portions
   of configure augment CFLAGS, often with gcc-specific flags (like
   -Werror) that need to be tweaked for other compilers.

- automatically detect Sun Workshop compiler, filter the CFLAGS, and
   force C99 mode.  Note that older versions of Workshop wouldn't support
   the -xc99=all flag, but since x264 requires C99 anyway, that's not a
   regression.

- Fix the '-mimpure-text' logic so it's not passed when Sun cc is used.
   -m has a different meaning to the workshop compiler than it does to
   gcc, and it causes the library to essentially be non-functional.

- Set correct dependency flags for Workshop, and skip the use of ranlib.

Please let me know if you have any questions about the patch.

Thanks,

Tim
-- 
Tim Mooney                                             Tim.Mooney at ndsu.edu
Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
Room 242-J6, IACC Building                             701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164


--- x264-snapshot-20111228-2245.orig/configure	2011-12-28 15:45:03.000000000 -0600
+++ x264-snapshot-20111228-2245/configure	2011-12-30 16:57:02.071786398 -0600
@@ -110,6 +110,24 @@
      done
  }

+
+suncc_cflags() {
+    log_msg "Filtering CFLAGS for Sun Workshop compiler"
+    # Filter out some of the gcc flags that the Sun/Oracle Workshop compiler
+    # doesn't understand.  Many of these are modeled after intel_cflags()
+    for arg in $*; do
+        [ "$arg" = -falign-loops        ] && arg=
+        [ "$arg" = -ffast-math          ] && arg='-xlibmopt -fround=nearest '
+        [ "$arg" = -fno-tree-vectorize  ] && arg=
+        [ "$arg" = -fomit-frame-pointer ] && arg=
+        [ "$arg" = -fPIC                ] && arg=-KPIC
+        [ "$arg" = -g                   ] && arg='-g -xs '
+        [ "$arg" = -Wall                ] && arg=-errtags=yes
+        [ "$arg" = -Wshadow             ] && arg=
+        [ -n "$arg"                     ] && echo -n "$arg "
+    done
+}
+
  cc_check() {
      if [ -z "$3" ]; then
          if [ -z "$1$2" ]; then
@@ -391,6 +410,8 @@
  host_vendor="${host%%-*}"
  host_os="${host#*-}"

+log_msg "host=$host, host_os=$host_os, host_cpu=$host_cpu"
+
  # test for use of Intel Compiler
  if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
      if [[ `basename "$CC"` = icl* ]]; then
@@ -403,6 +424,15 @@
          `$CC 2>&1 | grep -q "Intel(R) 64"` && host_cpu=x86_64
          cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
      fi
+elif [[ $host_os = solaris* ]]; then
+    log_msg "Host is solaris"
+    if `$CC -V 2>&1 | grep 'Sun C' >/dev/null` ; then
+        log_msg "Compiler is suncc, filtering CFLAGS"
+        compiler=suncc
+        CFLAGS="$(suncc_cflags $CFLAGS)"
+        CFLAGS="$CFLAGS -Xa -xc99=all"
+        log_msg "After filtering CFLAGS=$CFLAGS"
+    fi
  else
      if [[ `basename "$CC"` = icc* ]]; then
          AR="xiar"
@@ -616,7 +647,7 @@

  cc_check || die "No working C compiler found."

-if [ $compiler != ICL ]; then
+if [ $compiler != ICL -a $compiler != suncc ]; then
      if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
          CFLAGS="$CFLAGS -std=gnu99"
      elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
@@ -741,6 +772,8 @@

  if cc_check "math.h" "-Werror" "return log2f(2);" ; then
      define HAVE_LOG2F
+elif cc_check "math.h" "-errwarn=%all" "return log2f(2);" ; then
+    define HAVE_LOG2F
  fi

  if [ "$vis" = "yes" ] ; then
@@ -876,7 +909,7 @@
      ASFLAGS="$ASFLAGS -DPIC"
      # resolve textrels in the x86 asm
      cc_check stdio.h "-shared -Wl,-Bsymbolic" && SOFLAGS="$SOFLAGS -Wl,-Bsymbolic"
-    [ $SYS = SunOS -a "$ARCH" = "X86" ] && SOFLAGS="$SOFLAGS -mimpure-text"
+    [ $SYS = SunOS -a "$ARCH" = "X86" -a $compiler != suncc ] && SOFLAGS="$SOFLAGS -mimpure-text"
  fi

  if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
@@ -959,6 +992,14 @@
      else
          CFLAGS="-DNDEBUG $CFLAGS"
      fi
+elif [ $compiler = suncc ]; then
+	AR="$AR rc "
+	DEPMM="-xM1"
+	DEPMT="-xM1"
+	LD="$CC -o "
+	LIBX264=libx264.a
+	# ranlib isn't needed, ar does it
+	RANLIB=
  else
      AR="$AR rc "
      DEPMM="-MM -g0"
@@ -971,6 +1011,8 @@
      PROF_GEN_LD="-fprofile-generate"
      PROF_USE_CC="-fprofile-use"
      PROF_USE_LD="-fprofile-use"
+elif [ $compiler = suncc ]; then
+    CFLAGS="$(suncc_cflags $CFLAGS)"
  else
      CFLAGS="$(intel_cflags $CFLAGS)"
      # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP


More information about the x264-devel mailing list