NetBSD Problem Report #48116

From www@NetBSD.org  Sun Aug 11 18:57:02 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3FB0D7105C
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 11 Aug 2013 18:57:02 +0000 (UTC)
Message-Id: <20130811185700.BA571711B5@mollari.NetBSD.org>
Date: Sun, 11 Aug 2013 18:57:00 +0000 (UTC)
From: schaecsn@gmx.net
Reply-To: schaecsn@gmx.net
To: gnats-bugs@NetBSD.org
Subject: multimedia/ffmpeg / ffplay do not build
X-Send-Pr-Version: www-1.0

>Number:         48116
>Category:       pkg
>Synopsis:       multimedia/ffmpeg / ffplay do not build
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 11 19:00:00 +0000 2013
>Closed-Date:    Sun Apr 14 19:15:50 +0000 2024
>Last-Modified:  Sun Apr 14 19:15:50 +0000 2024
>Originator:     Stefan
>Release:        Slackware 13
>Organization:
>Environment:
Linux vaio 2.6.35.14 #1 Sun Aug 11 00:35:
>Description:
multimedia/ffmpeg (on latest stable and on current):

The Makefile is odd:

# disable asm on i386 for non-gcc and gcc < 4.2
# no alignment options needed for gcc >= 4.6 on i386

.if !empty(MACHINE_PLATFORM:MDarwin-*-i386) \
 || !empty(MACHINE_PLATFORM:MSunOS-*-i386)
CONFIGURE_ARGS+=       --disable-asm
.elif !empty(CC_VERSION:Mgcc-4.[2345]*)
CFLAGS+=-mstackrealign -mpreferred-stack-boundary=4
.elif !empty(CC_VERSION:Mgcc-[123]*) \
   || !empty(CC_VERSION:Mgcc-4.[01]*) \
   || empty(CC_VERSION:Mgcc*)
CONFIGURE_ARGS+=        --disable-asm
.endif
.endif

Both .elif cover gcc-4.2 and gcc-4.3. By way of how .elif works, only the
first .elif branch is taken. The intention oft the code is to take also the
second .elif branch.

Then, the first comment line does not go along with the code -
neither with the actual code flow nor with the intented code flow. I run
gcc-4.3 on i386/linux and need --disable-asm, otherwise ffmpeg does not build (issues in  libavcodec/x86/vc1dsp_mmx.o). 



multimedia/ffplay does not build, either:


LD      ffplay_g
libavcodec/libavcodec.so: undefined reference to `ff_mpeg_draw_horiz_band'
libavcodec/libavcodec.so: undefined reference to `ff_h264_draw_horiz_band'
collect2: ld returned 1 exit status
make: *** [ffplay_g] Error 1
*** Error code 2

Stop.
bmake: stopped in /usr/pkgsrc/multimedia/ffplay
*** Error code 1




>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/48116
Date: Tue, 13 Aug 2013 21:23:26 +0200

 --- /usr/pkgsrc/multimedia/ffmpeg/Makefile.orig	2013-08-11 22:51:09.000000000 +0200
 +++ /usr/pkgsrc/multimedia/ffmpeg/Makefile	2013-08-11 22:53:02.000000000 +0200
 @@ -40,14 +40,13 @@
  # no alignment options needed for gcc >= 4.6 on i386
  .if ${MACHINE_ARCH} == "i386"
  .  if !empty(MACHINE_PLATFORM:MDarwin-*-i386) \
 -   || !empty(MACHINE_PLATFORM:MSunOS-*-i386)
 +   || !empty(MACHINE_PLATFORM:MSunOS-*-i386) \
 +   || !empty(CC_VERSION:Mgcc-[123]*) \
 +   || !empty(CC_VERSION:Mgcc-4.[01]*) \
 +   ||  empty(CC_VERSION:Mgcc*)
  CONFIGURE_ARGS+=	--disable-asm
  .  elif !empty(CC_VERSION:Mgcc-4.[2345]*)
  CFLAGS+=		-mstackrealign -mpreferred-stack-boundary=4
 -.  elif !empty(CC_VERSION:Mgcc-[123]*) \
 -     || !empty(CC_VERSION:Mgcc-4.[01]*) \
 -     || empty(CC_VERSION:Mgcc*)
 -CONFIGURE_ARGS+=	--disable-asm
  .  endif
  .endif


 Maybe add

    || (!empty(MACHINE_PLATFORM:MLinux-*-i386) &&
        !empty(CC_VERSION:M-gcc-4.[0123])) \

 to the list of possible conditions for
 the --disable-asm configure option too.

 Onno

