After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729276 - audioresample: Misdetected and/or misused intrinsics headers
audioresample: Misdetected and/or misused intrinsics headers
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.x
Other Windows
: Normal normal
: 1.9.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 772107 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-04-30 16:45 UTC by LRN
Modified: 2016-09-30 07:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP audioresample: Separate out CFLAGS used for SSE code (20.24 KB, patch)
2016-09-28 12:14 UTC, Arun Raghavan
none Details | Review
WIP audioresample: Separate out CFLAGS used for SSE code (37.35 KB, patch)
2016-09-28 12:18 UTC, Arun Raghavan
none Details | Review
audioresample: Separate out CFLAGS used for SSE* code (71.70 KB, patch)
2016-09-28 13:05 UTC, Arun Raghavan
none Details | Review
audioresample: Separate out CFLAGS used for SSE* code (80.28 KB, patch)
2016-09-28 13:21 UTC, Arun Raghavan
none Details | Review
build.log (13.58 KB, text/x-log)
2016-09-28 15:56 UTC, Jura
  Details
audioresample: Separate out CFLAGS used for SSE* code (82.00 KB, patch)
2016-09-29 10:21 UTC, Arun Raghavan
none Details | Review
headers.tar (140.00 KB, application/x-tar)
2016-09-29 10:41 UTC, Jura
  Details
audioresample: Separate out CFLAGS used for SSE* code (82.07 KB, patch)
2016-09-29 13:11 UTC, Arun Raghavan
committed Details | Review

Description LRN 2014-04-30 16:45:17 UTC
As of mingw-w64-gcc-4.9.0 the configure test that used to check for xmmintrin.h and emmintrin.h passes instead of failing.

It used to fail because xmmintrin.h was hardcoded to #error when sse is not enabled, which is why HAVE_XMMINTRIN_H was always undefined.

New version of xmmintrin.h does *something* (not sure what) to make gcc require sse feature for sse intrinsics. This passes the simplistic configure test (which has no executable code) and defines HAVE_XMMINTRIN_H, but later audioresample fails to build.

mingw-w64 maintainer says that
#include <xmmintrin.h>
should be guarded by #ifdef __SSE__
(and emmintrin.h - by __SSE2__, i guess).
Comment 1 Ross Burton 2014-05-08 21:51:05 UTC
We're also seeing a similar problem building with gcc4.9 for qemux86, a (virtual) processor that doesn't support SSE.

Specifically when building audioresample there are many instances of:

Warning: SSE vector return without SSE enabled changes the ABI
Error: inlining failed in call to always_inline '_mm_setzero_pd': target specific option mismatch
Comment 2 Sebastian Dröge (slomo) 2014-05-09 06:41:05 UTC
Maybe we should just not use the gcc intrinsics headers and use asm blocks instead.

If using the intrinsics headers requires you to compile with -msse and the like, this is IMHO a bug in gcc though. We are intentionally not compiling with -msse as this would compile the C code into something that does not run without SSE (possibly, at least it allows gcc to emit SSE opcodes everywhere). We only want to have these specific parts of the code using SSE, and then detect at runtime if the CPU supports SSE and otherwise never call it.
Comment 3 LRN 2014-05-09 08:03:29 UTC
What i've been told initially is that you should isolate SSE-, MMX- and any other extended-instruction-using code into separate source files, compile them with appropriate compiler options, and make sure that *any* functions from these files are only called if runtime CPU detection permits.
I suspect that for some cases (such as code from speex) this is not very convenient.

I raised this issue again today, here's what i've got:

ktietz:	I can't do much about gcc's intrinsic header
ktietz:	the compromize I suggest is to use instead intrin.h header and omitting direct use of gcc's intrin-headers
LRN:	isn't intrin.h MS-specific?
ktietz:	well, it is a standard header present in our runtime for exactly such issues
ktietz:	if user insist to use directly the intrin-headers provided by gcc, then they have to deal with the bugs there themself
LRN:	well, GStreamer code is hardly W32-only, so i somehow doubt that they would like to rely on W32-only header for such things...
ktietz:	well, the issues reported here aren't W-specific AFAICS
ktietz:	so at least they need to guard the use of those headers
Comment 4 Ross Burton 2014-05-12 14:19:13 UTC
I think I agree with LRN - the current design doesn't work.  Our build with gcc 4.8 finds that the intriniscs headers are unavailable because we're not enabling SSE.  If we enable SSE, not just the resampler will use SSE but gcc can happily use SSE when optimising: the point of runtime detection is broken.

