Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#30137 closed defect (fixed)

ffmpeg: Cannot build in OS X 10.6.8 on 32-bit Mac

Reported by: skiskywalker@… Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: Cc: ryandesign (Ryan Carsten Schmidt), rmstonecipher@…, domiman@…, andrew@…, jeremyhu (Jeremy Huddleston Sequoia), cooljeanius (Eric Gallager)
Port: ffmpeg

Description (last modified by mf2k (Frank Schima))

Citizens of MacPorts Land, I humbly request your assistance in a matter that has me baffled.

I had been using ffmpeg and several other ports successfully in Leopard on my 32-bit MacBook. When I recently upgraded to Mac OS X 10.6.8, I followed your Migration instructions and so my MacPorts installation was removed. I then installed Xcode 4.0.2 and XQuartz 2.6.2. I installed the Snow Leopard version of MacPorts and have successfully installed and used other ports.

Unfortunately, ffmpeg does not build. It says:

$ sudo port -c install ffmpeg
--->  Computing dependencies for ffmpeg
--->  Fetching ffmpeg
--->  Attempting to fetch ffmpeg-0.7.1.tar.bz2 from http://lil.fr.distfiles.macports.org/ffmpeg
--->  Verifying checksum(s) for ffmpeg
--->  Extracting ffmpeg
--->  Configuring ffmpeg
--->  Building ffmpeg
Error: Target org.macports.build returned: shell command failed (see log for details)
Log for ffmpeg is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_multimedia_ffmpeg/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

I have read various pages on your site. Those parts that I have understood have not solved my problem, so I must upload that log file and hope that you will find this pleasantly solvable.

I am very grateful to the MacPorts project and its contributors.

Attachments (8)

main.log (1.0 MB) - added by skiskywalker@… 13 years ago.
ffmpeg build log
Portfile.diff (651 bytes) - added by dbevans (David B. Evans) 13 years ago.
Preliminary path to Portfile to use gcc-4.2
main.2.log (21.7 KB) - added by skiskywalker@… 12 years ago.
Log of ffmpeg failing to build with Xcode 4.2 in Snow Leopard.
main.3.log (74.5 KB) - added by skiskywalker@… 12 years ago.
Log of installing ffmpeg using clang-3.0
main-clang31.log (2.3 MB) - added by ports@… 12 years ago.
compilation log ffmpeg 32bits clang 3.1
cabac.pp.c (94.8 KB) - added by ports@… 12 years ago.
imx_dump_header_bsf.pp.c (113.6 KB) - added by ports@… 12 years ago.
clang-ffmpeg-errlog.log (4.5 KB) - added by ports@… 12 years ago.

Change History (46)

Changed 13 years ago by skiskywalker@…

Attachment: main.log added

ffmpeg build log

comment:1 Changed 13 years ago by mf2k (Frank Schima)

Description: modified (diff)
Owner: changed from macports-tickets@… to devans@…

comment:2 Changed 13 years ago by mroman@…

I had the same problem and managed to compile successfully after applying the path: attachment:ticket:28935:ffmpeg-Portfile.0.7.1.diff

See ticket #28935

comment:3 Changed 13 years ago by umaefx@…

I have the same issue with MacPorts 2.0, Snow Leopard and i386 architecture (i have changed my default architecture manually to i386 in /opt/local/etc/macports/macports.conf) No luck with the patch provided by mroman. Any help would be seriously appreciated.

comment:4 Changed 13 years ago by jmroot (Joshua Root)

Does #30490 being fixed help with this?

comment:5 Changed 13 years ago by skiskywalker@…

