Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 482258 - media-video/libav-9.8 - fails to build on amd64 hardened system when CFLAGS+=-fstack-check
Summary: media-video/libav-9.8 - fails to build on amd64 hardened system when CFLAGS+=...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: media-video herd
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 20:21 UTC by Amadeusz Sławiński
Modified: 2017-08-25 19:03 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Amadeusz Sławiński 2013-08-23 20:21:40 UTC
Similarly to ffmpeg (https://bugs.gentoo.org/show_bug.cgi?id=471756), libav also fails to build with -fstack-check

[ebuild   R    ] media-video/libav-9.8:0/9  USE="X alsa bzip2 encode gpl hardcoded-tables jpeg2k mmx mmxext mp3 ssl ssse3 threads v4l zlib -3dnow -3dnowext -aac (-altivec) -amr -avx -bindist -cdio -cpudetection -custom-cflags -debug -doc -faac -fdk -frei0r -gsm -ieee1394 -jack (-neon) -network -openssl -opus -oss -pic -pulseaudio -rtmp -schroedinger -sdl -speex -static-libs {-test} -theora -tools -truetype -vaapi -vdpau (-vis) -vorbis -vpx -x264 -xvid" 0 kB


x86_64-pc-linux-gnu-gcc -I. -I. -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DHAVE_AV_CONFIG_H -fstack-check -O2 -march=native -pipe  -fstack-check -O2 -march=native -pipe -std=c99 -fomit-frame-pointer -fPIC -pthread  -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wstrict-prototypes -fstack-check -O2 -march=native -pipe -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=declaration-after-statement -Werror=vla  -MMD -MF libavcodec/x86/mlpdsp.d -MT libavcodec/x86/mlpdsp.o -c -o libavcodec/x86/mlpdsp.o libavcodec/x86/mlpdsp.c
x86_64-pc-linux-gnu-gcc -I. -I. -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DHAVE_AV_CONFIG_H -fstack-check -O2 -march=native -pipe  -fstack-check -O2 -march=native -pipe -std=c99 -fomit-frame-pointer -fPIC -pthread  -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wstrict-prototypes -fstack-check -O2 -march=native -pipe -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=declaration-after-statement -Werror=vla  -MMD -MF libavcodec/x86/motion_est.d -MT libavcodec/x86/motion_est.o -c -o libavcodec/x86/motion_est.o libavcodec/x86/motion_est.c
libavcodec/x86/mlpdsp.c: In function ‘mlp_filter_channel_x86’:
libavcodec/x86/mlpdsp.c:124:5: error: can’t find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
libavcodec/x86/mlpdsp.c:124:5: error: ‘asm’ operand has impossible constraints
make: *** [libavcodec/x86/mlpdsp.o] Error 1
make: *** Waiting for unfinished jobs....
yasm -f elf -m amd64 -DPIC -I./ -I./ -Pconfig.asm -I libavcodec/x86/ -o libavcodec/x86/imdct36.o libavcodec/x86/imdct36.asm


Patch from the ffmpeg bug also allows libav to build
Comment 5 on other bug suggests playing mlp file to test, so I downloaded hard-rock.mlp from https://archive.org/details/MlpLosslessEncodedSurroundSoundFiles and it seems to play ok

% mplayer2 hard-rock.mlp 
MPlayer2 2.0-726-g6c87a98 (C) 2000-2012 MPlayer Team
Cannot open file '/home/amade/.mplayer/input.conf': No such file or directory
Failed to open /home/amade/.mplayer/input.conf.
Cannot open file '/etc/mplayer2/input.conf': No such file or directory
Failed to open /etc/mplayer2/input.conf.

Playing hard-rock.mlp.
Detected file format: raw MLP (libavformat)
[mlp @ 0x2cb897df4c0]max_analyze_duration reached
[mlp @ 0x2cb897df4c0]Estimating duration from bitrate, this may be inaccurate
[lavf] stream 0: audio (mlp), -aid 0
Load subtitles in .
Selected audio codec: MLP (Meridian Lossless Packing) [libavcodec]
AUDIO: 48000 Hz, 2 ch, s32le, 0.0 kbit/0.00% (ratio: 0->384000)
AO: [alsa] 48000Hz 2ch s32le (4 bytes per sample)
Video: no video
Starting playback...


Reproducible: Always




Portage 2.2.1 (hardened/linux/amd64/no-multilib/selinux, gcc-4.7.3, glibc-2.17, 3.10.7-hardened-r1 x86_64)
=================================================================
System uname: Linux-3.10.7-hardened-r1-x86_64-Intel-R-_Core-TM-_i3_CPU_M_350_@_2.27GHz-with-gentoo-2.2
KiB Mem:     2996996 total,    876016 free
KiB Swap:    3145724 total,   3144736 free
Timestamp of tree: Fri, 23 Aug 2013 00:45:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-lang/python:          2.7.5-r2, 3.2.5-r2, 3.3.2-r2
dev-util/cmake:           2.8.11.1
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.13.4, 1.14
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.10 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo hardened-dev local-overlay
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA AdobeFlash-11.x"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-fstack-check -O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-fstack-check -O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox selinux sesandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4"
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"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/hardened-development /home/amade/overlay"
SYNC=""
USE="X acpi alsa amd64 bash-completion berkdb bluetooth bzip2 cli cracklib crypt cxx dbus dri dvd flac gdbm gif gnutls gold gpg hardened iconv icu ipv6 jpeg jpeg2k justify libnotify mmx mmxext mng modules mp3 mudflap ncurses nls nptl open_perms opencl opengl openmp pam pax_kernel pcre png qt4 readline selinux session sse sse2 sse4_1 sse4_2 ssl ssse3 tcpd threads tiff udev unicode urandom usb v4l vim-syntax vlc wacom xattr xcb xft xinerama zlib zsh-completion" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_GB pl" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-4" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="x86_64 ppc" RUBY_TARGETS="ruby19" USERLAND="GNU" VIDEO_CARDS="nouveau" 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"
USE_PYTHON="2.7 3.2 3.3"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Anthony Basile gentoo-dev 2014-10-17 21:06:46 UTC
Okay the following should address this issue:

# diff -Naur libav-9.14.ebuild libav-9.14-r1.ebuild
--- libav-9.14.ebuild	2014-08-10 17:01:13.000000000 -0400
+++ libav-9.14-r1.ebuild	2014-10-17 17:06:22.162781792 -0400
@@ -259,6 +259,11 @@
 	# Misc stuff
 	use hardcoded-tables && myconf+=( --enable-hardcoded-tables )
 
+	# Even amd64 suffers from too-few-registers, bug #482258
+	if [[ ${ABI} == amd64 ]] && gcc-specs-stack-check; then
+		append-flags $(test-flags -fno-stack-check)
+	fi
+
 	# Specific workarounds for too-few-registers arch...
 	if [[ ${ABI} == x86 ]]; then
 		local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}


Currently only hardened uses -fstack-check, and its only available on 4.8 and above, but this future proofs the code in case stack-check makes it into our mainline specs.
Comment 2 Magnus Granberg gentoo-dev 2015-01-26 21:38:15 UTC
Time to applay the fix on libav and ffmpeg?
Comment 3 Hanno Böck gentoo-dev 2017-08-24 18:24:52 UTC
The corresponding ffmpeg bug #471756 mentions that this issue got resolved by using newer gcc versions (4.8 and up). I just tried compiling libav (12.1) with a current gcc (6.4.0) and saw no problem.

I guess this bug is obsolete and can be closed (?). Or can anyone still reproduce this?
Comment 4 Francisco Blas Izquierdo Riera gentoo-dev 2017-08-25 19:03:53 UTC
I can confirm libav builds correctly here, please reopen the bug if necessary.