State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Wed, 14 Aug 2013 17:55:16 +0000
State-Changed-Why:
I've applied Onno's patch. Did this fix the problem for you?


From: "Thomas Klausner" <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48116 CVS commit: pkgsrc/multimedia/ffmpeg
Date: Wed, 14 Aug 2013 17:54:07 +0000

 Module Name:	pkgsrc
 Committed By:	wiz
 Date:		Wed Aug 14 17:54:07 UTC 2013

 Modified Files:
 	pkgsrc/multimedia/ffmpeg: Makefile

 Log Message:
 Apply patch from Onno van der Linden to try fixing PR 48116.


 To generate a diff of this commit:
 cvs rdiff -u -r1.112 -r1.113 pkgsrc/multimedia/ffmpeg/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Adam Ciarcinski" <adam@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48116 CVS commit: pkgsrc/multimedia/ffmpeg2
Date: Thu, 15 Aug 2013 10:21:30 +0000

 Module Name:	pkgsrc
 Committed By:	adam
 Date:		Thu Aug 15 10:21:30 UTC 2013

 Modified Files:
 	pkgsrc/multimedia/ffmpeg2: Makefile

 Log Message:
 Apply patch from Onno van der Linden to try fixing PR 48116.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 pkgsrc/multimedia/ffmpeg2/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Stefan Schaeckeler <schaecsn@gmx.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48116 (multimedia/ffmpeg / ffplay do not build)
Date: Fri, 30 Aug 2013 15:01:12 -0700 (PDT)

 Ops, my analysis of the Makefile was wrong. Nevertheless, there is a problem with my version of gcc, 4.3.3.


 > I've applied Onno's patch. Did this fix the problem for you?

 The committed version r1.113 is slightly different from the version posted here. Let me comment on  r1.113: The Makefile is still not passing the option --disable-asm for gcc-4.3.3 to the configure script.

 A side note: I don't need these other options  "-mstackrealign -mpreferred-stack-boundary=4". ffmpeg compiles, builds and runs fine without them on gcc-4.3.3, as well. Actually, my gcc does not even know -mstackrealign and irgnores it.


 The second part of my bug report, the linking issue of ffplay (perhaps only on Linux?), is not yet addressed.

From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: pkg/48116 (multimedia/ffmpeg / ffplay do not build)
Date: Sun, 1 Sep 2013 17:53:06 +0200

 On Fri, Aug 30, 2013 at 10:05:00PM +0000, Stefan Schaeckeler wrote:
 >  The committed version r1.113 is slightly different from the version posted here. Let me comment on  r1.113: The Makefile is still not passing the option --disable-asm for gcc-4.3.3 to the configure script.

 Let's go back a step. The code definitely does not try to add
 --disable-asm when building with gcc-4.3.3. Why is it needed for you?

 What are the symptoms you see?

 >  The second part of my bug report, the linking issue of ffplay (perhaps only on Linux?), is not yet addressed.

 Separate bug reports for separate problems makes lives easier :)
  Thomas

