Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 577078 - media-video/ffmpeg-2.8.5 ebuild sets --cpu based on -mtune resulting in possibly illegal instructions
Summary: media-video/ffmpeg-2.8.5 ebuild sets --cpu based on -mtune resulting in possi...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-11 18:00 UTC by gentoobugs
Modified: 2016-03-11 20:09 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for existing ebuild (ffmpeg-2.8.5.ebuild.patch,523 bytes, patch)
2016-03-11 18:00 UTC, gentoobugs
Details | Diff
Truncated emerge output showing error (ffmpeg-emerge-configerrorshown.txt,2.92 KB, text/plain)
2016-03-11 18:02 UTC, gentoobugs
Details
Failure running ffmpeg built with the current ebuild (ffmpeg-run-failure.txt,2.55 KB, text/plain)
2016-03-11 18:05 UTC, gentoobugs
Details
Successfully running ffmpeg build with the patched ebuild (ffmpeg-run-patchedebuild-success.txt,4.24 KB, text/plain)
2016-03-11 18:07 UTC, gentoobugs
Details
proposed ffmpeg-2.8.5-r1.ebuild (ffmpeg-2.8.5-r1.ebuild,14.32 KB, text/plain)
2016-03-11 18:28 UTC, gentoobugs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gentoobugs 2016-03-11 18:00:26 UTC
Created attachment 427982 [details, diff]
patch for existing ebuild

The media-video/ffmpeg-2.8.5 ebuild sets the --cpu configure flags based on the -mtune CFLAG.

This bug appears to have been introduced in response to bug 172723

The -mtune CFLAG means optimize for the given CPU, but don't generate code the will only run on that CPU.  The --cpu configure flag means generate code that is optimized for that CPU ignoring backward compatibility.  This means that in some situations, ffmpeg will be compiled with code that does not run on all the CPUs that generic code compiled with the user's provided CFLAGS or CXXFLAGS would run on.

Specifically, if the user had set -mtune in the CFLAGS or CXXFLAGS without specifying -march or -mcpu then this bug is triggered.

A patch to the ebuild which corrects the problem is attached.  This bug is likely present in other ffmpeg ebuilds as well.

To reproduce, set -mtune without setting -mcpu or -march. See the truncated sample build output attached.  Note that --cpu=core-avx-i is added to the end of the configure options in the example.
Comment 1 gentoobugs 2016-03-11 18:02:15 UTC
Created attachment 427984 [details]
Truncated emerge output showing error

This is the beginning of an emerge run with the current ebuild which shows the error.
Comment 2 gentoobugs 2016-03-11 18:05:03 UTC
Created attachment 427986 [details]
Failure running ffmpeg built with the current ebuild

Attempt to run ffmpeg on a CPU that does not have all the instructions provided by the CPU specified in the -mtune CPU flag. (in this case, qemu64 virtual CPU vs. core-avx-i)
Comment 3 gentoobugs 2016-03-11 18:07:00 UTC
Created attachment 427988 [details]
Successfully running ffmpeg build with the patched ebuild

This shows a successful run of ffmpeg build with the patched ebuild.  The output shows the configure options used at compile time.
Comment 4 gentoobugs 2016-03-11 18:28:52 UTC
Created attachment 427990 [details]
proposed ffmpeg-2.8.5-r1.ebuild

proposed ffmpeg-2.8.5-r1.ebuild
Comment 5 Alexis Ballier gentoo-dev 2016-03-11 20:09:51 UTC
commit 0ad2a95a4188fd99800f9a6a1b73a37c55b70ade
Author: Alexis Ballier <aballier@gentoo.org>
Date:   Fri Mar 11 21:09:00 2016 +0100

    media-video/ffmpeg: Do not infer --cpu option from mtune CFLAG.
    
    mtune is meant for optimizing code but not generating specific instructions. ffmpeg --cpu option is for generating specific instuctions.
    Bug #577078 by gentoobugs@mysteryvortex.com.
    


thx