Skip to content

Commit 1bcd94c

Browse files
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>
1 parent 9df2f1f commit 1bcd94c

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

include/pybind11/detail/common.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@
9999
# endif
100100
#endif
101101

102+
// For CUDA, GCC7, GCC8:
103+
// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
104+
// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
105+
// However, the measured shared-library size saving when using noinline are only
106+
// 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel,
107+
// the default under pybind11/tests).
108+
#if !defined(PYBIND11_NOINLINE_FORCED) && \
109+
(defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
110+
# define PYBIND11_NOINLINE_DISABLED
111+
#endif
112+
102113
// The PYBIND11_NOINLINE macro is for function DEFINITIONS.
103114
// In contrast, FORWARD DECLARATIONS should never use this macro:
104115
// https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions

include/pybind11/pybind11.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010

1111
#pragma once
1212

13-
#if defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8))
14-
# pragma GCC diagnostic push
15-
# pragma GCC diagnostic ignored "-Wattributes"
16-
#endif
17-
1813
#include "attr.h"
1914
#include "gil.h"
2015
#include "options.h"
@@ -2383,7 +2378,3 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
23832378
#if defined(__GNUC__) && __GNUC__ == 7
23842379
# pragma GCC diagnostic pop // -Wnoexcept-type
23852380
#endif
2386-
2387-
#if defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8))
2388-
# pragma GCC diagnostic pop
2389-
#endif

0 commit comments

Comments
 (0)