From bc2c6a280ddb2bf4b46a2541baef6e83bfc03e72 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Thu, 25 Jun 2020 19:31:46 +0200 Subject: [PATCH] Fix illegal instruction in libaudio.dylib on OSX This file gets included by AudioHRTF_avx512.cpp, which contains code that should only be getting executed on CPUs with the appropriate support. Unfortunately, when that file is compiled with -mavx512f, GCC also generates AVX instructions in the code that initializes the value of SQUARE_ROOT_OF_2, and this crashes on CPUs without AVX because it runs unconditionally. Avoid the issue entirely by just making it a constant so no code needs to be run. --- libraries/shared/src/NumericalConstants.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/NumericalConstants.h b/libraries/shared/src/NumericalConstants.h index 8377c48960..b7fecfa1e4 100644 --- a/libraries/shared/src/NumericalConstants.h +++ b/libraries/shared/src/NumericalConstants.h @@ -28,8 +28,8 @@ const float ARCSECONDS_PER_ARCMINUTE = 60.0f; const float ARCSECONDS_PER_DEGREE = ARCMINUTES_PER_DEGREE * ARCSECONDS_PER_ARCMINUTE; const float EPSILON = 0.000001f; //smallish positive number - used as margin of error for some computations -const float SQUARE_ROOT_OF_2 = (float)sqrt(2.0f); -const float SQUARE_ROOT_OF_3 = (float)sqrt(3.0f); +const float SQUARE_ROOT_OF_2 = 1.414214f; +const float SQUARE_ROOT_OF_3 = 1.732051f; const float METERS_PER_DECIMETER = 0.1f; const float METERS_PER_CENTIMETER = 0.01f; const float METERS_PER_MILLIMETER = 0.001f;