Skip to content

Commit d3c940c

Browse files
committed
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)
1 parent b7ef46a commit d3c940c

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

.github/install_bazel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if ! bazel version; then
55
fi
66
echo "Installing wget and downloading $arch Bazel binary from GitHub releases."
77
yum install -y wget
8-
wget "https://github.com/bazelbuild/bazel/releases/download/5.2.0/bazel-5.2.0-linux-$arch" -O /usr/local/bin/bazel
8+
wget "https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-linux-$arch" -O /usr/local/bin/bazel
99
chmod +x /usr/local/bin/bazel
1010
else
1111
# bazel is installed for the correct architecture

.github/workflows/wheels.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ jobs:
4646
platforms: all
4747

4848
- name: Build wheels on ${{ matrix.os }} using cibuildwheel
49-
uses: pypa/cibuildwheel@v2.11.4
49+
uses: pypa/cibuildwheel@v2.12.0
5050
env:
5151
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-*'
5252
CIBW_SKIP: "*-musllinux_*"
5353
CIBW_TEST_SKIP: "*-macosx_arm64"
54-
# TODO: Build ppc64le using some other trick
5554
CIBW_ARCHS_LINUX: x86_64 aarch64
5655
CIBW_ARCHS_MACOS: x86_64 arm64
5756
CIBW_ARCHS_WINDOWS: AMD64

bazel/benchmark_deps.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def benchmark_deps():
4848
git_repository(
4949
name = "nanobind",
5050
remote = "https://github.com/wjakob/nanobind.git",
51-
commit = "2894c92475ccfd38df31daf3f12f915bbd9d3a9d",
51+
commit = "947fbb071eca282e6350402c0a23800502a1644f",
5252
build_file = "@//bindings/python:nanobind.BUILD",
5353
recursive_init_submodules = True,
5454
)

bindings/python/google_benchmark/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ py_extension(
1515
copts = [
1616
"-fexceptions",
1717
"-fno-strict-aliasing",
18-
"-std=c++17",
1918
],
2019
features = [
2120
"-use_header_modules",

bindings/python/nanobind.BUILD

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
config_setting(
3+
name = "macos",
4+
constraint_values = ["@platforms//os:macos"],
5+
visibility = [":__subpackages__"],
6+
)
7+
18
cc_library(
29
name = "nanobind",
310
hdrs = glob(
@@ -30,11 +37,13 @@ cc_library(
3037
],
3138
copts = [
3239
"-fexceptions",
33-
"-std=c++17", # requires C++17
34-
"-Os", # size optimization option for nanobind
40+
"-Os", # size optimization
3541
"-flto", # enable LTO
3642
],
37-
linkopts = ["-undefined suppress", "-flat_namespace", "-flto"],
43+
linkopts = select({
44+
":macos": ["-undefined suppress", "-flat_namespace"],
45+
"//conditions:default": [],
46+
}),
3847
includes = ["include", "ext/robin_map/include"],
3948
deps = ["@python_headers"],
4049
visibility = ["//visibility:public"],

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def bazel_build(self, ext):
8888
ext.bazel_target,
8989
"--symlink_prefix=" + os.path.join(self.build_temp, "bazel-"),
9090
"--compilation_mode=" + ("dbg" if self.debug else "opt"),
91-
"--cxxopt=-std=c++17", # C++17
91+
"--cxxopt=-std=c++17", # required by nanobind
9292
]
9393

9494
if IS_WINDOWS:

0 commit comments

Comments
 (0)