Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 538322 - Please add USE_EXPAND_HIDDEN="-CPU_FLAGS_X86" to {amd64-fbsd,x86-fbsd} profiles.
Summary: Please add USE_EXPAND_HIDDEN="-CPU_FLAGS_X86" to {amd64-fbsd,x86-fbsd} profiles.
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-31 09:44 UTC by Yuta SATOH
Modified: 2015-02-02 15:47 UTC (History)
1 user (show)

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


Attachments
sample patch for fbsd profiles (538322.patch,1.21 KB, patch)
2015-01-31 09:47 UTC, Yuta SATOH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta SATOH 2015-01-31 09:44:42 UTC
Please add USE_EXPAND_HIDDEN="-CPU_FLAGS_X86" to fbsd profiles in order to enable the USE flag, such as mmx and sse...


Reproducible: Always

Actual Results:  
# emerge -pv --nodeps media-video/ffmpeg
[ebuild     U *] media-video/ffmpeg-2.2.12:0/52.55.55 [2.2.2:0/52.55.55] USE="X aac aacplus bzip2 cpudetection encode faac fontconfig gnutls hardcoded-tables iconv jpeg2k mp3 network opengl oss rtmp sdl theora threads truetype twolame vorbis vpx x264 xvid zlib (-alsa) (-altivec) -amr -amrenc (-armv5te) (-armv6) (-armv6t2) (-armvfp) -bindist -bluray -cdio -celt -debug -doc -examples -fdk (-flite) -frei0r -gme -gsm (-iec61883) (-ieee1394) -jack -ladspa -libass -libcaca -libsoxr (-libv4l) (-mips32r2) (-mipsdspr1) (-mipsdspr2) (-mipsfpu) -modplug (-neon) -openal -openssl -opus -pic (-pulseaudio) -quvi -schroedinger -speex -ssh -static-libs {-test} (-v4l) (-vaapi) (-vdpau) -wavpack -webp -x265 -zvbi (-3dnow%) (-3dnowext%) (-avx%) (-avx2%) (-fma3%) (-fma4%) (-mmx%*) (-mmxext%*) (-sse%*) (-sse2%*) (-sse3%) (-sse4%) (-sse4_2%) (-ssse3%*)" ABI_X86="(64%*) -32% (-x32)" FFTOOLS="aviocat cws2fws ffescape ffeval ffhash fourcc2pixfmt graph2dot ismindex pktdumper qt-faststart trasher" 6868 KiB


Expected Results:  
# emerge -pv --nodeps media-video/ffmpeg
[ebuild     U *] media-video/ffmpeg-2.2.12:0/52.55.55 [2.2.2:0/52.55.55] USE="X aac aacplus bzip2 cpudetection encode faac fontconfig gnutls hardcoded-tables iconv jpeg2k mp3 network opengl oss rtmp sdl theora threads truetype twolame vorbis vpx x264 xvid zlib (-alsa) (-altivec) -amr -amrenc (-armv5te) (-armv6) (-armv6t2) (-armvfp) -bindist -bluray -cdio -celt -debug -doc -examples -fdk (-flite) -frei0r -gme -gsm (-iec61883) (-ieee1394) -jack -ladspa -libass -libcaca -libsoxr (-libv4l) (-mips32r2) (-mipsdspr1) (-mipsdspr2) (-mipsfpu) -modplug (-neon) -openal -openssl -opus -pic (-pulseaudio) -quvi -schroedinger -speex -ssh -static-libs {-test} (-v4l) (-vaapi) (-vdpau) -wavpack -webp -x265 -zvbi (-3dnow%) (-3dnowext%) (-avx%) (-avx2%) (-fma3%) (-fma4%) (-mmx%*) (-mmxext%*) (-sse%*) (-sse2%*) (-sse3%) (-sse4%) (-sse4_2%) (-ssse3%*)" ABI_X86="(64%*) -32% (-x32)" CPU_FLAGS_X86="mmx%* sse%* sse2%* -3dnow% -3dnowext% -avx% -avx2% -fma3% -fma4% -mmxext% -sse3% -sse4_1% -sse4_2% -ssse3%" FFTOOLS="aviocat cws2fws ffescape ffeval ffhash fourcc2pixfmt graph2dot ismindex pktdumper qt-faststart trasher" 6868 KiB
Comment 1 Yuta SATOH 2015-01-31 09:47:34 UTC
Created attachment 395248 [details, diff]
sample patch for fbsd profiles
Comment 2 Yuta SATOH 2015-01-31 09:50:26 UTC
If you want to display the news on FreeBSD, please add the following content to news/2015-01-28-cpu_flags_x86-introduction/2015-01-28-cpu_flags_x86-introduction.en.txt.

Display-If-Keyword: amd64-fbsd
Display-If-Keyword: ~amd64-fbsd
Display-If-Keyword: x86-fbsd
Display-If-Keyword: ~x86-fbsd

NOTE,
/proc/cpuinfo does not exist on FreeBSD.
User will need to manually set CPU_FLAGS_X86.

You will be able to get the information of CPU with the following command.

