From 90f3635afd5d4079631460535bcd8213945b0349 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 12 Feb 2020 16:21:43 -0500 Subject: protobuf: Fix intel compiler failures. (#14916) --- .../repos/builtin/packages/protobuf/intel-v1.patch | 25 ++++++++++ .../repos/builtin/packages/protobuf/intel-v2.patch | 55 ++++++++++++++++++++++ .../builtin/packages/protobuf/intel_inline.patch | 25 ---------- .../repos/builtin/packages/protobuf/package.py | 5 +- 4 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 var/spack/repos/builtin/packages/protobuf/intel-v1.patch create mode 100644 var/spack/repos/builtin/packages/protobuf/intel-v2.patch delete mode 100644 var/spack/repos/builtin/packages/protobuf/intel_inline.patch diff --git a/var/spack/repos/builtin/packages/protobuf/intel-v1.patch b/var/spack/repos/builtin/packages/protobuf/intel-v1.patch new file mode 100644 index 0000000000..61f1334293 --- /dev/null +++ b/var/spack/repos/builtin/packages/protobuf/intel-v1.patch @@ -0,0 +1,25 @@ +diff -Naur src_a/google/protobuf/stubs/port.h src_b/google/protobuf/stubs/port.h +--- a/src/google/protobuf/stubs/port.h 2017-08-24 18:17:47.149533997 -0700 ++++ b/src/google/protobuf/stubs/port.h 2017-08-24 22:13:12.907241538 -0700 +@@ -167,7 +167,9 @@ + // is not right for you. + + #ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE +-#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) ++#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER > 1700) ++#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) ++#elif defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + // For functions we want to force inline. + // Introduced in gcc 3.1. + #define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) +@@ -178,7 +180,9 @@ + #endif + + #ifndef GOOGLE_ATTRIBUTE_NOINLINE +-#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) ++#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER > 1700) ++#define GOOGLE_ATTRIBUTE_NOINLINE ++#elif defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + // For functions we want to force not inline. + // Introduced in gcc 3.1. + #define GOOGLE_ATTRIBUTE_NOINLINE __attribute__ ((noinline)) diff --git a/var/spack/repos/builtin/packages/protobuf/intel-v2.patch b/var/spack/repos/builtin/packages/protobuf/intel-v2.patch new file mode 100644 index 0000000000..4a3eb77339 --- /dev/null +++ b/var/spack/repos/builtin/packages/protobuf/intel-v2.patch @@ -0,0 +1,55 @@ +From 22f4f5422eddaac94750b268b7e6e305bd9cce5b Mon Sep 17 00:00:00 2001 +From: Chuck Atkins +Date: Tue, 11 Feb 2020 10:21:44 -0500 +Subject: [PATCH 1/2] Intel compiler: ifdef out an incorrectly evaluated is_pod + type trait + +--- + src/google/protobuf/arena.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h +index d73b53c79f..3ecfe23c09 100644 +--- a/src/google/protobuf/arena.h ++++ b/src/google/protobuf/arena.h +@@ -338,8 +338,10 @@ class PROTOBUF_EXPORT alignas(8) Arena final { + template + PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena, + size_t num_elements) { ++#ifndef __INTEL_COMPILER // icc mis-evaluates some types as non-pod + static_assert(std::is_pod::value, + "CreateArray requires a trivially constructible type"); ++#endif + static_assert(std::is_trivially_destructible::value, + "CreateArray requires a trivially destructible type"); + GOOGLE_CHECK_LE(num_elements, std::numeric_limits::max() / sizeof(T)) + +From 9c2c9861d5490801503b51936d00320bba68d465 Mon Sep 17 00:00:00 2001 +From: Chuck Atkins +Date: Tue, 11 Feb 2020 10:22:38 -0500 +Subject: [PATCH 2/2] Intel compiler: silence noisy warning for incorrectly + evaluated inlining + +--- + cmake/CMakeLists.txt | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt +index 8e5e68073b..849679995a 100644 +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -28,6 +28,14 @@ else() + set(CMAKE_CXX_EXTENSIONS OFF) + endif() + ++# The Intel compiler isn't able to deal with noinline member functions of ++# template classses defined in headers. As such it spams the output with ++# warning #2196: routine is both "inline" and "noinline" ++# This silences that warning. ++if (CMAKE_CXX_COMPILER_ID MATCHES Intel) ++ string(APPEND CMAKE_CXX_FLAGS " -diag-disable=2196") ++endif() ++ + # Options + option(protobuf_BUILD_TESTS "Build tests" ON) + option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF) diff --git a/var/spack/repos/builtin/packages/protobuf/intel_inline.patch b/var/spack/repos/builtin/packages/protobuf/intel_inline.patch deleted file mode 100644 index 61f1334293..0000000000 --- a/var/spack/repos/builtin/packages/protobuf/intel_inline.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff -Naur src_a/google/protobuf/stubs/port.h src_b/google/protobuf/stubs/port.h ---- a/src/google/protobuf/stubs/port.h 2017-08-24 18:17:47.149533997 -0700 -+++ b/src/google/protobuf/stubs/port.h 2017-08-24 22:13:12.907241538 -0700 -@@ -167,7 +167,9 @@ - // is not right for you. - - #ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE --#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -+#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER > 1700) -+#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) -+#elif defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) - // For functions we want to force inline. - // Introduced in gcc 3.1. - #define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) -@@ -178,7 +180,9 @@ - #endif - - #ifndef GOOGLE_ATTRIBUTE_NOINLINE --#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -+#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER > 1700) -+#define GOOGLE_ATTRIBUTE_NOINLINE -+#elif defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) - // For functions we want to force not inline. - // Introduced in gcc 3.1. - #define GOOGLE_ATTRIBUTE_NOINLINE __attribute__ ((noinline)) diff --git a/var/spack/repos/builtin/packages/protobuf/package.py b/var/spack/repos/builtin/packages/protobuf/package.py index 513d5653b4..0923d3a961 100644 --- a/var/spack/repos/builtin/packages/protobuf/package.py +++ b/var/spack/repos/builtin/packages/protobuf/package.py @@ -48,7 +48,10 @@ class Protobuf(CMakePackage): # first fixed in 3.4.0: https://github.com/google/protobuf/pull/3406 patch('pkgconfig.patch', when='@:3.3.2') - patch('intel_inline.patch', when='@3.2.0: %intel') + patch('intel-v1.patch', when='@3.2:@3.6 %intel') + + # See https://github.com/protocolbuffers/protobuf/pull/7197 + patch('intel-v2.patch', when='@3.7:@3.11.4 %intel') def fetch_remote_versions(self): """Ignore additional source artifacts uploaded with releases, -- cgit v1.2.3-70-g09d2