Bug 180564 - multimedia/mplayer compilation error with Clang (running out of registers)
Summary: multimedia/mplayer compilation error with Clang (running out of registers)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-15 03:00 UTC by dt71
Modified: 2013-10-18 08:50 UTC (History)
0 users

See Also:


Attachments
mplayer.patch (526 bytes, patch)
2013-07-15 03:10 UTC, dt71
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dt71 2013-07-15 03:00:00 UTC
libavcodec/x86/ac3dsp_init.c:149:9: error: ran out of registers during register allocation
        MIX5(IF0, IF1);
        ^
libavcodec/x86/ac3dsp_init.c:66:9: note: expanded from macro 'MIX5'
        "movss           0(%1), %%xmm5          \n"             \
        ^
libavcodec/x86/ac3dsp_init.c:153:9: error: ran out of registers during register
      allocation
        MIX5(IF1, IF0);
        ^
libavcodec/x86/ac3dsp_init.c:66:9: note: expanded from macro 'MIX5'
        "movss           0(%1), %%xmm5          \n"             \
        ^

How-To-Repeat: Try to compile MPlayer with a recent version of Clang (eg., r186084).
Comment 1 dt71 2013-07-15 03:10:14 UTC
Based on a discussion on #llvm at irc.oftc.net:
- The assembly core of Clang is inherently different from that of GCC. One would have to fully reimplement the GCC assembly core to yield matching behaviors in all cases. This is obviously not going to happen.
- The -fomit-frame-pointer option would free up 1 needed register.
- Someone said that the inline assembly version of the code should be just dropped, because the C version is faster.

The attached patch simply cancels the attempted use of 7 registers if the compiler is Clang.
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2013-07-16 10:24:07 UTC
Responsible Changed
From-To: freebsd-ports-bugs->miwi

miwi@ wants this submitter's PRs (via the GNATS Auto Assign Tool)
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2013-07-16 10:24:08 UTC
Maintainer of multimedia/mplayer,

Please note that PR ports/180564 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/180564

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 4 Edwin Groothuis freebsd_committer freebsd_triage 2013-07-16 10:24:09 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 5 Martin Wilke freebsd_committer freebsd_triage 2013-07-17 05:11:11 UTC
Responsible Changed
From-To: miwi->freebsd-ports-bugs

back to pool
Comment 6 Thomas Zander 2013-07-31 19:50:51 UTC
If I am not mistaken, this problem only occurs on i386 if you are
forcing clang on it. (The port does not declare clang support on i386
as of now.) It's therefore not terribly urgent, right?
If you concur, I would include the patch for the clang build problem
bundled with a bigger patch in a couple of weeks.

Best regards
Riggs
Comment 7 dt71 2013-08-09 20:30:25 UTC
Thomas Zander wrote:
> this problem only occurs on i386 if you are forcing clang on it.

I am not "forcing" Clang. I have 2 compilers installed: Clang (at some fancy, non-base path) and GCC 4.6 (from the ports). The CC environment variable is set to /path/to/clang (CXX and CPP are set appropriately), but the MPlayer port would be free to use GCC 4.6.
Comment 8 Thomas Zander 2013-09-08 05:25:51 UTC
Okay, approved. Can be committed.
Thank you and best regards
Riggs
Comment 9 Mark Linimon freebsd_committer freebsd_triage 2013-09-08 05:39:27 UTC
State Changed
From-To: feedback->open

Maintainer approved.
Comment 10 dfilter service freebsd_committer freebsd_triage 2013-10-18 08:45:57 UTC
Author: tijl
Date: Fri Oct 18 07:45:48 2013
New Revision: 330729
URL: http://svnweb.freebsd.org/changeset/ports/330729

Log:
  Fix build on i386 with clang.
  
  Some inline asm requires 7 registers but only 6 are available because
  clang assumes the stack is 4-byte aligned and there's a local variable
  that requires 16-byte alignment so the stack has to be realigned which
  requires one register to be used as frame pointer.
  
  PR:		ports/180564
  Submitted by:	dt71@gmx.com
  Approved by:	Thomas Zander <thomas.e.zander@googlemail.com> (maintainer)

Added:
  head/multimedia/mplayer/files/patch-libavcodec-x86-ac3dsp_init.c   (contents, props changed)
Modified:
  head/multimedia/mplayer/Makefile.options

Modified: head/multimedia/mplayer/Makefile.options
==============================================================================
--- head/multimedia/mplayer/Makefile.options	Fri Oct 18 07:44:30 2013	(r330728)
+++ head/multimedia/mplayer/Makefile.options	Fri Oct 18 07:45:48 2013	(r330729)
@@ -50,7 +50,7 @@ CFLAGS+=	-O -fomit-frame-pointer
 .endif #DEBUG
 
 #Supported architectures for clang
-.if ${ARCH} == "amd64"
+.if ${ARCH} == "amd64" || ${ARCH} == "i386"
 MPLAYER_CLANG_SUPPORTED_ARCH=	yes
 .endif
 

Added: head/multimedia/mplayer/files/patch-libavcodec-x86-ac3dsp_init.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/multimedia/mplayer/files/patch-libavcodec-x86-ac3dsp_init.c	Fri Oct 18 07:45:48 2013	(r330729)
@@ -0,0 +1,11 @@
+--- ffmpeg/libavcodec/x86/ac3dsp_init.c	2013-07-03 21:34:20.000000000 +0200
++++ ffmpeg/libavcodec/x86/ac3dsp_init.c	2013-07-03 21:34:45.000000000 +0200
+@@ -51,7 +51,7 @@
+ extern void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
+ extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
+ 
+-#if ARCH_X86_32 && defined(__INTEL_COMPILER)
++#if ARCH_X86_32 && (defined(__INTEL_COMPILER) || defined(__clang__))
+ #       undef HAVE_7REGS
+ #       define HAVE_7REGS 0
+ #endif
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 11 Tijl Coosemans freebsd_committer freebsd_triage 2013-10-18 08:46:52 UTC
State Changed
From-To: open->closed

Committed in r330729. 


Comment 12 Tijl Coosemans freebsd_committer freebsd_triage 2013-10-18 08:46:52 UTC
Responsible Changed
From-To: freebsd-ports-bugs->tijl

Committed in r330729.