The CPU-specific code should be pulled into separate files which are individually compiled with the relevant flags, and then all linked together.
Comment 5 Richard Purdie 2014-05-12 14:21:20 UTC
FWIW I also agree here, the SSE code needs to be in a separate file and then that file can be compiled with the correct compiler options. You can then do what you describe - detect SSE at runtime and use that code without the risk of invalid instructions anywhere else.
Comment 6 Sebastian Dröge (slomo) 2014-05-12 14:23:01 UTC
Let's just stop using the gcc intriniscs headers and use inline assembly there
Comment 7 Daniel Stone 2014-05-12 14:35:42 UTC
Doing it in a separate file is definitely the correct way to do it, and how, e.g., pixman does it. I don't really see the value in hand-rolling your own assembly, aside from having yet another target to fix everywhere ...
Comment 8 Sebastian Dröge (slomo) 2014-05-12 15:12:01 UTC
It's going to make the build more fragile and complicated. Feel free to prove me wrong though :)
Comment 9 Daniel Stone 2014-05-12 16:53:57 UTC
You're trading relatively minor build system complexity - something which is well understood and implemented both, in libraries such as Pixman - for duplicating yet another chunk of code which will need to be updated every time the underlying architecture changes.

The entire point of intrinsics is to allow you (and the poor people who have to do the work of going through every single component and fixing it) to avoid the latter.  X11 chose the latter path, and I can tell you from experience that it's terrible.  Even taking laziness as an argument, it's not even less work to go down that path.
Comment 10 Sebastian Dröge (slomo) 2016-09-28 08:21:25 UTC
*** Bug 772107 has been marked as a duplicate of this bug. ***
Comment 11 Arun Raghavan 2016-09-28 12:14:54 UTC
Created attachment 336433 [details] [review]
WIP audioresample: Separate out CFLAGS used for SSE code

This makes sure that we only build files that need explicit SIMD support
with the relevant CFLAGS.

I've only done this for SSE atm. If the approach looks okay, I can do SSE2 and
SSE4.1 as well.

Also pending is doing this on the meson build.
Comment 12 Arun Raghavan 2016-09-28 12:18:31 UTC
Created attachment 336434 [details] [review]
WIP audioresample: Separate out CFLAGS used for SSE code

Include the split-out files this time.
Comment 13 Sebastian Dröge (slomo) 2016-09-28 12:23:59 UTC
Review of attachment 336434 [details] [review]:

Seems like a good approach, yes

::: gst-libs/gst/audio/Makefile.am
@@ +108,3 @@
+	$(libgstaudio_@GST_API_VERSION@_la_CFLAGS) -msse
+# don't use full LDFLAGs because we get things like -version-info that cause a warning on private libs
+libaudio_resampler_sse_la_LDFLAGS = -msse

You need to do this only with GCC (and maybe clang) then
Comment 14 Jura 2016-09-28 12:45:11 UTC
I apply patch from last cooment and try compile:

In file included from /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler.c:834:0:
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86.h: In function ‘inner_product_gint32_full_1_sse41’:
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86.h:392:9: error: implicit declaration of function ‘_mm_cvtsi128_si64’ [-Werror=implicit-function-declaration]
   res = _mm_cvtsi128_si64 (sum);
         ^
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86.h:392:3: error: nested extern declaration of ‘_mm_cvtsi128_si64’ [-Werror=nested-externs]
   res = _mm_cvtsi128_si64 (sum);
Comment 15 Arun Raghavan 2016-09-28 13:05:24 UTC
Created attachment 336439 [details] [review]
audioresample: Separate out CFLAGS used for SSE* code

This makes sure that we only build files that need explicit SIMD support
with the relevant CFLAGS. This allows the rest of the code to be built
without, and specific SSE* code is only called after runtime checks for
CPU features.

