This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH,cygming,buildsys] Fix remaining parts of PR40125: [2/2] libffi


    Hi all,

  GCC PR40125(*) is about Windows DLLs getting installed to the wrong place in
cross-compilers.  By convention on windows systems, DLLs live in $prefix/bin
rather than $prefix/lib, since windows doesn't have an equivalent of
LD_LIBRARY_PATH; all shared libs have to be in the regular PATH.

  That's fine for a native compiler, but for a cross-compiler, the DLLs built
are target libraries, not host ones.  It doesn't make sense to install them in
$prefix/$target/bin, because that contains host binaries.  What does make
plenty of sense however is to install them somewhere under
$prefix/$target/lib, since that is chock-full of target binaries already,
libraries in particular, and following some discussion in the PR audit trail
we decided toolexeclibdir was the right place.

  This patch fixes the problem by passing an appropriate -bindir argument in
the cygwin/mingw libtool flags, based on with_cross_host.  It fixes the
problem only for GCC at the moment, as upstream libffi still uses an older
version of libtool from before the -bindir argument was implemented; thus,
this patch will make no difference to libffi at present, which will still have
the old default libtool behaviour of placing DLLs into $(libdir)/../bin.  When
libffi next upgrades its libtool, it should just work.

libffi/ChangeLog:

2010-12-22  Dave Korn  <dave.korn.cygwin@gmail.com>

	PR target/40125
	* configure.ac (AM_LTLDFLAGS): Add -bindir option for windows DLLs.
	* configure: Regenerate.

  Tested by building and installing (to a DESTDIR) i686-pc-cygwin native, and
i686-pc-cygwin x i686-pc-mingw32 cross-compilers, and verifying that the DLLs
all got installed to the correct locations, and also by building upstream
libffi (the same patch applies cleanly to both GCC and upstream) and verifying
that nothing changed.  Is this OK?

    cheers,
      DaveK
-- 
(*) - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40125

Index: libffi/configure
===================================================================
--- libffi/configure	(revision 167484)
+++ libffi/configure	(working copy)
@@ -11359,8 +11359,15 @@ case "$host" in
 	;;
   i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
 	TARGET=X86_WIN32; TARGETDIR=x86
-	# All mingw/cygwin/win32 builds require this for sharedlib
-	AM_LTLDFLAGS="-no-undefined"
+	# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
+	# We must also check with_cross_host to decide if this is a native
+	# or cross-build and select where to install dlls appropriately.
+	if test -n "$with_cross_host" &&
+	   test x"$with_cross_host" != x"no"; then
+	  AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
+	else
+	  AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
+	fi
 	;;
   i?86-*-darwin*)
 	TARGET=X86_DARWIN; TARGETDIR=x86
Index: libffi/configure.ac
===================================================================
--- libffi/configure.ac	(revision 167484)
+++ libffi/configure.ac	(working copy)
@@ -82,8 +82,15 @@ case "$host" in
 	;;
   i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
 	TARGET=X86_WIN32; TARGETDIR=x86
-	# All mingw/cygwin/win32 builds require this for sharedlib
-	AM_LTLDFLAGS="-no-undefined"
+	# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
+	# We must also check with_cross_host to decide if this is a native
+	# or cross-build and select where to install dlls appropriately.
+	if test -n "$with_cross_host" &&
+	   test x"$with_cross_host" != x"no"; then
+	  AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
+	else
+	  AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
+	fi
 	;;
   i?86-*-darwin*)
 	TARGET=X86_DARWIN; TARGETDIR=x86


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]