Opened 8 years ago

Closed 7 years ago

#28935 closed enhancement (fixed)

ffmpeg: +universal variant

Reported by: daitakahashi Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: universal haspatch Cc: fran6co@…, n.a.hawes@…, neverpanic (Clemens Lang), ryandesign (Ryan Schmidt)
Port: ffmpeg

Description

Missing universal variant of ffmpeg prevents universal build of dependent ports (e.g., gimp2 depends on gegl). To solve this problem, I attached a patch that enables +universal variant of ffmpeg. I tested only a case when universal_archs is i386 x86_64, however, I think this patch will work for other architecture combinations.

Attachments (10)

ffmpeg-Portfile.diff (898 bytes) - added by daitakahashi 8 years ago.
main.log (957.6 KB) - added by fran6co@… 8 years ago.
Full log
ffmpeg-Portfile.2.diff (2.5 KB) - added by daitakahashi 8 years ago.
Update platform darwin 10
ffmpeg-asflags-Portfile.diff (1.8 KB) - added by daitakahashi 8 years ago.
add ASFLAGS to configure environment
main.2.log (1.5 MB) - added by fran6co@… 8 years ago.
Different log with the last patch, but it's weird because it's not stopping at the first error found.
ffmpeg-i386-no-inline-Portfile.diff (3.1 KB) - added by daitakahashi 8 years ago.
disable inlining for intel 32bit architecture (darwin 10)
ffmpeg-asflags-mmx_patch-Portfile.diff (1.9 KB) - added by fran6co@… 8 years ago.
The Portfile that worked for me
patch-ffmpeg-0.6-PIC_fix.diff (1.8 KB) - added by fran6co@… 8 years ago.
And the patch
ffmpeg-0.6.3_1-asflags-mmx_patch-Portfile.diff (1.9 KB) - added by daitakahashi 8 years ago.
proposed patch (updated for ffmpeg 0.6.3_1)
ffmpeg-Portfile.0.7.1.diff (1.7 KB) - added by daitakahashi 7 years ago.

Change History (36)

Changed 8 years ago by daitakahashi

Attachment: ffmpeg-Portfile.diff added

comment:1 Changed 8 years ago by ryandesign (Ryan Schmidt)

Cc: devans@… removed
Owner: changed from macports-tickets@… to devans@…
Summary: +universal variant of ffmpeg 0.6.1ffmpeg: +universal variant

comment:2 Changed 8 years ago by fran6co@…

It's not working for me:

:info:build /usr/bin/gcc-4.2 -I. -I"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_multimedia_ffmpeg/work/ffmpeg-0.6.1-i386" -I/opt/local/include -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -DHAVE_AV_CONFIG_H -pipe -O2 -DHAVE_LRINTF -I/opt/local/include -arch i386   -std=c99 -fomit-frame-pointer -fPIC -I/opt/local/include/dirac -I/opt/local/include/schroedinger-1.0 -I/opt/local/include/orc-0.4 -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wundef -Wmissing-prototypes -O3 -fno-math-errno -fno-tree-vectorize -Werror=implicit -Werror=missing-prototypes          -MMD -MF libavcodec/h264_cavlc.d -MT libavcodec/h264_cavlc.o -c -o libavcodec/h264_cavlc.o libavcodec/h264_cavlc.c
:info:build libavcodec/h264_cavlc.c: In function 'decode_residual':
:info:build libavcodec/h264_cavlc.c:411: warning: suggest parentheses around comparison in operand of &
:info:build libavcodec/cabac.h: In function 'get_cabac_noinline':
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h: In function 'decode_cabac_mb_ref':
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h: In function 'decode_cabac_residual_nondc':
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/x86/h264_i386.h:97: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/x86/h264_i386.h:44: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h: In function 'decode_cabac_residual_dc':
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/x86/h264_i386.h:97: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/x86/h264_i386.h:44: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h: In function 'decode_cabac_mb_mvd':
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:527: error: PIC register '%ebx' clobbered in 'asm'
:info:build libavcodec/cabac.h:641: error: PIC register '%ebx' clobbered in 'asm'
:info:build gmake: *** [libavcodec/h264_cabac.o] Error 1
:info:build gmake: *** Waiting for unfinished jobs....