The meson build files need to updated.
Comment 16 Jura 2016-09-28 13:10:11 UTC
In file included from /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler.c:831:0:
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86.h:23:39: fatal error: audio-resampler-x86-sse41.h: No such file or directory
compilation terminated.
Comment 17 Arun Raghavan 2016-09-28 13:21:38 UTC
Created attachment 336446 [details] [review]
audioresample: Separate out CFLAGS used for SSE* code

Add missing files again. Sorry 'bout the spam.
Comment 18 Jura 2016-09-28 13:28:07 UTC
Old bug disapper, but new error:

libtool: link: x86_64-pc-linux-gnu-gcc -m32 -I/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs -I../gst-libs -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -DG_THREADS_MANDATORY -DG_DISABLE_DEPRECATED -Wall -Wdeclaration-after-statement -Wvla -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return -Wno-multichar -Wnested-externs -Werror -O2 -pipe -march=native -finline-functions -fomit-frame-pointer -Wl,-O1 -Wl,--as-needed -o .libs/gst-discoverer-1.0 gst-discoverer.o  ../gst-libs/gst/pbutils/.libs/libgstpbutils-1.0.so ../gst-libs/gst/tag/.libs/libgsttag-1.0.so ../gst-libs/gst/audio/.libs/libgstaudio-1.0.so ../gst-libs/gst/video/.libs/libgstvideo-1.0.so -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lm -pthread
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_full_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gdouble_cubic_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gfloat_cubic_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gdouble_linear_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_linear_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_cubic_1_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gfloat_linear_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_cubic_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_full_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gint16_cubic_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_linear_1_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gint16_linear_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_cubic_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_linear_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_cubic_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_full_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_linear_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_full_1_sse'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:681: gst-discoverer-1.0] Error 1
make[2]: *** Waiting for unfinished jobs....
Comment 19 Arun Raghavan 2016-09-28 13:31:37 UTC
That's odd. Can you do a make clean, touch configure.ac, and then make again?
Comment 20 Arun Raghavan 2016-09-28 13:42:44 UTC
(also build tested with clang on Linux, fwiw)
Comment 21 Jura 2016-09-28 15:56:20 UTC
I use gentoo portage for build ;)

I try manualy:
cd /tmp
tar xvf /usr/portage/distfiles/gst-plugins-base-1.9.2.tar.xz
wget "https://bug729276.bugzilla-attachments.gnome.org/attachment.cgi?id=336446&action=diff&collapsed=&context=patch&format=raw&headers=1" -O patch
cd gst-plugins-base-1.9.2
patch -p1 < ../patch
./configure --build=x86_64-pc-linux-gnu --host=i686-pc-linux-gnu
make &> build.log

and more errors...
Comment 22 Jura 2016-09-28 15:56:54 UTC
Created attachment 336457 [details]
build.log
Comment 23 Arun Raghavan 2016-09-28 16:03:04 UTC
Those failures don't seem to be related to this patch. Some other weirdness in your build env.
Comment 24 Tim-Philipp Müller 2016-09-28 16:05:23 UTC
Are you *sure* your configure was re-generated after the patch to configure.ac here?
Comment 25 Jura 2016-09-28 16:09:33 UTC
Yes, gentoo portage apply patch, and run configure for 32 and 64 bit:


>>> Emerging (1 of 1) media-libs/gst-plugins-base-1.9.2::my-gnome

 * gst-plugins-base-1.9.2.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                             [ ok ]


