diff mbox

[FFmpeg-devel] build: restore using dlltool/lib.exe for creating Win32 .lib files

Message ID 20180216212103.21036-1-h.leppkes@gmail.com
State Accepted
Commit 6d8bef8c05ea5dcb95f5930954cd6bd28868c2c9
Headers show

Commit Message

Hendrik Leppkes Feb. 16, 2018, 9:21 p.m. UTC
The GCC generated import libraries don't work properly when being imported
by MSVC, resulting in missing symbols at runtime.

This reverts 5b5365fe9 and partially reverts changes from 98a9b1f0d
---
 configure | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Hendrik Leppkes Feb. 17, 2018, 8:57 a.m. UTC | #1
On Fri, Feb 16, 2018 at 10:21 PM, Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> The GCC generated import libraries don't work properly when being imported
> by MSVC, resulting in missing symbols at runtime.
>
> This reverts 5b5365fe9 and partially reverts changes from 98a9b1f0d

For the record, Martin Storsjö, the original author of the change this
is reverting, could reproduce the failure and also send a revert to
Libav.
So unless someone objects, I'll push this in a day or so, since
without it using mingw-build libraries with MSVC is impossible right
now (without manual steps to re-generate the .lib file, anyway)

- Hendrik
Hendrik Leppkes Feb. 19, 2018, 9:27 p.m. UTC | #2
On Sat, Feb 17, 2018 at 9:57 AM, Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> On Fri, Feb 16, 2018 at 10:21 PM, Hendrik Leppkes <h.leppkes@gmail.com> wrote:
>> The GCC generated import libraries don't work properly when being imported
>> by MSVC, resulting in missing symbols at runtime.
>>
>> This reverts 5b5365fe9 and partially reverts changes from 98a9b1f0d
>
> For the record, Martin Storsjö, the original author of the change this
> is reverting, could reproduce the failure and also send a revert to
> Libav.
> So unless someone objects, I'll push this in a day or so, since
> without it using mingw-build libraries with MSVC is impossible right
> now (without manual steps to re-generate the .lib file, anyway)

And applied.

- Hendrik
diff mbox

Patch

diff --git a/configure b/configure
index 99c53d482a..3b06b86a6e 100755
--- a/configure
+++ b/configure
@@ -4994,6 +4994,10 @@  case $target_os in
         ;;
     mingw32*|mingw64*)
         target_os=mingw32
+        LIBTARGET=i386
+        if enabled x86_64; then
+            LIBTARGET="i386:x86-64"
+        fi
         if enabled shared; then
             # Cannot build both shared and static libs when using dllimport.
             disable static
@@ -5005,7 +5009,14 @@  case $target_os in
         SLIBSUF=".dll"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
-        SLIB_EXTRA_CMD='cp $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
+        if check_cmd lib.exe -list; then
+            SLIB_EXTRA_CMD=-'lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
+            if enabled x86_64; then
+                LIBTARGET=x64
+            fi
+        else
+            SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
+        fi
         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
         SLIB_INSTALL_LINKS=
         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
@@ -5013,6 +5024,7 @@  case $target_os in
         SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--disable-auto-image-base $$(@:$(SLIBSUF)=.def)'
         enabled x86_64 && objformat="win64" || objformat="win32"
+        dlltool="${cross_prefix}dlltool"
         ranlib=:
         enable dos_paths
         check_ldflags -Wl,--nxcompat,--dynamicbase
@@ -6886,6 +6898,7 @@  LD_O=$LD_O
 X86ASM_O=$X86ASM_O
 LD_LIB=$LD_LIB
 LD_PATH=$LD_PATH
+DLLTOOL=$dlltool
 WINDRES=$windres
 DEPWINDRES=$dep_cc
 DOXYGEN=$doxygen
@@ -6939,6 +6952,7 @@  LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
 EXTRALIBS=$extralibs
 COMPAT_OBJS=$compat_objs
 INSTALL=$install
+LIBTARGET=${LIBTARGET}
 SLIBNAME=${SLIBNAME}
 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}