From 1bcd94c481bba513c4c63a62b1f5da13f5e7978d Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 14 Aug 2021 07:41:27 -0700 Subject: [PATCH] Removing last remnants of pragma block at the top of pybind11.h (#3186) * Removing last remnants of pragma block at the top of pybind11.h, defaulting CUDA, GCC7, GCC8 to PYBIND11_NOINLINE_DISABLED, with the option to define PYBIND11_NOINLINE_FORCED. * Unique SOSIZE prefix to make it easier to extract the sosizes from the GitHub logs. * Commenting out PYBIND11_WERROR block, for noinline testing. * Undoing accidental change. * `#define PYBIND11_NOINLINE_FORCED` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * `#define PYBIND11_NOINLINE_DISABLED` * Going back to default (removing `#define PYBIND11_NOINLINE_DISABLED`). * `#define PYBIND11_NOINLINE_FORCED` * Undoing all changes releated to measuring sosizes. * Rollback of PR #3030 (Working around Centos 8 failure). * Disabling -Werror for GNU (experiment). * Commenting out the entire `if(PYBIND11_WERROR)` again (although that is not expected to make a difference, but who knows what I am overlooking). * Adding `-DCMAKE_BUILD_TYPE=Release` * Undoing change to tests/CMakeLists.txt (uncommenting `if(PYBIND11_WERROR)` block). * post `git rebase master -X theirs` fixups. * Adding measurements to comment for `PYBIND11_NOINLINE_FORCED`. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/pybind11/detail/common.h | 11 +++++++++++ include/pybind11/pybind11.h | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index cc24a52fd3..8daa33903e 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -99,6 +99,17 @@ # endif #endif +// For CUDA, GCC7, GCC8: +// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`. +// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`. +// However, the measured shared-library size saving when using noinline are only +// 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel, +// the default under pybind11/tests). +#if !defined(PYBIND11_NOINLINE_FORCED) && \ + (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8))) +# define PYBIND11_NOINLINE_DISABLED +#endif + // The PYBIND11_NOINLINE macro is for function DEFINITIONS. // In contrast, FORWARD DECLARATIONS should never use this macro: // https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 20df6a01fd..7b7b3ca71f 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -10,11 +10,6 @@ #pragma once -#if defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wattributes" -#endif - #include "attr.h" #include "gil.h" #include "options.h" @@ -2383,7 +2378,3 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) #if defined(__GNUC__) && __GNUC__ == 7 # pragma GCC diagnostic pop // -Wnoexcept-type #endif - -#if defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)) -# pragma GCC diagnostic pop -#endif