Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reapply size optimizations for clang & MSVC, LTO for Mac+Linux #1685

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions bindings/python/nanobind.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,46 @@ licenses(["notice"])

package(default_visibility = ["//visibility:public"])

filegroup(
name = "symboltable",
srcs = ["cmake/darwin-ld-cpython.sym"],
config_setting(
name = "msvc_compiler",
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
)

cc_library(
name = "nanobind",
srcs = glob([
"src/*.cpp"
"src/*.cpp",
]),
copts = ["-fexceptions"],
includes = ["include", "ext/robin_map/include"],
additional_linker_inputs = select({
"@platforms//os:macos": [":cmake/darwin-ld-cpython.sym"],
"//conditions:default": [],
}),
copts = select({
":msvc_compiler": [
"/EHsc", # exceptions
"/Os", # size optimizations
],
# these should work on both clang and gcc.
"//conditions:default": [
"-fexceptions",
"-flto",
"-Os",
],
}),
includes = [
"ext/robin_map/include",
"include",
],
linkopts = select({
"@platforms//os:macos": ["-Wl,@$(location :cmake/darwin-ld-cpython.sym)"],
"//conditions:default": [],
}),
textual_hdrs = glob(
[
"include/**/*.h",
"src/*.h",
"ext/robin_map/include/tsl/*.h",
],
),
linkopts = select({
"@platforms//os:macos": ["-Wl,@$(location :cmake/darwin-ld-cpython.sym)"],
"//conditions:default": [],
}),
additional_linker_inputs = select({
"@platforms//os:macos": [":cmake/darwin-ld-cpython.sym"],
"//conditions:default": [],
}),
deps = ["@python_headers"],
)
Loading