comment:4 Changed 8 years ago by fran6co@…

I think the problem is when compiling something in 32bits when using a 64bit system.

comment:5 Changed 8 years ago by daitakahashi

Could you post the whole build-log? I would like to see ./configure arguments.

Changed 8 years ago by fran6co@…

Attachment: main.log added

Full log

comment:6 Changed 8 years ago by fran6co@…

Cc: fran6co@… added

Cc Me!

comment:7 Changed 8 years ago by daitakahashi

Workaround at platform darwine 10 was needed to adapt universal variant. Updated patch will solve the problem.

Changed 8 years ago by daitakahashi

Attachment: ffmpeg-Portfile.2.diff added

Update platform darwin 10

comment:8 Changed 8 years ago by fran6co@…

That way it disables mmx from the 32bit build. The compilation error seems to be a know issue with gcc when doing cross compilation with assembly code. Not sure if disabling mmx is the correct patch.

comment:9 Changed 8 years ago by daitakahashi

Your problem may come from the ignorance of target arch at the usability check of ebx resister. The new patch will solve a clobbering problem (mmx workaround is disabled to confirm that this is a separate problem).

Changed 8 years ago by daitakahashi

add ASFLAGS to configure environment

Changed 8 years ago by fran6co@…

Attachment: main.2.log added

Different log with the last patch, but it's weird because it's not stopping at the first error found.

comment:10 Changed 8 years ago by daitakahashi