From: Stefan Schaeckeler <schaecsn@gmx.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48116 (multimedia/ffmpeg / ffplay do not build)
Date: Sun,  1 Sep 2013 12:33:14 -0700 (PDT)

 >  Let's go back a step. The code definitely does not try to add
 >  --disable-asm when building with gcc-4.3.3. Why is it needed for you?
 >  
 >  What are the symptoms you see?

 With gcc 4.3.3 + not --disable-asm, I run into http://ffmpeg.org/faq.html#error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027

 Somehow it looks to me that sucess/failure to compile ffmpeg's inline assembler code depends on a combination of the gcc version and gcc flags. This makes it a quite fragile package for pkgsrc.


 I can build ffmpeg successfully:

 - gcc 4.3.3 (native) + --disable-asm

 - gcc 4.5 (from pkgsrc) + without --disable-asm

From: Stefan Schaeckeler <schaecsn@gmx.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48116 (multimedia/ffmpeg / ffplay do not build)
Date: Sun,  1 Sep 2013 13:13:39 -0700 (PDT)

 >  >  The second part of my bug report, the linking issue of ffplay (perhaps only on Linux?), is not yet addressed.
 >  
 >  Separate bug reports for separate problems makes lives easier :)

 I can't disagree, but here we have to deal with a package that was artificially split into two packages by the pkgsrc team. So problems and solutions are interleaved. I looked into the ffplay linker problem:


 1. Need to know:

 With configure option --disable-asm, the library libavcodec is solely build from sources in ./ffmpeg-1.2.1/libavcodec/.

 Without option --disable-asm, most files are taken from ./ffmpeg-1.2.1/libavcodec/ but others are taken from ./ffmpeg-1.2.1/libavcodec/x86/.



 2. At least on my machine:

 configure option --disble-asm must be passed to gcc 4.3.3. Gcc 4.5 does not need this option (at least not with CFLAGS+= -O2 -march=pentium4 -pipe)



 3. my linker issue with the current pkgsrc Makefile in multimedia/ffplay is for gcc 4.3.3 with configure option --disable-asm (without --disable-asm,  I run into the 'can't find a register' issue posted above):

 libavcodec/libavcodec.so: undefined reference to `ff_mpeg_draw_horiz_band'
 libavcodec/libavcodec.so: undefined reference to `ff_h264_draw_horiz_band'


 These definitions are in

 ./ffmpeg-1.2.1/libavcodec/mpegvideo.c:void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)

 ./ffmpeg-1.2.1/libavcodec/h264.c:void ff_h264_draw_horiz_band(H264Context *h, int y, int height)


 The Makefile in multimedia/ffmpeg does not trigger the compilation of these two .c files. Experimenting showed that this is because configure option --disable-decoders is passed in multimedia/ffplay/Makefile.

 When configuring without option --disable-asm, alternative code is taken from ffmpeg-1.2.1/libavcodec/x86/ that does not refer to these definitions.



 4. Fix. I see several ways to proceed:

 A. compile everything with gcc 4.5

  Add GCC_REQD+= 4.5 to ffmpeg/Makefile.common. This makes sure that configure option --disable-asm is not chosen.

 Or

 B. Move the gcc version checks from ffmpeg/Makefile to ffmpeg/Makefile.common. Make sure these checks pass --disable-asm to gcc 4.3.3. Then, also comment out CONFIGURE_ARGS+= --disable-decoders in ffplay/Makefile for this version of gcc to make sure mpegvideo.c and h264.c are compiled into libavcodec/libavcodec.so.

State-Changed-From-To: feedback->open
State-Changed-By: obache@NetBSD.org
State-Changed-When: Sat, 08 Mar 2014 12:43:30 +0000
State-Changed-Why:
feedback is provided


State-Changed-From-To: open->closed
State-Changed-By: gutteridge@NetBSD.org
State-Changed-When: Sun, 14 Apr 2024 19:15:50 +0000
State-Changed-Why:
This issue was addressed more broadly by nia@ in r. 1.76 of ffmpeg2's Makefile. Sorry for the delay!

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.