mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
1. Add current latest version (opentelemetry-cpp version v1.14.2) to PyTorch library. Steps: ``` $cd pytorch $git submodule add https://github.com/open-telemetry/opentelemetry-cpp.git third_party/opentelemetry-cpp $cd third_party/opentelemetry-cpp $git checkout v1.14.2 $git add third_party/opentelemetry-cpp .gitmodules $git commit ``` Expected change in checkout size: ``` (/home/cpio/local/a/pytorch-env) [cpio@devvm17556.vll0 ~/local/pytorch (gh/c-p-i-o/otel)]$ git count-objects -vH count: 654 size: 3.59 MiB in-pack: 1229701 packs: 17 size-pack: 1.17 GiB prune-packable: 76 garbage: 0 size-garbage: 0 bytes ``` 2. TODO - [x] Figure out how dynamic linking works. App builders will somehow need to `target_include` opentelemetry-cpp at runtime. - [ ] Examples on how to use opentelemetry + pytorch - [ ] Tests + documentation (e.g. using null opentelemetry implementation). Pull Request resolved: https://github.com/pytorch/pytorch/pull/122999 Approved by: https://github.com/ezyang
72 lines
2.0 KiB
Plaintext
72 lines
2.0 KiB
Plaintext
load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
bool_flag(
|
|
name = "with_abseil",
|
|
build_setting_default = False,
|
|
)
|
|
|
|
CPP_STDLIBS = [
|
|
"none",
|
|
"best",
|
|
"2014",
|
|
"2017",
|
|
"2020",
|
|
"2023",
|
|
]
|
|
|
|
string_flag(
|
|
name = "with_cxx_stdlib",
|
|
build_setting_default = "best",
|
|
values = CPP_STDLIBS,
|
|
)
|
|
|
|
cc_library(
|
|
name = "api",
|
|
hdrs = glob(["include/**/*.h"]),
|
|
defines = select({
|
|
":with_external_abseil": ["HAVE_ABSEIL"],
|
|
"//conditions:default": [],
|
|
}) + select({
|
|
":set_cxx_stdlib_none": [],
|
|
### automatic selection
|
|
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
|
|
# See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
|
|
":set_cxx_stdlib_best_and_msvc": ["OPENTELEMETRY_STL_VERSION=(_MSVC_LANG/100)"],
|
|
### manual selection
|
|
":set_cxx_stdlib_2014": ["OPENTELEMETRY_STL_VERSION=2014"],
|
|
":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"],
|
|
":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"],
|
|
":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"],
|
|
"//conditions:default": [],
|
|
}),
|
|
strip_include_prefix = "include",
|
|
tags = ["api"],
|
|
deps = select({
|
|
":with_external_abseil": [
|
|
"@com_google_absl//absl/base",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/types:variant",
|
|
],
|
|
"//conditions:default": [],
|
|
}),
|
|
)
|
|
|
|
config_setting(
|
|
name = "with_external_abseil",
|
|
flag_values = {":with_abseil": "true"},
|
|
)
|
|
|
|
[config_setting(
|
|
name = "set_cxx_stdlib_%s" % v,
|
|
flag_values = {":with_cxx_stdlib": v},
|
|
) for v in CPP_STDLIBS]
|
|
|
|
config_setting(
|
|
name = "set_cxx_stdlib_best_and_msvc",
|
|
constraint_values = ["@bazel_tools//tools/cpp:msvc"],
|
|
flag_values = {":with_cxx_stdlib": "best"},
|
|
)
|