[MPlayer-dev-eng] [PATCH] Fix crash when using win32 codecs on mac osx / intel

Ulion ulion2002 at gmail.com
Mon Aug 27 16:02:57 CEST 2007


2007/8/27, Diego Biurrun <diego at biurrun.de>:
>
> The main problem is that -mstackrealign was introduced in gcc 4.2, so
> we cannot use it unconditionally.  I will revert your patch for now, if
> you can come up with a more general solution, that would be welcome.
>
> Diego

Ok. How about this attached patch using configure detect gcc flag?


-- 
Ulion
-------------- next part --------------
Index: configure
===================================================================
--- configure	(revision 24244)
+++ configure	(working copy)
@@ -1504,6 +1504,28 @@
   }
 fi
 
+# Check whether compiler support -mstackrealign or -fstackrealign flag.
+echocheck "cflag stackrealign"
+cat > $TMPC << EOF
+__attribute__((noinline)) static int foo3(int i1, int i2, int i3) {
+  return i3;
+}
+int main() {
+  return foo3(1,2,3)==3 ? 0 : 1;
+}
+EOF
+_cflag_stackrealign=
+if test "$cc_vendor" = "gnu" ; then
+  # Gcc earlier version on apple has flag -mstackrealign for intel x86 platform.
+  # Or gcc version above 4.2 has flag -fstackrealign.
+  cc_check -O4 -mstackrealign && _cflag_stackrealign=-mstackrealign || cc_check -O4 -fstackrealign && _cflag_stackrealign=-fstackrealign
+  if test -n "$_cflag_stackrealign" && ! tmp_run ; then
+    # Lost third parameter, try to fix it if we can.
+    cc_check -O4 $_cflag_stackrealign -fno-unit-at-a-time && tmp_run && _cflag_stackrealign="$_cflag_stackrealign -fno-unit-at-a-time"
+  fi
+fi
+test -n "$_cflag_stackrealign" && echores "$_cflag_stackrealign" || echores "no"
+
 # ---
 
 # now that we know what compiler should be used for compilation, try to find
@@ -7498,6 +7520,7 @@
 EXTRAXX_INC = $_inc_extra $_inc_extraxx
 OPTFLAGS = $CFLAGS \$(EXTRA_INC)
 CXXFLAGS = $CXXFLAGS \$(EXTRAXX_INC)
+CFLAG_STACKREALIGN = $_cflag_stackrealign
 INSTALLSTRIP = $_install_strip
 CHARSET = $_charset
 HELP_FILE = $_mp_help
Index: loader/Makefile
===================================================================
--- loader/Makefile	(revision 24244)
+++ loader/Makefile	(working copy)
@@ -11,6 +11,8 @@
 # QTX emulation is not supported in Darwin
 ifneq ($(TARGET_OS),Darwin)
 SRCS_COMMON += wrapper.S
+else
+win32.o: CFLAGS += $(CFLAG_STACKREALIGN)
 endif
 endif
 


More information about the MPlayer-dev-eng mailing list