Sorry I've been away for a while but I'm back! I tried the patch shortly after mroman suggested it but had some problems. First I had to tell diff to change /opt/local/var/macports/sources/rsync.macports.org/release/ports/multimedia/ffmpeg/Portfile instead of /opt/local/var/macports/sources/svn.macports.org/trunk/dports/multimedia/ffmpeg/Portfile (which I don't have) and then, after much compiling, MacPorts said:

Error: Cannot install ffmpeg for the arch(s) 'i386 x86_64' because
Error: its dependency XviD is only installed for the arch 'i386'
Error: and does not have a universal variant.
Error: Unable to execute port: architecture mismatch

Not that I need a 64-bit build right now — I was just trying the +universal variant as recommended by mroman. Anyway, today I updated my MacPorts to 2.0.1 then updated all the installed ports. Finally I ran sudo port -c install ffmpeg and received the same error message as in my first post above. I would still love to be able to use ffmpeg, though!

comment:6 in reply to:  5 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added

Replying to skiskywalker@…:

Error: Cannot install ffmpeg for the arch(s) 'i386 x86_64' because
Error: its dependency XviD is only installed for the arch 'i386'
Error: and does not have a universal variant.

I have fixed this in XviD in r82642.

The failure I now get when cross-compiling ffmpeg for i386 on an x86_64 machine is the one described in the ffmpeg FAQ, which the ffmpeg developers say is a bug in gcc which they refuse to work around, and the gcc developers say is not a bug and cannot be fixed by them. #30602 reports basically the same compilation failure with clang, lending weight to the gcc developers' argument that ffmpeg's code is the culprit. I have not yet tried the universal variant patch from #28935 suggested above.

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

There is also a patch in comment:ticket:20938:31 that purports to fix this problem, but it may need to be updated for the current version of ffmpeg.

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

The patch in #28935 worked for me so I committed it. Please test if that resolves the issue for you.

comment:9 Changed 13 years ago by rmstonecipher@…

I am getting the same build error trying to build for i386 (as part of +universal) on a core 2 duo macbook, lion, xcode 4.1:

:info:build /Developer/usr/bin/clang -I. -I"/opt/local/var/macports/build/_opt_local_var_macports_sources_svn_trunk_dports_multimedia_ffmpeg/ffmpeg/work/ffmpeg-0.7.1-i386" -I/opt/local/include -D_ISOC99_SOURCE -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 -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/opt/local/include/SDL -g -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -O3 -fno-math-errno -fno-signed-zeros -mllvm -stack-alignment=16 -Qunused-arguments  -MMD -c -o libavcodec/h264_cabac.o libavcodec/h264_cabac.c
:info:build fatal error: error in backend: Ran out of registers during register allocation!
:info:build gmake: *** [libavcodec/h264_cabac.o] Error 1

comment:10 Changed 13 years ago by rmstonecipher@…

Cc: rmstonecipher@… added

Cc Me!

comment:11 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: domiman@… andrew@… added

I am able to build ffmpeg 0.7.3 universal on Xcode 3.2.6 on Snow Leopard.

Duplicate #31151 shows others are unable to build ffmpeg 0.7.3 universal on Xcode 4.2 on Lion.

Perhaps we need to force ffmpeg to use gcc-4.2 for now instead of clang.

comment:12 Changed 13 years ago by dbevans (David B. Evans)

Status: newassigned

I was just able to build universal using gcc-4.2 as well.

Both llvm-gcc-4.2 and clang have (different) problems but gcc-4.2 seems to work OK.

A similar bug in clang/llvm has been reported here and claims to be fixed upstream but I'm guessing not in the current Apple version (2.1 as of Xcode 4.1).

See the comments in the ffmpeg Portfile for the problem with llvm-gcc-4.2.

A preliminary patch is attached to prove the point but needs to be tested on Lion and Leopard. Note that it disables parallel builds but this is just to make it easier to see where the failure is.

Changed 13 years ago by dbevans (David B. Evans)

Attachment: Portfile.diff added

Preliminary path to Portfile to use gcc-4.2

comment:13 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

The block of code that should be used to force the use of gcc-4.2 instead of either llvm-gcc-4.2 or clang is shown here:

http://lists.macosforge.org/pipermail/macports-dev/2011-July/015263.html

comment:14 Changed 13 years ago by dbevans (David B. Evans)

Resolution: fixed
Status: assignedclosed

Fix to force use of gcc-4.2 using recommended code block committed in r83625. If this doesn't work for you please open a new ticket with specific details.

comment:15 Changed 13 years ago by andrew@…

Confirmed that the fix works (I am able to build ffmpeg now).

comment:16 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

This should be fixed in currently shipping versions of XCode (I think XCode 4.2 and later work), so I'm removing this hunk.

r90901

comment:17 Changed 12 years ago by skiskywalker@…

Resolution: fixed
Status: closedreopened

I just checked my e-mail, saw this and realised why ffmpeg doesn't build any more! I have Xcode 4.2 (4C199) and I'm not aware of any newer versions for Snow Leopard. I humbly request unchanging whatever just changed.

comment:18 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

You're right, 4.2 is the last version of Xcode available for Snow Leopard. Jeremy said above he believes 4.2 and later works; if it does not work for you, please provide the log file, or error messages, or something to help us diagnose whatever's going wrong.

comment:19 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: jeremyhu@… added

Changed 12 years ago by skiskywalker@…

Attachment: main.2.log added

Log of ffmpeg failing to build with Xcode 4.2 in Snow Leopard.

comment:20 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Weird ... what is the output of:

/usr/bin/clang --version
/Developer/usr/bin/clang --version

Indeed if this is in XCode 4.2 on SL, then we certainly need to work around this in a better way. Falling back on gcc-4.2 is bad, so I'd rather use a newer clang. Can you please verify that clang-3.0 works for you:

sudo port -v install clang-3.0
sudo port -v clean ffmpeg
sudo port -v install ffmpeg configure.compiler=macports-clang-3.0

comment:21 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Summary: Cannot build ffmpeg in OS X 10.6.8 on 32-bit Macffmpeg: Cannot build in OS X 10.6.8 on 32-bit Mac

"macports-clang-3.0" is not a valid value for configure.compiler—not in MacPorts 2.0.4 anyway. (IIRC it's been added in trunk only.) So you would have to:

sudo port -v install ffmpeg configure.cc=clang-mp-3.0 configure.cxx=clang++-mp-3.0

comment:22 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Ah. Indeed, those changes are not merged from trunk into release_2_0.

comment:23 Changed 12 years ago by skiskywalker@…

Sorry to have ignored you all; my coursework is done now! How are we progressing with this ticket?

comment:24 in reply to:  23 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Replying to skiskywalker@…:

Sorry to have ignored you all; my coursework is done now! How are we progressing with this ticket?

We're still waiting on your response. Please test if clang-3.0 builds it for you.

comment:25 Changed 12 years ago by skiskywalker@…

Gosh. OK, I told MacPorts to update itself and then install clang-3.0. Both clangs report:

Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: i386-apple-darwin10.8.0
Thread model: posix

Then I ran

sudo port -v clean ffmpeg
sudo port -v install ffmpeg configure.cc=clang-mp-3.0 configure.cxx=clang++-mp-3.0

That produced quite a verbose error. I'll upload a log file.

Changed 12 years ago by skiskywalker@…

Attachment: main.3.log added

Log of installing ffmpeg using clang-3.0

comment:26 Changed 12 years ago by ports@…

ffmpeg 32bits can be compiled with gcc47. Configuration: MacPorts base 2.1.1, ffmpeg @0.7.11+mmx+universal+nonfree, OS 10.7.2

--- Portfile.orig	2012-04-11 22:30:29.000000000 +0200
+++ Portfile	2012-05-25 16:30:49.000000000 +0200
@@ -100,6 +100,11 @@
     configure.compiler clang
 }
 
+platform i386 {
+	configure.cc "gcc-mp-4.7"
+	depends_build-append port:gcc47
+}
+
 # Xcode 4.1's clang has issues with ffmpeg
 # See https://trac.macports.org/ticket/30137
 if {$xcodeversion == "4.1"} {

comment:27 in reply to:  26 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to skiskywalker@…:

Gosh. OK, I told MacPorts to update itself and then install clang-3.0.

The log you attached says:

clang-mp-3.0: command not found 

This suggests you did not actually install the clang-3.0 port. Please selfupdate to ensure you have MacPorts 2.1.1 and the latest port definitions, then clean ffmpeg, install clang-3.0, and try again to build ffmpeg with clang-3.0:

sudo port selfupdate
sudo port clean ffmpeg
sudo port install clang-3.0
sudo port install ffmpeg configure.compiler=macports-clang-3.0

Since the previous remarks in this ticket were made, the final version of clang-3.1 has been released, so if it fails with clang-3.0, you could repeat the test with clang-3.1.

Replying to ports@…:

ffmpeg 32bits can be compiled with gcc47.

We're not going to change ffmpeg to use gcc47, and even if we were, doing so conditional on "platform i386" doesn't make sense. If anything, we're simply going to revert r90901 and go back to using gcc-4.2 since that worked before.

Changed 12 years ago by ports@…

Attachment: main-clang31.log added

compilation log ffmpeg 32bits clang 3.1

comment:28 Changed 12 years ago by ports@…

Confirmed to work with gcc-apple-4.2. Doesn't work with clang-mp-3.1. You can see the attached log, but the error is:

libavcodec/x86/h264_i386.h:51:9: error: ran out of registers during register allocation

doing so conditional on "platform i386" doesn't make sense

Restricting the compiler for ffmpeg 64bits is not necessary.

Thanks!

comment:29 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Thanks for stating that it doesn't work with clang-mp-3.1 and gcc-apple-4.2, but you have still not answered the question. Does it work with clang-3.0?

comment:30 Changed 12 years ago by ports@…

Ah yes sorry, I assumed that skiskywalker tried that but I guess he didn't. Yes, it does work with clang-3.0. I've successfully compiled ffmpeg +universal+nonfree on Lion. So the solution would be to either use apple-gcc-4.2 or macports-clang-3.0 (but not 3.1). Interestingly, clang was 18% faster at building ffmpeg than gcc.

comment:31 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Ok, thanks.

What variants are you installing with? I really want to reproduce this. I have the latest ffmpeg built with XCode 4.2 (ffmpeg-0.7.11_1+mmx+universal.darwin_10.i386-x86_64.tbz2).

Can you please attach the preprocessed source for the failed compile? To do that, change the -c in the command line to a -E, change the -o option to '-o ~/Desktop/file.to.attach.cpp' , and get rid of all the -M options. As an example the above:

/Developer/usr/bin/clang -I. -I"/opt/local/var/macports/build/_opt_local_var_macports_sources_svn_trunk_dports_multimedia_ffmpeg/ffmpeg/work/ffmpeg-0.7.1-i386" -I/opt/local/include -D_ISOC99_SOURCE -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 -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/opt/local/include/SDL -g -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -O3 -fno-math-errno -fno-signed-zeros -mllvm -stack-alignment=16 -Qunused-arguments  -MMD -c -o libavcodec/h264_cabac.o libavcodec/h264_cabac.c

would become:

/Developer/usr/bin/clang -I. -I"/opt/local/var/macports/build/_opt_local_var_macports_sources_svn_trunk_dports_multimedia_ffmpeg/ffmpeg/work/ffmpeg-0.7.1-i386" -I/opt/local/include -D_ISOC99_SOURCE -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 -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/opt/local/include/SDL -g -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -O3 -fno-math-errno -fno-signed-zeros -mllvm -stack-alignment=16 -Qunused-arguments -E -o ~/Desktop/h264_cabac.pp.c libavcodec/h264_cabac.c

You would need to execute that from the appropriate directory (it looks like it's just ${worksrcpath}).

Changed 12 years ago by ports@…

Attachment: cabac.pp.c added

Changed 12 years ago by ports@…

Attachment: imx_dump_header_bsf.pp.c added

Changed 12 years ago by ports@…

Attachment: clang-ffmpeg-errlog.log added

comment:32 Changed 12 years ago by ports@…

Not sure which one of those preprocessed files you need, so I attached both. Variants are +universal +nonfree.

comment:33 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

I've reproduced it (<rdar://problem/11542429>). I will update configure.compiler checks in ffmpeg's Portfile.

comment:34 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: reopenedclosed

r93718 should take care of it.

comment:35 Changed 11 years ago by james.athey@…

Resolution: fixed
Status: closedreopened

The compiler checks have been removed from ffmpeg's Portfile for some reason, so this problem has returned. With the latest XCode (4.5.2) installed on Lion (10.7.5), ffmpeg still will not build for i386 using clang. I had to use

port install ffmpeg +nonfree +universal configure.compiler=apple-gcc-4.2

to get it to build for +universal.

Version 0, edited 11 years ago by james.athey@… (next)

comment:36 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

comment:37 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: reopenedclosed

Actually, r101797

comment:38 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

Note: See TracTickets for help on using tickets.