Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB

"""C++ compile/link options for Protobuf libraries."""
COPTS = select({
"//build_defs:config_msvc": [
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4146", # unary minus operator applied to unsigned type
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
"/wd4307", # 'operator' : integral constant overflow
"/wd4309", # 'conversion' : truncation of constant value
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4355", # 'this' : used in base member initializer list
"/wd4506", # no definition for inline function 'function'
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4996", # The compiler encountered a deprecated declaration.
],
"//conditions:default": [
"-DHAVE_ZLIB",
"-Woverloaded-virtual",
"-Wno-sign-compare",
"-Wno-nonnull",
"-Werror",
],
})
# Android and MSVC builds do not need to link in a separate pthread library.
LINK_OPTS = select({
"//build_defs:config_android": [],
"//build_defs:config_android-stlport": [],
"//build_defs:config_android-libcpp": [],
"//build_defs:config_android-gnu-libstdcpp": [],
"//build_defs:config_android-default": [],
"//build_defs:config_msvc": [
# Suppress linker warnings about files with no symbols defined.
"-ignore:4221",
],
Fix protoc_nowkt linking on MacOS (#12320) Depending on how the local cc toolchain is setup on macos, the core foundation framework might not be available while linking protoc_nowkt. This results in a few _CF symbols being interpreted as dynamic load and is set to the binary's flat-namespace, causing runtime errors during susequent actions such as gen_wkt_cc_sources. ```bash > otool -dyld_info bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/protoc_nowkt | grep '_CF' __DATA_CONST __got 0x10035C038 0x8010000000000007 bind 0x0 flat-namespace _CFRelease __DATA_CONST __got 0x10035C040 0x8010000000000008 bind 0x0 flat-namespace _CFStringGetCString __DATA_CONST __got 0x10035C048 0x8010000000000009 bind 0x0 flat-namespace _CFStringGetLength __DATA_CONST __got 0x10035C050 0x801000000000000A bind 0x0 flat-namespace _CFStringGetMaximumSizeForEncoding __DATA_CONST __got 0x10035C058 0x801000000000000B bind 0x0 flat-namespace _CFTimeZoneCopyDefault __DATA_CONST __got 0x10035C060 0x801000000000000C bind 0x0 flat-namespace _CFTimeZoneGetName ``` Tell the linker to use CoreFoundation framework explicitly fixes this issue. ```bash > otool -dyld_info bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/protoc_nowkt | grep '_CF' __DATA_CONST __got 0x10035C038 0x8010000000000007 bind 0x0 CoreFoundation _CFRelease __DATA_CONST __got 0x10035C040 0x8010000000000008 bind 0x0 CoreFoundation _CFStringGetCString __DATA_CONST __got 0x10035C048 0x8010000000000009 bind 0x0 CoreFoundation _CFStringGetLength __DATA_CONST __got 0x10035C050 0x801000000000000A bind 0x0 CoreFoundation _CFStringGetMaximumSizeForEncoding __DATA_CONST __got 0x10035C058 0x801000000000000B bind 0x0 CoreFoundation _CFTimeZoneCopyDefault __DATA_CONST __got 0x10035C060 0x801000000000000C bind 0x0 CoreFoundation _CFTimeZoneGetName ``` closes #12173 Closes #12320 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12320 from sluongng:main 1416168f128b05d72692a3b451dd96c2b3c1cc49 PiperOrigin-RevId: 526830008
2 years ago
"@platforms//os:macos": [
"-lpthread",
"-lm",
"-framework CoreFoundation",
],
"//conditions:default": [
"-lpthread",
"-lm",
],
})