diff mbox

[FFmpeg-devel] Fix link errors when HAVE_X86ASM is not defined

Message ID fbec6a98-a568-c73c-378e-3423d4f03b16@gmail.com
State New
Headers show

Commit Message

James Almer Nov. 21, 2018, 3:27 p.m. UTC
On 11/20/2018 11:47 PM, Haihao Xiang wrote:
> This fixes the link errors below:
> 
> LD      ffmpeg_g
> libavfilter/libavfilter.so: undefined reference to `ff_scene_sad_avx2'
> libavfilter/libavfilter.so: undefined reference to `ff_scene_sad_sse2'
> collect2: error: ld returned 1 exit status
> Makefile:108: recipe for target 'ffmpeg_g' failed
> make: *** [ffmpeg_g] Error 1
> 
> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
> ---
>  libavfilter/x86/scene_sad_init.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/libavfilter/x86/scene_sad_init.c b/libavfilter/x86/scene_sad_init.c
> index 461fa406d9..7e93ef44d3 100644
> --- a/libavfilter/x86/scene_sad_init.c
> +++ b/libavfilter/x86/scene_sad_init.c
> @@ -20,6 +20,7 @@
>  #include "libavutil/x86/cpu.h"
>  #include "libavfilter/scene_sad.h"
>  
> +#if HAVE_X86ASM
>  #define SCENE_SAD_FUNC(FUNC_NAME, ASM_FUNC_NAME, MMSIZE)                      \
>  void ASM_FUNC_NAME(SCENE_SAD_PARAMS);                                         \
>                                                                                \
> @@ -50,3 +51,12 @@ ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
>      }
>      return NULL;
>  }
> +
> +#else
> +
> +ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
> +{
> +    return NULL;
> +}
> +
> +#endif
> \ No newline at end of file

Can you test the attached patch? It's more in line with how other asm
modules with the same issue were fixed before, like synth_filter in
libavcodec.
From 41e5c18028a74b7fc9e42a2050ad7290a0074fd6 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Wed, 21 Nov 2018 12:21:38 -0300
Subject: [PATCH] x86/scene_sad: fix link errors when HAVE_X86ASM is not
 defined

Reported-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavfilter/x86/scene_sad_init.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Xiang, Haihao Nov. 22, 2018, 12:57 a.m. UTC | #1
On Wed, 2018-11-21 at 12:27 -0300, James Almer wrote:
> On 11/20/2018 11:47 PM, Haihao Xiang wrote:

> > This fixes the link errors below:

> > 

> > LD      ffmpeg_g

> > libavfilter/libavfilter.so: undefined reference to `ff_scene_sad_avx2'

> > libavfilter/libavfilter.so: undefined reference to `ff_scene_sad_sse2'

> > collect2: error: ld returned 1 exit status

> > Makefile:108: recipe for target 'ffmpeg_g' failed

> > make: *** [ffmpeg_g] Error 1

> > 

> > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>

> > ---

> >  libavfilter/x86/scene_sad_init.c | 10 ++++++++++

> >  1 file changed, 10 insertions(+)

> > 

> > diff --git a/libavfilter/x86/scene_sad_init.c

> > b/libavfilter/x86/scene_sad_init.c

> > index 461fa406d9..7e93ef44d3 100644

> > --- a/libavfilter/x86/scene_sad_init.c

> > +++ b/libavfilter/x86/scene_sad_init.c

> > @@ -20,6 +20,7 @@

> >  #include "libavutil/x86/cpu.h"

> >  #include "libavfilter/scene_sad.h"

> >  

> > +#if HAVE_X86ASM

> >  #define SCENE_SAD_FUNC(FUNC_NAME, ASM_FUNC_NAME,

> > MMSIZE)                      \

> >  void

> > ASM_FUNC_NAME(SCENE_SAD_PARAMS);                                         \

> >                                                                             

> >    \

> > @@ -50,3 +51,12 @@ ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)

> >      }

> >      return NULL;

> >  }

> > +

> > +#else

> > +

> > +ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)

> > +{

> > +    return NULL;

> > +}

> > +

> > +#endif

> > \ No newline at end of file

> 

> Can you test the attached patch? It's more in line with how other asm

> modules with the same issue were fixed before, like synth_filter in

