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

Submitted by Haihao Xiang on Nov. 21, 2018, 2:47 a.m.

Details

Message ID 20181121024734.29307-1-haihao.xiang@intel.com
State New
Headers show

Commit Message

Haihao Xiang Nov. 21, 2018, 2:47 a.m.
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(+)

Comments

Derek Buitenhuis Nov. 21, 2018, 1:12 p.m.
On 21/11/2018 02:47, 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(+)

We require dead code elimination to build FFmpeg, so this shouldn't be needed.

What compiler are you using?

- derek
Hendrik Leppkes Nov. 21, 2018, 2:09 p.m.
On Wed, Nov 21, 2018 at 2:21 PM Derek Buitenhuis
<derek.buitenhuis@gmail.com> wrote:
>
> On 21/11/2018 02:47, 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(+)
>
> We require dead code elimination to build FFmpeg, so this shouldn't be needed.
>

This does not apply here, the function is called unconditionally on
x86 (or rather on ARCH_X86)
What we usually do is just put the contents of such functions into the
guard, and not the init function itself - instead of having a second
one.

- Hendrik
Derek Buitenhuis Nov. 21, 2018, 3:02 p.m.
On 21/11/2018 14:09, Hendrik Leppkes wrote:
> This does not apply here, the function is called unconditionally on
> x86 (or rather on ARCH_X86)
> What we usually do is just put the contents of such functions into the
> guard, and not the init function itself - instead of having a second
> one.

Ah, OK. My bad.

- Derek

Patch hide | download patch | download mbox

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