gcc on the raspberry pi 3 crashes when called from our configure
script, and even in simpler cases:
$ gcc -mcpu=native -march=native
*** Error in `gcc': double free or corruption (top): 0x0190dbc0 ***
Aborted
So we need to add explicit optimisation options if we want to build an
optimal binary on the Pi 3.
As per:
https://www.element14.com/community/community/raspberry-pi/blog/2016/02/29/the-most-comprehensive-raspberry-pi-comparison-benchmark-ever
the raspberry pi 3 is an armv8, but cpuinfo incorrectly reports it as
an armv7. So we can’t detect the CPU using /proc/cpuinfo.
Instead we use /proc/device-tree/model, which explicit has the
Raspberry PI type in it, e.g. “Raspberry Pi 3 Model B Rev 1.2”.
https://www.raspberrypi.org/forums/viewtopic.php?t=144115&p=952479
lists hopefully correct optimal gcc flags, namely:
Some basic options that should be the defaults anyway:-
-mfloat-abi=hard -mlittle-endian -munaligned-access
(confirmed; these are the defaults)
Pi1 -mcpu=arm1176jzf-s -mfpu=vfp
Pi2 -mcpu=cortex-a7 -mfpu=neon-vfpv4
Pi3 -mcpu=cortex-a53 -mfpu=neon-fp-armv8
When we test if the compiler options work, we didn't test for the
possibility of the compiler crashing which unfortunately it does on
the raspberry pi 3 - crashing in this case means returning exit code
134 (i.e. SIGABRT).
Change the test so that instead of testing for one particular failure,
we invert and test for success - treating everything else as failure.
Currently if users run autoreconf then configure without having
pkg-config installed, they see:
./configure: line 5283: syntax error near unexpected token FFMPEG,'
./configure: line 5283: PKG_CHECK_MODULES(FFMPEG, libavutil
libavformat libavcodec libswscale, HAVE_FFMPEG=yes)'
This is not hugely helpful and causes support queries and confusion.
It is because the pkg.m4 file that defines PKG_CHECK_MODULES is not
available of pkg-config is not installed.
To work around this, remove PKG_CHECK_MODULES and do roughly the
equivalent calling pkg-config directly. To mirror the current
behaviour, we also add a test for pkg-config being present and abort
if it is not. (I am not 100% sure this is the desired behaviour, but
regardless this commit is still an improvement on what we currently
have.)
The current definitions (char codec_swf[3] = "swf" etc) are declared
one character too short resulting in stack corruption or crashes in
some cases.
To avoid the possibility of an error at all, we change ffmpeg_open to
take a const char * as it doesn't need to alter the string.
Closes https://github.com/Mr-Dave/motion/issues/109