Opened 6 years ago

Closed 6 years ago

#2343 closed defect (fixed)

cpu runtime detection does not build on i386 with glibc 2.27

Reported by: James Cowgill Owned by: beastd
Priority: normal Component: undetermined
Version: Severity: major
Keywords: Cc:
Blocked By: Blocking:
Reproduced by developer: no Analyzed by developer: no

Description

Building mplayer subversion (r38104) on i386 with glibc 2.27 fails if cpu runtime detection is enabled:

$ ./configure --disable-ffmpeg_a --enable-runtime-cpudetection
[...]
$ make
[...]
cc -MMD -MP -Wundef -Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls -Werror=format-security -Wstrict-prototypes -Wmissing-prototypes -Wdisabled-optimization -Wno-pointer-sign -Wdeclaration-after-statement -std=gnu99 -Werror-implicit-function-declaration -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ISOC99_SOURCE -I. -Iffmpeg -O4 -march=i486 -mtune=generic -pipe -ffast-math -fomit-frame-pointer -fno-tree-vectorize -fno-asynchronous-unwind-tables -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE  -DPIC -D_REENTRANT -I/usr/include/p11-kit-1 -I/usr/include/samba-4.0 -I/usr/include/directfb -I/usr/include/   -D_REENTRANT  -I/usr/include/freetype2 -I/usr/include/libpng16 -DZLIB_CONST -I/usr/include/opus -I/usr/include/bs2b -I/usr/include/i386-linux-gnu -I/usr/include/i386-linux-gnu  -c -o cpudetect.o cpudetect.c
cpudetect.c:60:52: warning: 'struct sigcontext' declared inside parameter list will not be visible outside of this definition or declaration
 static void sigill_handler_sse( int signal, struct sigcontext sc )
                                                    ^~~~~~~~~~
cpudetect.c:60:63: error: parameter 2 ('sc') has incomplete type
 static void sigill_handler_sse( int signal, struct sigcontext sc )
                                                               ^~
cpudetect.c:60:13: warning: function declaration isn't a prototype [-Wstrict-prototypes]
 static void sigill_handler_sse( int signal, struct sigcontext sc )
             ^~~~~~~~~~~~~~~~~~
Makefile:726: recipe for target 'cpudetect.o' failed
make: *** [cpudetect.o] Error 1

This happens because <signal.h> no longer defines "struct sigcontext" in standards compliant mode, because the behavior of sigcontext is highly platform specific. See this glibc commit:
https://sourceware.org/git/?p=glibc.git;a=commit;h=4fa9b3bfe6759c82beb4b043a54a3598ca467289

To use sigcontext, you need to do one of these:

  • Define _GNU_SOURCE
  • Define _DEFAULT_SOURCE
  • Remove the _POSIX_C_SOURCE, _XOPEN_SOURCE and _ISOC99_SOURCE defines (which will cause glibc to define _DEFAULT_SOURCE).

Change History (2)

comment:1 by reimar, 6 years ago

Note that unless a really ancient Linux version is used, the best fix might be to just remove this code - SSE itself is detected via CPUID, this is just about the case when a non-SSE-aware kernel is used on a SSE CPU.
However I committed r38106 which uses longjmp instead of trying to hack eip from the signal handler.

comment:2 by reimar, 6 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.