Thank you for testing. Your log shows the first error (libavcodec/h264_cavlc.c compilation) is fixed, so the second problem is a different one (may relate to #20938). In my environment (OSX 10.5.8 Core2Duo), not gcc-4.0 but gcc-4.2 reproduced similar problem.

/usr/bin/gcc-4.2 -I. -I"/opt/local/var/macports/build/_LocalPort_port_multimedia_ffmpeg/work/ffmpeg-0.6.1" -I/opt/local/include -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -DHAVE_AV_CONFIG_H -pipe -O2 -DHAVE_LRINTF -I/opt/local/include -arch i386   -std=c99 -fomit-frame-pointer -fPIC -I/opt/local/include/dirac -I/opt/local/include/schroedinger-1.0 -I/opt/local/include/orc-0.4 -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wundef -Wmissing-prototypes -O3 -fno-math-errno -fno-tree-vectorize          -MMD -MF libavcodec/x86/dsputil_mmx.d -MT libavcodec/x86/dsputil_mmx.o -c -o libavcodec/x86/dsputil_mmx.o libavcodec/x86/dsputil_mmx.c
/dsputil_mmx.clibavcodec/x86/h264dsp_mmx.c: In function `h264_h_loop_filter_luma_mmx2':
libavcodec/x86/dsputil_mmx.c:727: error: can't find a register in class `GENERAL_REGS' while reloading `asm'
libavcodec/x86/dsputil_mmx.c:727: error: can't find a register in class `GENERAL_REGS' while reloading `asm'
libavcodec/x86/dsputil_mmx.c:727: error: can't find a register in class `GENERAL_REGS' while reloading `asm'
libavcodec/x86/dsputil_mmx.c:727: error: `asm' operand has impossible constraints
... long error messages

The problem was avoided by the suppression of inlining (-fno-inline or -finline-limit=small integer, possibly generates slow binary). I hope this can be applicable for 10.6 environment. The updated portfile includes this fix.

Changed 8 years ago by daitakahashi

disable inlining for intel 32bit architecture (darwin 10)

comment:11 Changed 8 years ago by daitakahashi

I also think that the patch posted on https://roundup.ffmpeg.org/issue2088 can be helpful.

comment:12 Changed 8 years ago by fran6co@…

I'm testing your patch because I'm trying to build opencv as a universal binary and ffmpeg is a strong dependency.

With the -fno-inline change it managed to compile, didn't try it if it works.

It also works using the patch to dsputil_mmx.c. I like that solution better because it doesn't disable inlining for 386 build. I think it needs to be tested on a 32bit environment, because this could be a fix for ticket #20938.

Changed 8 years ago by fran6co@…

The Portfile that worked for me

Changed 8 years ago by fran6co@…

And the patch

comment:13 Changed 8 years ago by fran6co@…

If this portfile gets accepted in Macports it should have a comment explaining that this is a gcc bug, not of ffmpeg.

comment:14 Changed 8 years ago by daitakahashi

Your updated patch works without any problems (OSX 10.5, i386/x86_64 universal), thank you very much.

For future reference: the link I posted here has been 404 since this morning, but the message can be found at mail-archive.

comment:15 Changed 8 years ago by n.a.hawes@…

Cc: n.a.hawes@… added

Cc Me!

comment:16 Changed 8 years ago by daitakahashi

Changes discussed here seems to be safely applicable for updated (0.6.2) ffmpeg port (snow leopard 64bit host, i386/x86_64). Could someone test updated port (with above changes) if it works?

comment:17 in reply to:  16 Changed 8 years ago by fran6co@…

Works for me! (Snow Leopard 10.6.7 64bit)

comment:18 Changed 8 years ago by dbevans (David B. Evans)

Status: newassigned

comment:19 Changed 8 years ago by dbevans (David B. Evans)

I have applied this most recent set of patches and have confirmed that it builds properly in the following cases:

Snow Leopard 10.6.7 x86_64 both universal and not Leopard 10.5.8 ppc not universal (universal is still building)

I've lost track of who's tested what where. If someone can verify that it works on i386 platforms (both Snow Leopard and Leopard would be good) then I'm ready to commit these changes.

comment:20 Changed 8 years ago by daitakahashi

No problem was found on leopard machine (32bit Core2 Duo, for both i386 and i386/x86_64 universal).

comment:21 Changed 8 years ago by daitakahashi

I confirmed that the newest ffmpeg 0.6.3 built fine with above patches (Snow leopard 10.6.7, Macbook Pro early 2011, i386/x86_64 universal).

comment:22 Changed 8 years ago by neverpanic (Clemens Lang)

Cc: cal@… added

Cc Me!

Changed 8 years ago by daitakahashi

proposed patch (updated for ffmpeg 0.6.3_1)

comment:23 Changed 8 years ago by daitakahashi

Although a small change is needed to adapt ffmpeg-0.6.3_1 (above patch), patches uploaded on this thread work fine with current ffmpeg port (Snow leopard 10.6.7, Macbook Pro early 2011, i386/x86_64 universal).

comment:24 Changed 7 years ago by ryandesign (Ryan Schmidt)

This ticket is long and I haven't read everything in it. Is this patch still needed for ffmpeg @0.7.1? What about ffmpeg-devel @20110628? If so, do the patches need to be refreshed for those versions, and if so, can someone do that?

comment:25 Changed 7 years ago by daitakahashi

As far as I tested, ffmpeg @0.7.1 does not require any of those patches (x86_64 and i386/x86_64 universal, OS X 10.6.8). I attach the patch to Portfile below.

Changed 7 years ago by daitakahashi

Attachment: ffmpeg-Portfile.0.7.1.diff added

comment:26 in reply to:  25 Changed 7 years ago by mroman@…

@dtakahashi42 Your path compiled ok in 32-bit 10.6 with gcc 4.5. Thanks!

comment:27 Changed 7 years ago by ryandesign (Ryan Schmidt)

Cc: ryandesign@… added
Keywords: haspatch added
Resolution: fixed
Status: assignedclosed

I committed a version of this latest patch in r82651. It allowed me to build ffmpeg for x86_64, i386, and both (universal), on Snow Leopard with Xcode 3.2.6, where before I was only able to build for x86_64. Hopefully this works on other configurations as well.

Note: See TracTickets for help on using tickets.