[MPlayer-cvslog] r24683 - in trunk: configure loader/Makefile

diego subversion at mplayerhq.hu
Tue Oct 2 00:46:33 CEST 2007


Author: diego
Date: Tue Oct  2 00:46:33 2007
New Revision: 24683

Log:
Detect support of and add necessary CFLAGS to avoid crashes when loading
Win32 DLLs on Mac OS X / Intel.
based on patch by Ulion, ulion2002 gmail com


Modified:
   trunk/configure
   trunk/loader/Makefile

Modified: trunk/configure
==============================================================================
--- trunk/configure	(original)
+++ trunk/configure	Tue Oct  2 00:46:33 2007
@@ -2301,6 +2301,25 @@ fi
 echores $_named_asm_args
 
 
+if darwin && test "$cc_vendor" = "gnu" ; then
+echocheck "GCC support of -mstackrealign"
+# GCC 4.2 and some earlier Apple versions support this flag on x86. Since
+# Mac OS X/Intel has an ABI different from Windows this is needed to avoid
+# crashes when loading Win32 DLLs. Unfortunately some gcc versions create
+# wrong code with this flag, but this can be worked around by adding
+# -fno-unit-at-a-time as described in the blog post at
+# http://www.dribin.org/dave/blog/archives/2006/12/05/missing_third_param/
+cat > $TMPC << EOF
+__attribute__((noinline)) static int foo3(int i1, int i2, int i3) { return i3; }
+int main(void) { return foo3(1,2,3) == 3 ? 0 : 1; }
+EOF
+  cc_check -O4 -mstackrealign && tmp_run && _stackrealign=-mstackrealign
+  test -z "$_stackrealign" && cc_check -O4 -mstackrealign -fno-unit-at-a-time \
+    && tmp_run && _stackrealign="-mstackrealign -fno-unit-at-a-time"
+  test -n "$_stackrealign" && echores "yes" || echores "no"
+fi # if darwin && test "$cc_vendor" = "gnu" ; then
+
+
 # Checking for CFLAGS
 _install_strip="-s"
 if test "$_profile" != "" || test "$_debug" != "" ; then
@@ -7527,6 +7546,7 @@ EXTRA_INC = $_inc_extra
 EXTRAXX_INC = $_inc_extra $_inc_extraxx
 OPTFLAGS = $CFLAGS \$(EXTRA_INC)
 CXXFLAGS = $CXXFLAGS \$(EXTRAXX_INC)
+CFLAG_STACKREALIGN = $_stackrealign
 INSTALLSTRIP = $_install_strip
 CHARSET = $_charset
 HELP_FILE = $_mp_help

Modified: trunk/loader/Makefile
==============================================================================
--- trunk/loader/Makefile	(original)
+++ trunk/loader/Makefile	Tue Oct  2 00:46:33 2007
@@ -11,6 +11,8 @@ SRCS_COMMON += ldt_keeper.c pe_image.c m
 # 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-cvslog mailing list