# dmesg | grep Features
  Features=0x1fa3fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,DTS,MMX,FXSR,SSE,SSE2,SS,HTT>
  Features2=0xfefa3223<SSE3,PCLMULQDQ,VMX,SSSE3,FMA,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND,HV>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  Structured Extended Features=0x200<ERMS>
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-01-31 10:15:36 UTC
(In reply to Yuta SATOH from comment #2)
> If you want to display the news on FreeBSD, please add the following content
> to
> news/2015-01-28-cpu_flags_x86-introduction/2015-01-28-cpu_flags_x86-
> introduction.en.txt.
> 
> Display-If-Keyword: amd64-fbsd
> Display-If-Keyword: ~amd64-fbsd
> Display-If-Keyword: x86-fbsd
> Display-If-Keyword: ~x86-fbsd

You decide, I don't mind either way. I guess Gentoo/BSD users aren't used to getting dedicated news items :).

> NOTE,
> /proc/cpuinfo does not exist on FreeBSD.
> User will need to manually set CPU_FLAGS_X86.
> 
> You will be able to get the information of CPU with the following command.
> 
> # dmesg | grep Features
>  
> Features=0x1fa3fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
> CMOV,PAT,PSE36,DTS,MMX,FXSR,SSE,SSE2,SS,HTT>
>  
> Features2=0xfefa3223<SSE3,PCLMULQDQ,VMX,SSSE3,FMA,CX16,PCID,SSE4.1,SSE4.2,
> x2APIC,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND,HV>
>   AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
>   AMD Features2=0x1<LAHF>
>   Structured Extended Features=0x200<ERMS>

No non-dmesg|grep source for that kind of intel? Do you want to update cpuinfo2cpuflags to handle BSD case somehow?
Comment 4 Yuta SATOH 2015-02-01 13:15:52 UTC
(In reply to Michał Górny from comment #3)
> (In reply to Yuta SATOH from comment #2)
> > If you want to display the news on FreeBSD, please add the following content
> > to
> > news/2015-01-28-cpu_flags_x86-introduction/2015-01-28-cpu_flags_x86-
> > introduction.en.txt.
> > 
> > Display-If-Keyword: amd64-fbsd
> > Display-If-Keyword: ~amd64-fbsd
> > Display-If-Keyword: x86-fbsd
> > Display-If-Keyword: ~x86-fbsd
> 
> You decide, I don't mind either way. I guess Gentoo/BSD users aren't used to
> getting dedicated news items :).

In my personal opinion, does not require a news for G/FBSD.
Gentoo/FreeBSD have very little users.

> > NOTE,
> > /proc/cpuinfo does not exist on FreeBSD.
> > User will need to manually set CPU_FLAGS_X86.
> > 
> > You will be able to get the information of CPU with the following command.
> > 
> > # dmesg | grep Features
> >  
> > Features=0x1fa3fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
> > CMOV,PAT,PSE36,DTS,MMX,FXSR,SSE,SSE2,SS,HTT>
> >  
> > Features2=0xfefa3223<SSE3,PCLMULQDQ,VMX,SSSE3,FMA,CX16,PCID,SSE4.1,SSE4.2,
> > x2APIC,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND,HV>
> >   AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
> >   AMD Features2=0x1<LAHF>
> >   Structured Extended Features=0x200<ERMS>
> 
> No non-dmesg|grep source for that kind of intel? Do you want to update
> cpuinfo2cpuflags to handle BSD case somehow?

dmesg is the only way to get CPU flag on FreeBSD.

I don't think the code additions to cpuinfo2cpuflags.
I think it is no problem with manual setting.

If you can change the profile, please apply attachment 395248 [details, diff].
Thanks in advance.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-02-01 13:42:12 UTC
Sure, committed now. Sorry that I forgot about them when committing the initial hide/unhide block :). Please let me know if there's anything else that needs fixing.

As an extra advert, please consider using our git mirror [1] for syncing, development & submitting pull requests :).

[1]:https://github.com/gentoo/gentoo-portage-rsync-mirror
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-02-01 20:19:10 UTC
Oh. As for FreeBSD, maybe it'd be possible to run CPUID instruction and parse the output manually? I'd need to see if it's possible to do assembly in Python.
Comment 7 Yuta SATOH 2015-02-02 11:11:35 UTC
(In reply to Michał Górny from comment #6)
> Oh. As for FreeBSD, maybe it'd be possible to run CPUID instruction and
> parse the output manually? I'd need to see if it's possible to do assembly
> in Python.

If possible to maintenance, I think very good approach to get CPUID.
Gentoo works on multiple platforms (linux, *bsd, macos, solaris...).
It will work on platforms non Linux.


FYI,
PyCPUID works fine on FreeBSD.

https://github.com/FlightDataServices/PyCPUID

# python2 /usr/lib/python2.7/site-packages/pycpuid/pycpuid.py
Vendor: GenuineIntel
Stepping ID: 3
Model: 0x3c
Family: 6
Processor Type: 0
Brand ID: 0x0
Brand String: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Features: ['FPU', 'VME', 'DE', 'PSE', 'TSC', 'MSR', 'PAE', 'MCE', 'CX8', 'APIC', 'SEP', 'MTRR', 'PGE', 'MCA', 'CMOV', 'PAT', 'PSE36', 'CLFLSH', 'DS', 'MMX', 'FXSR', 'SSE', 'SSE2', 'SS', 'HTT', 'SSE3', 'PCLMULDQ', 'VMX', 'SSE3', 'CX16', 'SSE4_1', 'SSE4_2', 'X2APIC', 'MOVBE', 'POPCNT', 'AES', 'XSAVE', 'OSXSAVE']



workhorsy/py-cpuinfo and flababah/cpuid.py does not work on FreeBSD.

https://github.com/workhorsy/py-cpuinfo
https://github.com/flababah/cpuid.py

* workhorsy/py-cpuinfo

Source code change)
# diff cpuinfo.py.orig cpuinfo.py
1218c1218
<       info = get_cpu_info()
---
>       info = get_cpu_info_from_cpuid()

