mirror of
https://github.com/google/benchmark.git
synced 2025-02-23 09:40:27 +08:00
* Reapply size optimization for clang, equivalent options for MSVC Working towards cross-platform optimal nanobind building configurations. * Add LTO back to non-Windows builds The Windows case (the option name is "/GL") is more complicated, since there, the compiler options also need to be passed to the linker if LTO is enabled. Since we are gating the linker options on platform at the moment instead of compiler, we need to implement a Bazel boolean flag for the case "Platform == MacOS && Compiler == AnyOf(gcc, clang)".
48 lines
1.1 KiB
Plaintext
48 lines
1.1 KiB
Plaintext
licenses(["notice"])
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
config_setting(
|
|
name = "msvc_compiler",
|
|
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
|
|
)
|
|
|
|
cc_library(
|
|
name = "nanobind",
|
|
srcs = glob([
|
|
"src/*.cpp",
|
|
]),
|
|
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",
|
|
],
|
|
),
|
|
deps = ["@python_headers"],
|
|
)
|