From 88a5bde51fe37314a31131573d3d387cfd3430fa Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 14 Nov 2020 10:01:04 -0800 Subject: [PATCH] Fixing M_PI compile error on MSVC. M_PI and other math constants (used in chlo_legalize_hlo_patterns.td) are not part of the C++ standard and must be enabled on MSVC (similar to _GNU_SOURCE adding glibc symbols to posix headers). PiperOrigin-RevId: 342432987 --- lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo.cc b/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo.cc index b232ca4..2144a59 100644 --- a/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo.cc +++ b/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo.cc @@ -13,6 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +// Enable the use of M_* math constants. +// NOTE: this must be first in the file to ensure that if cmath is transitively +// included by any other header it has the define set on first processing. +// https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants +#define _USE_MATH_DEFINES +#include #include #include "mlir-hlo/Dialect/mhlo/IR/chlo_ops.h"