# python3 cpuinfo.py
Segmentation fault (core dumped)


* flababah/cpuid.py

Source code change)
# diff cpuid.py.orig cpuid.py
71c71
<         if platform.machine() not in ("AMD64", "x86_64", "x86", "i686"):
---
>         if platform.machine() not in ("AMD64", "amd64", "x86_64", "x86", "i686"):

# python2 cpuid.py
CPUID    A        B        C        D
Segmentation fault (core dumped)

# gdb python2
GNU gdb (Gentoo 7.6.1 p2) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-gentoo-freebsd10.0".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /usr/bin/python2.7...(no debugging symbols found)...done.
(gdb) run cpuid.py
Starting program: /usr/bin/python2 cpuid.py
CPUID    A        B        C        D

Program received signal SIGSEGV, Segmentation fault.
0x00000008013c7e86 in memmove () from /lib/libc.so.7
(gdb) bt
#0  0x00000008013c7e86 in memmove () from /lib/libc.so.7
#1  0x00000008024314fc in ffi_call_unix64 () from /usr/lib/libffi.so.6
#2  0x0000000802431002 in ffi_call () from /usr/lib/libffi.so.6
#3  0x000000080221b26a in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#4  0x000000080221bc76 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#5  0x0000000802215f55 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#6  0x0000000800868c49 in PyObject_Call () from /usr/lib/libpython2.7.so.1
#7  0x000000080093acea in ?? () from /usr/lib/libpython2.7.so.1
#8  0x000000080093a3eb in ?? () from /usr/lib/libpython2.7.so.1
#9  0x00000008009369c1 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1
#10 0x000000080093844b in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1
#11 0x000000080089c30b in ?? () from /usr/lib/libpython2.7.so.1
#12 0x0000000800868c49 in PyObject_Call () from /usr/lib/libpython2.7.so.1
#13 0x000000080087dce6 in ?? () from /usr/lib/libpython2.7.so.1
#14 0x0000000800868c49 in PyObject_Call () from /usr/lib/libpython2.7.so.1
#15 0x00000008008e83e4 in ?? () from /usr/lib/libpython2.7.so.1
#16 0x00000008008d8d65 in ?? () from /usr/lib/libpython2.7.so.1
#17 0x0000000800868c49 in PyObject_Call () from /usr/lib/libpython2.7.so.1
#18 0x000000080093acea in ?? () from /usr/lib/libpython2.7.so.1
#19 0x000000080093a3eb in ?? () from /usr/lib/libpython2.7.so.1
#20 0x00000008009369c1 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1
#21 0x000000080088c6de in ?? () from /usr/lib/libpython2.7.so.1
#22 0x000000080088cd91 in ?? () from /usr/lib/libpython2.7.so.1
#23 0x0000000800936461 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1
#24 0x000000080093844b in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1
#25 0x000000080093285b in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1
#26 0x0000000800964e72 in ?? () from /usr/lib/libpython2.7.so.1
#27 0x0000000800964dfb in PyRun_FileExFlags () from /usr/lib/libpython2.7.so.1
#28 0x0000000800963a9e in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.7.so.1
#29 0x00000008009632fb in PyRun_AnyFileExFlags () from /usr/lib/libpython2.7.so.1
#30 0x000000080097bdbb in Py_Main () from /usr/lib/libpython2.7.so.1
#31 0x0000000000400a93 in main ()
(gdb) q
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-02-02 15:47:29 UTC
Yeah, that looks like a neat option. However, I have a few doubts...

Right now, we do implicit cpuinfo -> flag mapping via special values in cpu_flags_x86.desc. Which is a good thing since we don't have to update the script for new instruction sets, just rely on the kernel providing names for the appropriate bits.

If we switch to this, we either decide on hardcoding the flag names or doing mapping from the 'new' names to flags. If we do the latter, we still rely on pycpuinfo providing up-to-date information. But sadly, while /proc/cpuinfo names can be helpful to most of Gentoo users, names specific to pycpuinfo won't be).

If we want to avoid relying on any external piece of software being updated frequently, we may put appropriate bit numbers in the file. However, that sounds like putting machine-intended data where it doesn't really belong. So maybe put it somewhere else instead? For example, some of my Portage-related packages are relying on data files kept within their files/ subdirectory.