forked from google/benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch bindings implementation to
nanobind
(google#1526)
* End support for Python 3.7, update cibuildwheel and publish actions Removes Python 3.7 from the support matrix, since it does not support PEP590 vectorcalls. Bumps the `cibuildwheel` and `pypa-publish` actions to their latest available versions respectively. * Add nanobind to the Bazel dependencies, add a BUILD file The build file builds nanobind as a static `cc_library`. Currently, the git SHA points to HEAD, since some necessary features have not been included in a release yet. * Delete pybind11 BUILD file * Switch bindings implementation to nanobind Switches over the binding tool to `nanobind` from `pybind11`. Most changes in the build setup itself were drop-in replacements of existing code changed to nanobind names, no new concepts needed to be implemented. Sets the minimum required macOS to 10.14 for full C++17 support. Also, to avoid ambiguities in Bazel, build for macOS 11 on Mac ARM64. * Use Bazel select for linker options Guards against unknown linker option errors by selecting required linker options for nanobind only on macOS, where they are relevant. Other changes: * Bump cibuildwheel action to v2.12.0 * Bump Bazel for aarch64 linux wheels to 6.0.0 * Remove C++17 flag from build files since it is present in setup.py `bazel build` command * Bump nanobind commit to current HEAD (TBD: Bump to next stable release) * Unbreak Windows builds of nanobind-based bindings Guards compiler options behind a new `select` macro choosing between MSVC and not MSVC. Other changes: * Inject the proper C++17 standard cxxopt in the `setup.py` build command. * Bump nanobind to current HEAD. * Make `macos` a benchmark-wide condition, with public visibility to allow its use in the nanobind BUILD file. * Fall back to `nb::implicitly_convertible` for Counter construction Since `benchmark::Counter` only has a constructor for `double`, the nanobind `nb::init_implicit` template cannot be used. Therefore, to support implicit construction from ints, we fall back to the `nb::implicitly_convertible` template instead.
- Loading branch information
1 parent
f59d021
commit 80a3c5e
Showing
10 changed files
with
154 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
config_setting( | ||
name = "msvc_compiler", | ||
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"}, | ||
) | ||
|
||
cc_library( | ||
name = "nanobind", | ||
hdrs = glob( | ||
include = [ | ||
"include/nanobind/*.h", | ||
"include/nanobind/stl/*.h", | ||
"include/nanobind/detail/*.h", | ||
], | ||
exclude = [], | ||
), | ||
srcs = [ | ||
"include/nanobind/stl/detail/nb_dict.h", | ||
"include/nanobind/stl/detail/nb_list.h", | ||
"include/nanobind/stl/detail/traits.h", | ||
"ext/robin_map/include/tsl/robin_map.h", | ||
"ext/robin_map/include/tsl/robin_hash.h", | ||
"ext/robin_map/include/tsl/robin_growth_policy.h", | ||
"ext/robin_map/include/tsl/robin_set.h", | ||
"src/buffer.h", | ||
"src/common.cpp", | ||
"src/error.cpp", | ||
"src/implicit.cpp", | ||
"src/nb_enum.cpp", | ||
"src/nb_func.cpp", | ||
"src/nb_internals.cpp", | ||
"src/nb_internals.h", | ||
"src/nb_type.cpp", | ||
"src/tensor.cpp", | ||
"src/trampoline.cpp", | ||
], | ||
copts = select({ | ||
":msvc_compiler": [], | ||
"//conditions:default": [ | ||
"-fexceptions", | ||
"-Os", # size optimization | ||
"-flto", # enable LTO | ||
], | ||
}), | ||
linkopts = select({ | ||
"@com_github_google_benchmark//:macos": ["-undefined suppress", "-flat_namespace"], | ||
"//conditions:default": [], | ||
}), | ||
includes = ["include", "ext/robin_map/include"], | ||
deps = ["@python_headers"], | ||
visibility = ["//visibility:public"], | ||
) |
Oops, something went wrong.