diff --git a/ruy/BUILD b/ruy/BUILD index 9fdfc10fd60..a07d49d1961 100644 --- a/ruy/BUILD +++ b/ruy/BUILD @@ -332,12 +332,22 @@ cc_library( # ruy_copts contains -Wundef, but cpuinfo's header warns with that. "-Wno-undef", ], - }), + }) + select({ + # This select must match the similar select in `deps`. + # We intentionally define this token in the BUILD + # file so that ports to other build-systems do not + # use cpuinfo by default - they need to port the + # cpuinfo BUILD first, then can define this token. + ":ppc": [], + ":fuchsia": [], + "//conditions:default": ["-DRUY_HAVE_CPUINFO"], + }), deps = [ ":platform", ":check_macros", ":cpu_cache_params", ] + select({ + # This select must match the similar select in `copts` ":ppc": [], ":fuchsia": [], "//conditions:default": ["@cpuinfo//:cpuinfo_with_unstripped_include_path"], diff --git a/ruy/cpuinfo.cc b/ruy/cpuinfo.cc index db937546a8b..bda706c19de 100644 --- a/ruy/cpuinfo.cc +++ b/ruy/cpuinfo.cc @@ -8,9 +8,7 @@ #include "ruy/cpu_cache_params.h" #include "ruy/platform.h" -#define RUY_HAVE_CPUINFO (!(RUY_PLATFORM_PPC || RUY_PLATFORM_FUCHSIA)) - -#if RUY_HAVE_CPUINFO +#ifdef RUY_HAVE_CPUINFO #include "include/cpuinfo.h" #endif @@ -24,7 +22,7 @@ void MakeDummyCacheParams(CpuCacheParams* result) { } } // end namespace -#if RUY_HAVE_CPUINFO +#ifdef RUY_HAVE_CPUINFO CpuInfo::~CpuInfo() { if (init_status_ == InitStatus::kInitialized) { @@ -115,7 +113,7 @@ bool CpuInfo::AvxVnni() { return EnsureInitialized() && cpuinfo_has_x86_avx512vnni(); } -#else // not RUY_HAVE_CPUINFO +#else // not defined RUY_HAVE_CPUINFO CpuInfo::~CpuInfo() {} bool CpuInfo::EnsureInitialized() {