Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 273421 - [PATCH] media-video/ffmpeg does not enable correct optimizations with -march=native
Summary: [PATCH] media-video/ffmpeg does not enable correct optimizations with -march=...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-09 19:35 UTC by Fabian Henze
Modified: 2009-09-06 09:33 UTC (History)
4 users (show)

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


Attachments
repost the patch, sry for the mess in the description (ffmpeg-ebuild-march-native.patch,749 bytes, patch)
2009-06-09 19:36 UTC, Fabian Henze
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Henze 2009-06-09 19:35:10 UTC
Hi, I noticed that the CPU detection in the ffmpeg ebuild fails if march is set to "native". It's configure script will print
  WARNING: Unknown CPU "native", ignored.
and switch to march=generic. I hacked a patch that works for me, but I am not much of a bash ninja and I am sure there is a cleaner approach. Anyway, you get the idea ;-)


--- a/media-video/ffmpeg/ffmpeg-0.5-r1.ebuild	2009-05-21 21:06:31.000000000 +0200
+++ b/media-video/ffmpeg/ffmpeg-0.5-r1.ebuild	2009-06-09 21:12:06.000000000 +0200
@@ -137,8 +137,13 @@ src_compile() {
 	# If they contain an unknown CPU it will not hurt since ffmpeg's configure
 	# will just ignore it.
 	for i in $(get-flag march) $(get-flag mcpu) $(get-flag mtune) ; do
-		myconf="${myconf} --cpu=$i"
-		break
+		if [[ "$i" == "native" ]]; then
+			i=`echo "int main() {return 0;}" | gcc ${CFLAGS} -x c -S -Q -v - 2>&1 | egrep -m 1 -o "\-march=.*" | cut -f 1 -d \ | cut -f 2 -d \=`
+		fi
+		if [[ "$i" != "" ]]; then
+			myconf="${myconf} --cpu=$i"
+			break
+		fi
 	done
 
 	# video hooking support. replaced by libavfilter, probably needs to be

Reproducible: Always
Comment 1 Fabian Henze 2009-06-09 19:36:38 UTC
Created attachment 194031 [details, diff]
repost the patch, sry for the mess in the description
Comment 2 Roman v. Gemmeren 2009-08-15 17:14:07 UTC
hi,

here it still fails with:
WARNING: Unknown CPU "k8-sse3", ignored.

i guess there is a space missing somewhere...

Comment 3 Roman v. Gemmeren 2009-08-16 07:32:32 UTC
sry, the patch is correct, but ffmpeg just doesn't know k8-sse3, probably it should be identified as k8 only...

Comment 4 emil karlson 2009-08-27 22:37:14 UTC
http://git.ffmpeg.org/?p=ffmpeg;a=commit;h=9025b25ce04900fa5a9d14871547ff80dab1996c

So when the time is right just add $i -> ${i/native/host}

kthxbye ;o)
Comment 5 Alexis Ballier gentoo-dev 2009-09-06 09:33:57 UTC
(In reply to comment #4)
> http://git.ffmpeg.org/?p=ffmpeg;a=commit;h=9025b25ce04900fa5a9d14871547ff80dab1996c
> 
> So when the time is right just add $i -> ${i/native/host}

added such a thing in -9999; closing as fixed. We'll probably make a new snapshot soon.