diff mbox

[FFmpeg-devel] configure: Fix DEF file post-processing with LTO enabled.

Message ID 20170822192646.8772-1-kasper93@gmail.com
State New
Headers show

Commit Message

Kacper Michajlow Aug. 22, 2017, 7:26 p.m. UTC
With LTO enabled exported symbol entry looks like:
av_audio_convert @3 DATA

In order to maintain valid format we need to strip everything after @.

This patch fixes linking libraries compiled with MinGW toolchain with LTO enabled.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kacper Michajlow Sept. 6, 2017, 6:03 p.m. UTC | #1
2017-08-22 21:26 GMT+02:00 Kacper Michajłow <kasper93@gmail.com>:

> With LTO enabled exported symbol entry looks like:
> av_audio_convert @3 DATA
>
> In order to maintain valid format we need to strip everything after @.
>
> This patch fixes linking libraries compiled with MinGW toolchain with LTO
> enabled.
>
> Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
> ---
>  configure | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
>
Bump after two weeks.

Thanks,
Kacper
Michael Niedermayer Sept. 8, 2017, 12:52 a.m. UTC | #2
On Wed, Sep 06, 2017 at 08:03:18PM +0200, Kacper Michajlow wrote:
> 2017-08-22 21:26 GMT+02:00 Kacper Michajłow <kasper93@gmail.com>:
> 
> > With LTO enabled exported symbol entry looks like:
> > av_audio_convert @3 DATA
> >
> > In order to maintain valid format we need to strip everything after @.
> >
> > This patch fixes linking libraries compiled with MinGW toolchain with LTO
> > enabled.
> >
> > Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
> > ---
> >  configure | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >
> Bump after two weeks.

in absence of anyone else applying this.

can you provide a testcase / command line to reproduce the issue
this fixes
maybe if its easy to reproduce it will get a reply sooner

thxs

[...]
Kacper Michajlow Sept. 23, 2017, 9:41 a.m. UTC | #3
2017-09-08 2:52 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:

> On Wed, Sep 06, 2017 at 08:03:18PM +0200, Kacper Michajlow wrote:
> > 2017-08-22 21:26 GMT+02:00 Kacper Michajłow <kasper93@gmail.com>:
> >
> > > With LTO enabled exported symbol entry looks like:
> > > av_audio_convert @3 DATA
> > >
> > > In order to maintain valid format we need to strip everything after @.
> > >
> > > This patch fixes linking libraries compiled with MinGW toolchain with
> LTO
> > > enabled.
> > >
> > > Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
> > > ---
> > >  configure | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > >
> > Bump after two weeks.
>
> in absence of anyone else applying this.
>
> can you provide a testcase / command line to reproduce the issue
> this fixes
> maybe if its easy to reproduce it will get a reply sooner
>
> thxs
>


Tested with latest nevcairiel's mingw build from files.1f0.de/mingw and
VS2017

Setup env for lib.exe and link.exe (adjust for your VS instalation):
"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\Common7\Tools\VsDevCmd.bat"

configure (let's disable everything for this cruel example):
sh configure --enable-lto --enable-shared --disable-static
--disable-everything --disable-avdevice --disable-avcodec
--disable-swresample --disable-swscale --disable-postproc

compile:
make

And now try to link something like

ver.c:
int main()
{
    return avfilter_version();
}

cl ver.c libavfilter\avfilter.lib -link

It will fail without the patch, because of trailing DATA in .def file
avfilter.lib was not correctly created by lib.exe and is not usable as it
doesn't have those symbols listed.

If you need real project to reproduce you can add --enable-lto to LAV
Filters configure options and built it. Without this patch it will fail.

Regards,
Kacper
diff mbox

Patch

diff --git a/configure b/configure
index 7201941c36..3ed7b72cf4 100755
--- a/configure
+++ b/configure
@@ -4919,12 +4919,12 @@  case $target_os in
         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
         dlltool="${cross_prefix}dlltool"
         if check_cmd lib.exe -list; then
-            SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
+            SLIB_EXTRA_CMD=-'sed -e "s/ @[^\r\n]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
             if enabled x86_64; then
                 LIBTARGET=x64
             fi
         elif check_cmd $dlltool --version; then
-            SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
+            SLIB_EXTRA_CMD=-'sed -e "s/ @[^\r\n]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(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=