[llvm] [bazel] Make nanobind link on macOS (PR #190687)
Keith Smiley via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 14:13:29 PDT 2026
https://github.com/keith created https://github.com/llvm/llvm-project/pull/190687
Previously the mlir libraries that are marked as shared didn't link on
macOS since undefined symbols error by default. This uses nanobind's
list of acceptable undefined python symbols to make these link.
>From 868c3f65be14c699fa9346a0b2edca34e4176512 Mon Sep 17 00:00:00 2001
From: Keith Smiley <keithbsmiley at gmail.com>
Date: Mon, 6 Apr 2026 14:12:00 -0700
Subject: [PATCH] [bazel] Make nanobind link on macOS
Previously the mlir libraries that are marked as shared didn't link on
macOS since undefined symbols error by default. This uses nanobind's
list of acceptable undefined python symbols to make these link.
---
utils/bazel/third_party_build/nanobind.BUILD | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/utils/bazel/third_party_build/nanobind.BUILD b/utils/bazel/third_party_build/nanobind.BUILD
index 41296d9034fda..e8de0bd07a325 100644
--- a/utils/bazel/third_party_build/nanobind.BUILD
+++ b/utils/bazel/third_party_build/nanobind.BUILD
@@ -8,11 +8,21 @@ cc_library(
],
exclude = ["src/nb_combined.cpp"],
),
+ additional_linker_inputs = select({
+ "@platforms//os:macos": [":cmake/darwin-ld-cpython.sym"],
+ "//conditions:default": [],
+ }),
defines = [
"NB_BUILD=1",
"NB_SHARED=1",
],
includes = ["include"],
+ linkopts = select({
+ "@platforms//os:macos": [
+ "-Wl,@$(location :cmake/darwin-ld-cpython.sym)",
+ ],
+ "//conditions:default": [],
+ }),
textual_hdrs = glob(
[
"include/**/*.h",
More information about the llvm-commits
mailing list