media-libs/x265-2.2 forces compilation for Power8 instruction set instead of PowerPC 970. Then, invalid instruction is generated and every executable using the x265 library does crash with an "invalid instruction" exception. This, as an example, prevents media-video/vlc to build with x265 USE flag set, as vlc-cache-gen uses libx265. When trying to disable Power8 instruction set, editing cmake caches by hand to force using -cpu=970, the x265 package does not build. Trying to disable altivec (adding -mno-altivec to CFLAGS and CXXFLAGS) does not help. Reproducible: Always Steps to Reproduce: 1.# emerge --verbose =media-libs/x265-2.2 2.# gdb x265 3.r Starting program: /usr/bin/x265 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Program received signal SIGILL, Illegal instruction. 0x00003fffb7bff488 in ?? () from /usr/lib64/libx265.so.102 (gdb) x/i 0x00003fffb7bff488 => 0x3fffb7bff488: stxvw4x vs32,0,r9 Actual Results: x265 crashes with illegal instruction exception Expected Results: x265 compilation should respect CFLAGS / CXXFLAGS, not adding -mcpu=power8 to the build command line then compile a runable library on 970 (aka G5) CPU. # emerge --info media-libs/x265 Portage 2.3.3 (python 3.4.5-final-0, default/linux/powerpc/ppc64/13.0/64bit-userland, gcc-4.9.4, glibc-2.23-r3, 4.7.0-rc5-g3992a27-dirty ppc64) ================================================================= System Settings ================================================================= System uname: Linux-4.7.0-rc5-g3992a27-dirty-ppc64-PPC970FX,_altivec_supported-with-gentoo-2.3 KiB Mem: 2005244 total, 398700 free KiB Swap: 16777212 total, 16769540 free Timestamp of repository gentoo: Sun, 05 Mar 2017 09:00:01 +0000 sh bash 4.3_p48-r1 ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1 app-shells/bash: 4.3_p48-r1::gentoo dev-lang/perl: 5.22.3_rc4::gentoo dev-lang/python: 2.7.12::gentoo, 3.4.5::gentoo dev-util/cmake: 3.7.2::gentoo dev-util/pkgconfig: 0.28-r2::gentoo sys-apps/baselayout: 2.3::gentoo sys-apps/openrc: 0.23.2::gentoo sys-apps/sandbox: 2.10-r3::gentoo sys-devel/autoconf: 2.13::gentoo, 2.69::gentoo sys-devel/automake: 1.4_p6-r2::gentoo, 1.5-r2::gentoo, 1.6.3-r2::gentoo, 1.7.9-r3::gentoo, 1.8.5-r5::gentoo, 1.9.6-r4::gentoo, 1.11.6-r1::gentoo, 1.14.1::gentoo, 1.15::gentoo sys-devel/binutils: 2.25.1-r1::gentoo sys-devel/gcc: 4.9.3::gentoo, 4.9.4::gentoo sys-devel/gcc-config: 1.7.3::gentoo sys-devel/libtool: 2.4.6-r3::gentoo sys-devel/make: 4.2.1::gentoo sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers) sys-libs/glibc: 2.23-r3::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 x-portage location: /usr/local/portage masters: gentoo priority: 0 ACCEPT_KEYWORDS="ppc64" ACCEPT_LICENSE="* -@EULA" CBUILD="powerpc64-unknown-linux-gnu" CFLAGS="-mcpu=970 -O2 -mmultiple -mstring -maltivec -mabi=altivec -pipe" CHOST="powerpc64-unknown-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.6/ext-active/ /etc/php/cgi-php5.6/ext-active/ /etc/php/cli-php5.6/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-mcpu=970 -O2 -mmultiple -mstring -maltivec -mabi=altivec -pipe" DISTDIR="/usr/portage/distfiles" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs buildsyspkg config-protect-if-modified ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersync" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://gentoo.modulix.net/gentoo/ http://mirror.netcologne.de/gentoo/ http://gentoo.mirrors.ovh.net/gentoo-distfiles/ http://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ http://mirror.leaseweb.com/gentoo/ http://mirror.bytemark.co.uk/gentoo/ http://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo/ http://ftp.snt.utwente.nl/pub/os/linux/gentoo http://tux.rainside.sk/gentoo/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j 1" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" USE="X Xaw3d a52 aac aalib acl adns aim alsa altivec ao apache2 apm audiofile avahi bash-completion bcmath berkdb bidi blas bluetooth branding bzip2 cairo calendar caps cdb cdda cddb cdparanoia cdr cgi cli cracklib crypt cscope ctype cups curl curlwrappers cvs cxx dbus dga djvu dri dts dv dvd dvdr eds emacs encode enscript evo exif expat fam fastcgi fbcon ffmpeg fftw filecaps flac fltk fontconfig fortran ftp gd gdbm geoip ggi gif gimp git glut gmp gnuplot gnutls gphoto2 gpm gps graphviz gsl gsm gstreamer gtk guile gzip iconv icq icu idn ieee1394 imagemagick imap imlib inotify introspection ipv6 jack javascript jingle jit jpeg jpeg2k ladspa lame lash latex lcms ldap libass libcaca libffi libnotify libsamplerate libwww lua lzma lzo m17n-lib mad maildir matroska mbox memlimit mhash mikmod mime mmap mms mng modplug modules motif mozilla mp3 mp4 mpeg mpi mplayer msn mtp musepack musicbrainz nas ncurses nls nntp nptl nsplugin ocaml odbc offensive ofx ogg openal openexr opengl osc oscar oss pam pcntl pcre pdf perl pie plotutils png policikit portaudio posix postgres postscript ppc64 ppds pulseaudio python quicktime raw rdesktop readline rss ruby samba sasl savedconfig sdl shorten simplexml skey slang slp smp sndfile snmp soap sockets sound sox speex spell ssl startup-notification static-libs subversion svg syslog sysvipc szip taglib tcl tcpd theora threads tidy tiff timidity tk truetype udev unicode upnp upnp-av upower usb v4l vcd vhosts vnc vorbis wavpack wddx wifi wmf wxwidgets x264 xattr xcb xcomposite xface xft xine xinerama xinetd xml xmlrpc xmp xmpp xosd xpm xscreensaver xv xvid yahoo yaz zeroconf zlib" ABI_PPC="64" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2 canon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev keyboard linuxinput mouse void" KERNEL="linux" L10N="en fr" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en fr" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21" USERLAND="GNU" VIDEO_CARDS="dummy fbdev nouveau nv v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON ================================================================= Package Settings ================================================================= media-libs/x265-2.2::gentoo was built with the following: USE="10bit 12bit (-neon) -numa -pic -test" CFLAGS="-mcpu=970 -O2 -mmultiple -mstring -maltivec -mabi=altivec -pipe -fPIC" CXXFLAGS="-mcpu=970 -O2 -mmultiple -mstring -maltivec -mabi=altivec -pipe -fPIC" # emerge -pqv =media-libs/x265-2.2 [ebuild R ] media-libs/x265-2.2 USE="10bit 12bit (-neon) -numa -pic {-test}
Created attachment 466164 [details] media-libs/x265-2.2 build log in this build log one can see that -mcpu=power8 is added to the compilation options, which is incorrect when building for other CPUs.
does it build if you remove that flag ? I've tried to build it without it (without any -mcpu switch actually) and it fails horribly on altivec primitives
Created attachment 466780 [details] build log with empty CFLAGS / CXXFLAGS Here's the build log when using empty CFLAGS / CXXFLAGS: output of: CFLAGS="" CXXFLAGS="" ebuild /usr/portage/media-libs/x265/x265-2.2.ebuild compile I still got the same bug: -DX265_ARCH_POWER8=1 ... -mcpu=power8 visible on compilation commad lines and the same result.
(In reply to Jocelyn Mayer from comment #3) > Created attachment 466780 [details] > build log with empty CFLAGS / CXXFLAGS > > Here's the build log when using empty CFLAGS / CXXFLAGS: output of: > CFLAGS="" CXXFLAGS="" ebuild /usr/portage/media-libs/x265/x265-2.2.ebuild > compile > > I still got the same bug: -DX265_ARCH_POWER8=1 ... -mcpu=power8 visible on > compilation commad lines and the same result. yes, but I tried to patch it and it failed horribly after that. it seems power8 is required for altivec.
Created attachment 466796 [details] build log with empty CFLAGS / CXXFLAGS and edited CMakeCache.txt build log with empty CFLAGS / CXXFLAGS and edited CMakeCache.txt I also tried to edit CMakeCache.txt to turn CPU_POWER8:BOOL=ON into CPU_POWER8:BOOL=OFF after configuration phase. In such a case, compilation fails, as seen in this build log.
(In reply to Jocelyn Mayer from comment #5) > Created attachment 466796 [details] > build log with empty CFLAGS / CXXFLAGS and edited CMakeCache.txt > > build log with empty CFLAGS / CXXFLAGS and edited CMakeCache.txt > I also tried to edit CMakeCache.txt to turn CPU_POWER8:BOOL=ON into > CPU_POWER8:BOOL=OFF after configuration phase. > In such a case, compilation fails, as seen in this build log. yeah that's what I had too; mcpu=power8 or more is required for their altivec asm
btw, does it work any better if you pass -DCPU_POWER8=OFF to cmake ?
Created attachment 466798 [details] build log with edited CMakeCache.txt to disable POWER8 and ALTIVEC support This time, I edited CMakeCache.txt to turn CPU_POWER8:BOOL=ON to CPU_POWER8:BOOL=OFF and ENABLE_ALTIVEC:BOOL=ON to ENABLE_ALTIVEC:BOOL=OFF This way, I am able to compile and run x265 on the PowerPC G5 machine. Then, we should find a way to disable CPU_POWER8 and ALTIVEC in order to merge x265 package for PowerPC64 machines with CPU < POWER8.
(In reply to Jocelyn Mayer from comment #8) > Then, we should find a way to disable CPU_POWER8 and ALTIVEC in order to > merge x265 package for PowerPC64 machines with CPU < POWER8. Yes, that's why I was asking you to try with the cmake options: (In reply to Alexis Ballier from comment #7) > btw, does it work any better if you pass -DCPU_POWER8=OFF to cmake ? and -DENABLE_ALTIVEC=OFF if that does not work
Created attachment 466804 [details, diff] media-libs/x265/x265-2.2.ebuild patch This patch, forcing -DCPU_POWER8=OFF and -DENABLE_ALTIVEC=OFF cmake flags allows me to compile and run media-libs/x265-2.2 successfully on the Imac G5. The drawback is that it disables optimisation for POWER8+ CPUs... I don't know how to dynamically check the CPU version in order to make -DCPU_POWER8 and -DENABLE_ALTIVEC set accordingly to the current CPU...
commit 01d54dcfff9f02fc3acd31acce03d3d2011e6346 Author: Alexis Ballier <aballier@gentoo.org> Date: Sun Mar 12 12:39:23 2017 +0100 media-libs/x265: Add power8 useflag, bug #611906 Package-Manager: Portage-2.3.4, Repoman-2.3.2 commit cdcf3bf245394c487165de83ca24a98400a613a3 Author: Alexis Ballier <aballier@gentoo.org> Date: Sun Mar 12 12:37:40 2017 +0100 profiles: mask power8 useflag in arch/base and unmask it for ppc, part of bug #611906 Thanks for testing, it should be all set now.