> libavcodec.


Yes, your patch works for me. However I think you should check
HAVE_AVX2_EXTERNAL as well in ff_scene_sad_get_fn_x86(), otherwise the link
error still exists if HAVE_X86ASM is 1 but HAVE_AVX2_EXTERNAL is 0. Both
HAVE_X86ASM and HAVE_AVX2_EXTERNAL are 0 on my system.

Thanks
Haihao


> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
James Almer Nov. 22, 2018, 1:42 a.m. UTC | #2
On 11/21/2018 9:57 PM, Xiang, Haihao wrote:
> On Wed, 2018-11-21 at 12:27 -0300, James Almer wrote:
>> On 11/20/2018 11:47 PM, Haihao Xiang wrote:
>>> This fixes the link errors below:
>>>
>>> LD      ffmpeg_g
>>> libavfilter/libavfilter.so: undefined reference to `ff_scene_sad_avx2'
>>> libavfilter/libavfilter.so: undefined reference to `ff_scene_sad_sse2'
>>> collect2: error: ld returned 1 exit status
>>> Makefile:108: recipe for target 'ffmpeg_g' failed
>>> make: *** [ffmpeg_g] Error 1
>>>
>>> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
>>> ---
>>>  libavfilter/x86/scene_sad_init.c | 10 ++++++++++
>>>  1 file changed, 10 insertions(+)
>>>
>>> diff --git a/libavfilter/x86/scene_sad_init.c
>>> b/libavfilter/x86/scene_sad_init.c
>>> index 461fa406d9..7e93ef44d3 100644
>>> --- a/libavfilter/x86/scene_sad_init.c
>>> +++ b/libavfilter/x86/scene_sad_init.c
>>> @@ -20,6 +20,7 @@
>>>  #include "libavutil/x86/cpu.h"
>>>  #include "libavfilter/scene_sad.h"
>>>  
>>> +#if HAVE_X86ASM
>>>  #define SCENE_SAD_FUNC(FUNC_NAME, ASM_FUNC_NAME,
>>> MMSIZE)                      \
>>>  void
>>> ASM_FUNC_NAME(SCENE_SAD_PARAMS);                                         \
>>>                                                                             
>>>    \
>>> @@ -50,3 +51,12 @@ ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
>>>      }
>>>      return NULL;
>>>  }
>>> +
>>> +#else
>>> +
>>> +ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
>>> +{
>>> +    return NULL;
>>> +}
>>> +
>>> +#endif
>>> \ No newline at end of file
>>
>> Can you test the attached patch? It's more in line with how other asm
>> modules with the same issue were fixed before, like synth_filter in
>> libavcodec.
> 
> Yes, your patch works for me. However I think you should check
> HAVE_AVX2_EXTERNAL as well in ff_scene_sad_get_fn_x86(), otherwise the link
> error still exists if HAVE_X86ASM is 1 but HAVE_AVX2_EXTERNAL is 0. Both
> HAVE_X86ASM and HAVE_AVX2_EXTERNAL are 0 on my system.

You're right, fixed and applied. Thanks.
diff mbox

Patch

diff --git a/libavfilter/x86/scene_sad_init.c b/libavfilter/x86/scene_sad_init.c
index 461fa406d9..f5331338af 100644
--- a/libavfilter/x86/scene_sad_init.c
+++ b/libavfilter/x86/scene_sad_init.c
@@ -36,11 +36,16 @@  static void FUNC_NAME(SCENE_SAD_PARAMS) {                                     \
     *sum += sad[0];                                                           \
 }
 
+#if HAVE_X86ASM
 SCENE_SAD_FUNC(scene_sad_sse2, ff_scene_sad_sse2, 16);
+#if HAVE_AVX2_EXTERNAL
 SCENE_SAD_FUNC(scene_sad_avx2, ff_scene_sad_avx2, 32);
+#endif
+#endif
 
 ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
 {
+#if HAVE_X86ASM
     int cpu_flags = av_get_cpu_flags();
     if (depth == 8) {
         if (EXTERNAL_AVX2_FAST(cpu_flags))
@@ -48,5 +53,6 @@  ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
         else if (EXTERNAL_SSE2(cpu_flags))
             return scene_sad_sse2;
     }
+#endif
     return NULL;
 }