>>> Unpacking source...
>>> Unpacking gst-plugins-base-1.9.2.tar.xz to /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work
>>> Source unpacked in /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work
>>> Preparing source in /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2 ...
 * Applying gst-plugins-base-1.9.2-separate-cflags-for-sse.patch ...                                                                              [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2 ...
 * abi_x86_32.x86: running multilib-minimal_abi_src_configure
 * Configuring to build base plugin(s) ...
 * econf: updating gst-plugins-base-1.9.2/config.guess with /usr/share/gnuconfig/config.guess
 * econf: updating gst-plugins-base-1.9.2/config.sub with /usr/share/gnuconfig/config.sub
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/configure --prefix=/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --disable-silent-rules --docdir=/usr/share/doc/gst-plugins-base-1.9.2 --htmldir=/usr/share/doc/gst-plugins-base-1.9.2/html --libdir=/usr/lib32 --with-package-name=Gentoo GStreamer ebuild --with-package-origin=https://www.gentoo.org --disable-zlib --disable-x --disable-xvideo --disable-xshm --disable-alsa --disable-cdparanoia --disable-ivorbis --disable-libvisual --disable-ogg --disable-opus --disable-pango --disable-theora --disable-vorbis --enable-orc --disable-maintainer-mode --enable-nls --enable-alsa --disable-introspection --disable-ivorbis --enable-ogg --enable-opus --enable-orc --enable-pango --enable-theora --enable-vorbis --enable-x --enable-xshm --enable-xvideo --disable-debug --disable-examples --disable-static

but get error on compile:

libtool: link: x86_64-pc-linux-gnu-gcc -m32 -I/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs -I../gst-libs -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -DG_THREADS_MANDATORY -DG_DISABLE_DEPRECATED -Wall -Wdeclaration-after-statement -Wvla -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return -Wno-multichar -Wnested-externs -Werror -O2 -pipe -march=native -finline-functions -fomit-frame-pointer -Wl,-O1 -Wl,--as-needed -o .libs/gst-discoverer-1.0 gst-discoverer.o  ../gst-libs/gst/pbutils/.libs/libgstpbutils-1.0.so ../gst-libs/gst/tag/.libs/libgsttag-1.0.so ../gst-libs/gst/audio/.libs/libgstaudio-1.0.so ../gst-libs/gst/video/.libs/libgstvideo-1.0.so -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lm -pthread
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_full_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gdouble_cubic_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gfloat_cubic_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gdouble_linear_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_linear_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_cubic_1_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gfloat_linear_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_cubic_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_full_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gint16_cubic_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_linear_1_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gint16_linear_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_cubic_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_linear_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_cubic_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_full_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_linear_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_full_1_sse'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:681: gst-discoverer-1.0] Error 1
make[2]: *** Waiting for unfinished jobs....
libtool: link: x86_64-pc-linux-gnu-gcc -m32 -I/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs -I../gst-libs -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -DG_THREADS_MANDATORY -DG_DISABLE_DEPRECATED -Wall -Wdeclaration-after-statement -Wvla -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return -Wno-multichar -Wnested-externs -Werror -O2 -pipe -march=native -finline-functions -fomit-frame-pointer -Wl,-O1 -Wl,--as-needed -o .libs/gst-play-1.0 gst-play.o gst-play-kb.o  ../gst-libs/gst/pbutils/.libs/libgstpbutils-1.0.so ../gst-libs/gst/tag/.libs/libgsttag-1.0.so ../gst-libs/gst/audio/.libs/libgstaudio-1.0.so ../gst-libs/gst/video/.libs/libgstvideo-1.0.so -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lm -pthread
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_full_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gdouble_cubic_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gfloat_cubic_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gdouble_linear_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_linear_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_cubic_1_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gfloat_linear_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_cubic_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint32_full_1_sse41'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gint16_cubic_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_linear_1_sse'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `interpolate_gint16_linear_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_cubic_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_linear_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gint16_cubic_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_full_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gdouble_linear_1_sse2'
../gst-libs/gst/audio/.libs/libgstaudio-1.0.so: undefined reference to `resample_gfloat_full_1_sse'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:685: gst-play-1.0] Error 1
make[2]: Leaving directory '/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2-abi_x86_32.x86/tools'
make[1]: *** [Makefile:693: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2-abi_x86_32.x86'
make: *** [Makefile:622: all] Error 2


Sorry for bad english ;)
Comment 26 Arun Raghavan 2016-09-28 16:11:01 UTC
You probably need an eautoreconf
Comment 27 Sebastian Dröge (slomo) 2016-09-28 16:57:32 UTC
Review of attachment 336446 [details] [review]:

Almost good to go :)

::: gst-libs/gst/audio/Makefile.am
@@ +111,3 @@
+libaudio_resampler_sse_la_CFLAGS = \
+	$(libgstaudio_@GST_API_VERSION@_la_CFLAGS) \
+	-msse

