Skip to content

Commit

Permalink
Removing last remnants of pragma block at the top of pybind11.h (#3186)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Ralf W. Grosse-Kunstleve and pre-commit-ci[bot] authored Aug 14, 2021
1 parent 9df2f1f commit 1bcd94c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 11 additions & 0 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

0 comments on commit 1bcd94c

Please sign in to comment.