mirror of
https://github.com/google/benchmark.git
synced 2024-12-28 05:20:14 +08:00
b219e18b91
* Add LTO builds on Windows+MSVC Gates the MSVC switches behind an `@bazel_skylib:selects` statement. This is a first experiment from best guesses and studying the MSVC docs. * Fix misleading inline comment
60 lines
1.4 KiB
Plaintext
60 lines
1.4 KiB
Plaintext
licenses(["notice"])
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
|
|
|
config_setting(
|
|
name = "msvc_compiler",
|
|
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
|
|
)
|
|
|
|
selects.config_setting_group(
|
|
name = "winplusmsvc",
|
|
match_all = [
|
|
"@platforms//os:windows",
|
|
":msvc_compiler",
|
|
],
|
|
)
|
|
|
|
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
|
|
"/GL", # LTO / whole program optimization
|
|
],
|
|
# these should work on both clang and gcc.
|
|
"//conditions:default": [
|
|
"-fexceptions",
|
|
"-flto",
|
|
"-Os",
|
|
],
|
|
}),
|
|
includes = [
|
|
"ext/robin_map/include",
|
|
"include",
|
|
],
|
|
linkopts = select({
|
|
":winplusmsvc": ["/LTGC"], # Windows + MSVC.
|
|
"@platforms//os:macos": ["-Wl,@$(location :cmake/darwin-ld-cpython.sym)"], # Apple.
|
|
"//conditions:default": [],
|
|
}),
|
|
textual_hdrs = glob(
|
|
[
|
|
"include/**/*.h",
|
|
"src/*.h",
|
|
"ext/robin_map/include/tsl/*.h",
|
|
],
|
|
),
|
|
deps = ["@python_headers"],
|
|
)
|