From 2290c64967dbf10824cbe8f20d45eca2836813a7 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Wed, 27 Feb 2019 22:18:12 +0000 Subject: [PATCH 1/2] Fix hwloc build for non x86 platforms Commit a6bf9c8476 yesterday triggered the building of hwloc in TensorFlow. While many platforms (windows, mac, android) were excluded from building hwloc, others like ppc64le and raspberry pi still tried to build hwloc. This fails because hwloc references x86 specific files. Instead of excluding those platforms from building with hwloc, lets add conditions to only include the x86 files during a build on the x86 platform. This might enable the other platforms to still take advantage of hwloc function. --- third_party/hwloc/BUILD.bazel | 10 +++++++--- third_party/hwloc/static-components.h | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/third_party/hwloc/BUILD.bazel b/third_party/hwloc/BUILD.bazel index 35e689acbb4..99f1dce6748 100644 --- a/third_party/hwloc/BUILD.bazel +++ b/third_party/hwloc/BUILD.bazel @@ -228,7 +228,6 @@ cc_library( "hwloc/topology-linux.c", "hwloc/topology-noos.c", "hwloc/topology-synthetic.c", - "hwloc/topology-x86.c", "hwloc/topology-xml.c", "hwloc/topology-xml-nolibxml.c", "hwloc/traversal.c", @@ -237,13 +236,18 @@ cc_library( "include/hwloc/shmem.h", "include/private/autogen/config.h", "include/private/components.h", - "include/private/cpuid-x86.h", "include/private/debug.h", "include/private/internal-components.h", "include/private/misc.h", "include/private/private.h", "include/private/xml.h", - ], + ] + select({ + "@org_tensorflow//tensorflow:linux_x86_64": [ + "hwloc/topology-x86.c", + "include/private/cpuid-x86.h", + ], + "//conditions:default": [] + }), hdrs = [ "include/hwloc.h", "include/hwloc/autogen/config.h", diff --git a/third_party/hwloc/static-components.h b/third_party/hwloc/static-components.h index 8cae42a9c1f..1b3336f31e4 100644 --- a/third_party/hwloc/static-components.h +++ b/third_party/hwloc/static-components.h @@ -21,6 +21,9 @@ static const struct hwloc_component* hwloc_static_components[] = { &hwloc_noos_component, &hwloc_xml_component, &hwloc_synthetic_component, &hwloc_xml_nolibxml_component, &hwloc_linux_component, &hwloc_linuxio_component, - &hwloc_x86_component, NULL}; +#ifdef PLATFORM_IS_X86 + &hwloc_x86_component, +#endif + NULL}; #endif // THIRD_PARTY_HWLOC_STATIC_COMPONENTS_H_ From 7c18a18a5f79a27f52f80921a7b1f666407da6ff Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Thu, 28 Feb 2019 17:48:27 +0000 Subject: [PATCH 2/2] Include all x86 defines macros for hwloc Copied from tensorflow/core/platform/platform.h#L59 Look for both gcc/clang and Visual Studio macros indicating we're compiling for an x86 device. --- third_party/hwloc/static-components.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/hwloc/static-components.h b/third_party/hwloc/static-components.h index 1b3336f31e4..8482356f30b 100644 --- a/third_party/hwloc/static-components.h +++ b/third_party/hwloc/static-components.h @@ -21,7 +21,8 @@ static const struct hwloc_component* hwloc_static_components[] = { &hwloc_noos_component, &hwloc_xml_component, &hwloc_synthetic_component, &hwloc_xml_nolibxml_component, &hwloc_linux_component, &hwloc_linuxio_component, -#ifdef PLATFORM_IS_X86 +#if defined(__x86_64__) || defined(__amd64__) || defined(_M_IX86) || \ +defined(_M_X64) &hwloc_x86_component, #endif NULL};