From 3929798a53c6fbc83b3d54d801c1c07cee4c78f5 Mon Sep 17 00:00:00 2001 From: Georg Chini Date: Sun, 21 Jul 2019 15:07:18 +0200 Subject: [PATCH] Commit fd9e3452 removed -ffast-math from the compile flags. Under some conditions this may lead to massive slowdown of floating point operations when underflows or denormals are encountered. In particular, this problem was observed with the soxr resampler after applying https://gitlab.freedesktop.org/pulseaudio/pulseaudio/merge_requests/120 Therefore this patch adds -ffast-math to the link flags of the pulseaudio daemon. Linking with -ffast-math adds a procedure set_fast_math() to the startup code of the daemon. On x86, the procedure sets bit 6 and 15 of the mxcsr register. When these bits are set, denormals and results of underflowing operations are truncated to 0. --- src/Makefile.am | 4 ++-- src/daemon/meson.build | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 03535fc83..ede970b2b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -175,9 +175,9 @@ PREOPEN_LIBS = $(modlibexec_LTLIBRARIES) endif if FORCE_PREOPEN -pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(IMMEDIATE_LDFLAGS) -dlpreopen force $(foreach f,$(PREOPEN_LIBS),-dlpreopen $(f)) +pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(IMMEDIATE_LDFLAGS) -ffast-math -dlpreopen force $(foreach f,$(PREOPEN_LIBS),-dlpreopen $(f)) else -pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(IMMEDIATE_LDFLAGS) -dlopen force $(foreach f,$(PREOPEN_LIBS),-dlopen $(f)) +pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(IMMEDIATE_LDFLAGS) -ffast-math -dlopen force $(foreach f,$(PREOPEN_LIBS),-dlopen $(f)) endif if HAVE_SYSTEMD_DAEMON diff --git a/src/daemon/meson.build b/src/daemon/meson.build index 59bf0a2c3..f246153f0 100644 --- a/src/daemon/meson.build +++ b/src/daemon/meson.build @@ -28,6 +28,7 @@ executable('pulseaudio', pulseaudio_headers, install: true, include_directories : [configinc, topinc], + link_args : ['-ffast-math'], link_with : [libpulsecore, libpulsecommon, libpulse], dependencies : [ltdl_dep, cap_dep, dbus_dep, libsystemd_dep], c_args : pa_c_args,