You still need to ensure to only do that if the compiler supports this very flag. Needs a configure check

Should probably also check for the relevant intrinsics headers.
Comment 28 Arun Raghavan 2016-09-28 17:31:45 UTC
The intrinsics are checked for already (and all the .c files have the code surrounded by #ifdefs for corresponding HAVE_*_H).

I'll add some HAVE_SSE/HAVE_SSE2/... AM_CONDITIONALs around this tomorrow with some configure.ac checks for the corresponding compiler flags.
Comment 29 Jura 2016-09-28 17:55:03 UTC
I add eautoreconf, but next error:
>>> Unpacking source...
>>> Unpacking gst-plugins-base-1.9.2.tar.xz to /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work
>>> Source unpacked in /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work
>>> Preparing source in /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2 ...
 * Applying gst-plugins-base-1.9.2-separate-cflags-for-sse.patch ... [ ok ]
 * Running eautoreconf in '/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2' ...
 * Running autopoint --force ...                             [ ok ]
 * Skipping 'gtkdocize --copy' due gtkdocize not installed
 * Running libtoolize --install --copy --force --automake ...[ ok ]
 * Running aclocal -I m4 -I common/m4 ...                    [ ok ]
 * Running autoconf --force ...                              [ ok ]
 * Running autoheader ...                                    [ ok ]
 * Running automake --add-missing --copy --force-missing ... [ ok ]
 * Running elibtoolize in: gst-plugins-base-1.9.2/
 *   Applying portage/1.2.0 patch ...
 *   Applying sed/1.5.6 patch ...
 *   Applying as-needed/2.4.3 patch ...
>>> Source prepared.
................
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c: In function ‘inner_product_gint32_full_1_sse41’:
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:66:9: error: implicit declaration of function ‘_mm_cvtsi128_si64’ [-Werror=implicit-function-declaration]
   res = _mm_cvtsi128_si64 (sum);
         ^
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:66:3: error: nested extern declaration of ‘_mm_cvtsi128_si64’ [-Werror=nested-externs]
   res = _mm_cvtsi128_si64 (sum);
Comment 30 Arun Raghavan 2016-09-29 10:21:44 UTC
Created attachment 336493 [details] [review]
audioresample: Separate out CFLAGS used for SSE* code

Fixed to also test for the relevant compiler flags. Also fixed compile-time
checks in top-level x86 header to not check for the __SSE_* flags (as that
defeats the purpose).
Comment 31 Arun Raghavan 2016-09-29 10:25:33 UTC
(In reply to Jura from comment #29)
[...]
> /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.
> 2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:66:3: error: nested extern
> declaration of ‘_mm_cvtsi128_si64’ [-Werror=nested-externs]
>    res = _mm_cvtsi128_si64 (sum);

If you still see this, please mention the exact gcc version being used, and also attach xmmintrin.h, emmintrin.h, tmmintrin.h, pmmintrin.h and smmintrin.h from wherever they are on your system.
Comment 32 Sebastian Dröge (slomo) 2016-09-29 10:32:59 UTC
Review of attachment 336493 [details] [review]:

Almost good to go

::: configure.ac
@@ +190,3 @@
+SSE41_CFLAGS="-msse4.1"
+
+AS_CXX_COMPILER_FLAG([$SSE_CFLAGS], [HAVE_SSE=1], [HAVE_SSE=0])

Why CXX?

::: gst-libs/gst/audio/Makefile.am
@@ +107,3 @@
+# -version-info that cause a warning on private libs
+
+noinst_LTLIBRARIES += libaudio_resampler_sse.la

Shouldn't this only be compiled in if HAVE_SSE? Same for the others?
Comment 33 Jura 2016-09-29 10:41:06 UTC
I apply «attachment 336493 [details] [review]» and try compile:

/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c: In function ‘inner_product_gint32_full_1_sse41’:
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:66:9: error: implicit declaration of function ‘_mm_cvtsi128_si64’ [-Werror=implicit-function-declaration]
   res = _mm_cvtsi128_si64 (sum);
         ^
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:66:3: error: nested extern declaration of ‘_mm_cvtsi128_si64’ [-Werror=nested-externs]
   res = _mm_cvtsi128_si64 (sum);
   ^
# equery b xmmintrin.h
 * Searching for xmmintrin.h ... 
sys-devel/gcc-5.4.0 (/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/xmmintrin.h)
sys-devel/llvm-3.8.1-r2 (/usr/lib/clang/3.8.1/include/xmmintrin.h)


# tar -c /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/{xmmintrin.h,emmintrin.h,tmmintrin.h,pmmintrin.h,smmintrin.h} > /tmp/headers.tar
Comment 34 Jura 2016-09-29 10:41:29 UTC
Created attachment 336497 [details]
headers.tar
Comment 35 Arun Raghavan 2016-09-29 12:58:22 UTC
(In reply to Sebastian Dröge (slomo) from comment #32)
> Review of attachment 336493 [details] [review] [review]:
> 
> Almost good to go
> 
> ::: configure.ac
> @@ +190,3 @@
> +SSE41_CFLAGS="-msse4.1"
> +
> +AS_CXX_COMPILER_FLAG([$SSE_CFLAGS], [HAVE_SSE=1], [HAVE_SSE=0])
> 
> Why CXX?

Because I suck.

> ::: gst-libs/gst/audio/Makefile.am
> @@ +107,3 @@
> +# -version-info that cause a warning on private libs
> +
> +noinst_LTLIBRARIES += libaudio_resampler_sse.la
> 
> Shouldn't this only be compiled in if HAVE_SSE? Same for the others?

I'd initially done this, but we also have checks for both the header and SSE support in each of the C files, so it felt redundant. Can put it back if you think it's clearer.
Comment 36 Sebastian Dröge (slomo) 2016-09-29 12:59:31 UTC
(In reply to Arun Raghavan from comment #35)

> I'd initially done this, but we also have checks for both the header and SSE
> support in each of the C files, so it felt redundant. Can put it back if you
> think it's clearer.

As long as it compiles and links fine if any of these things are not found :)


Please merge once you removed the CXX
Comment 37 Arun Raghavan 2016-09-29 13:11:32 UTC
Created attachment 336517 [details] [review]
audioresample: Separate out CFLAGS used for SSE* code

About to push this. Jura, this should also fix your problem --
_mm_cvtsi128_si64() comes from emmintrin.h which is included in my smmintrin.h
but not in yours. Added an explicit include for it.
Comment 38 Jura 2016-09-30 07:44:21 UTC
After apply attachment 336517 [details] [review] :
libtool: compile:  x86_64-pc-linux-gnu-gcc -m32 -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio -I../../.. -I/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs -I../../../gst-libs -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -DG_THREADS_MANDATORY -DG_DISABLE_DEPRECATED -Wall -Wdeclaration-after-statement -Wvla -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return -Wno-multichar -Wnested-externs -Werror -I/usr/include/orc-0.4 -msse4.1 -O2 -pipe -march=native -finline-functions -fomit-frame-pointer -c /var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c  -fPIC -DPIC -o .libs/libaudio_resampler_sse41_la-audio-resampler-x86-sse41.o
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c: In function ‘inner_product_gint32_full_1_sse41’:
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:67:9: error: implicit declaration of function ‘_mm_cvtsi128_si64’ [-Werror=implicit-function-declaration]
   res = _mm_cvtsi128_si64 (sum);
         ^
/var/tmp/portage/media-libs/gst-plugins-base-1.9.2/work/gst-plugins-base-1.9.2/gst-libs/gst/audio/audio-resampler-x86-sse41.c:67:3: error: nested extern declaration of ‘_mm_cvtsi128_si64’ [-Werror=nested-externs]
   res = _mm_cvtsi128_si64 (sum);
   ^
Comment 39 Sebastian Dröge (slomo) 2016-09-30 07:47:15 UTC
The attachment is not the latest version that was committed, and there was a follow-up fix. Try these:

https://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=4b5f78337a54130f20efc454f48646f507847644
https://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=a1ae17ef69251f33e427bd96dbefa6ac5e723059
Comment 40 Jura 2016-09-30 07:54:36 UTC
It works! Thanks!