[MPlayer-dev-eng] [PATCH] Suppress unsupported options when building with clang

Rowan James rowanj at phere.net
Mon Jul 26 10:49:45 CEST 2010


On 26/07/2010, at 6:12 PM, Alexander Strange wrote:

> 
> On Jul 26, 2010, at 1:05 AM, Rowan James wrote:
> 
>> This patch stops './configure --cc=clang' from generating command lines with options which clang doesn't support.
>> 
>> Specifically, clang does not support the '-mcpu=', '-falign-loops=', and '-shared-libgcc' options.
>> 
>> Developed and tested on OS X 10.6 w/ Xcode 3.2, clang SVN (current), gcc-4.2.1 (Apple)
>> 
>> Effectively removes warnings otherwise generated for each file; gcc (default) ./configure still builds the same.
> 
> How about making it use -Qunused-arguments instead? That stops it printing the warning.

I had the impression that  the args involved were never going to be used, so not generating them was the best approach, rather than suppressing the warning.  I'm open to suggestions on the matter, though.

> Did you check what circumstances -mcpu is used in?

No, actually - and with that I've simplified the patch a bit (updated version below). Replaced squelching the _mcpu variable with a clang-specific CFLAGS format string, as given for other compilers a couple of paragraphs later in the file.

> 
> Also, clang has worse problems. The clang integrated as can't compile mplayer asm yet, and configure's defaulting to -O4 enables link-time optimization which breaks everything. Still, that's not a reason to not fix this.

Absolutely it does - but it picks up other errors more reliably and clearly than GCC, and I'm currently using this as a probe project to familiarise myself with the source for some other stuff I have in mind.  The compiler-specific CFLAG format string I mentioned above was already defaulting to -O2 for compilers without their own case, so the -O4 issue you mention hadn't bitten me this time (I do remember it from trying this a few months back, though).


===================================================================
--- configure	(revision 31826)
+++ configure	(working copy)
@@ -1505,7 +1505,10 @@
 fi
 
 if darwin; then
-  extra_cflags="-mdynamic-no-pic -falign-loops=16 -shared-libgcc $extra_cflags"
+  extra_cflags="-mdynamic-no-pic $extra_cflags"
+  if test "$(basename $_cc)" != "clang" ; then
+    extra_cflags="-falign-loops=16 -shared-libgcc $extra_cflags"
+  fi
   _timer=timer-darwin.c
 fi
 
@@ -2539,6 +2542,8 @@
     CFLAGS="-O2 $_march $_mcpu $_pipe -fomit-frame-pointer -wd167 -wd556 -wd144"
   elif test "$cc_vendor" = "sun" ; then
     CFLAGS="-O2 $_march $_mcpu $_pipe -xc99 -xregs=frameptr"
+  elif test "$cc_vendor" = "clang"; then
+    CFLAGS="-O2 $_march $_pipe"
   elif test "$cc_vendor" != "gnu" ; then
     CFLAGS="-O2 $_march $_mcpu $_pipe"
   else



More information about the MPlayer-dev-eng mailing list