Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove weak symbols from CEL #968

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

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
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
113 changes: 15 additions & 98 deletions common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ cc_library(
"values/*_test.cc",
],
) + [
"legacy_value.cc",
"list_type_reflector.cc",
"map_type_reflector.cc",
"type_reflector.cc",
Expand All @@ -615,6 +616,7 @@ cc_library(
"values/*_test.h",
],
) + [
"legacy_value.h",
"type_reflector.h",
"value.h",
"value_factory.h",
Expand All @@ -626,6 +628,7 @@ cc_library(
":any",
":casting",
":json",
":kind",
":memory",
":native_type",
":optional_ref",
Expand All @@ -638,11 +641,20 @@ cc_library(
"//common/internal:data_interface",
"//common/internal:reference_count",
"//common/internal:shared_byte_string",
"//eval/internal:cel_value_equal",
"//eval/public:cel_value",
"//eval/public:message_wrapper",
"//eval/public/containers:container_backed_list_impl",
"//eval/public/containers:container_backed_map_impl",
"//eval/public/structs:legacy_type_adapter",
"//eval/public/structs:legacy_type_info_apis",
"//eval/public/structs:proto_message_type_adapter",
"//extensions/protobuf:memory_manager",
"//extensions/protobuf/internal:map_reflection",
"//extensions/protobuf/internal:qualify",
"//extensions/protobuf/internal:struct_lite",
"//internal:casts",
"//internal:deserialize",
"//internal:dynamic_loader",
"//internal:json",
"//internal:message_equality",
"//internal:number",
Expand All @@ -655,7 +667,6 @@ cc_library(
"//internal:utf8",
"//internal:well_known_types",
"//runtime:runtime_options",
"@com_google_absl//absl/base",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:no_destructor",
"@com_google_absl//absl/base:nullability",
Expand All @@ -665,7 +676,6 @@ cc_library(
"@com_google_absl//absl/hash",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/log:die_if_null",
"@com_google_absl//absl/meta:type_traits",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
Expand Down Expand Up @@ -731,102 +741,9 @@ cc_library(
deps = ["//base/internal:unknown_set"],
)

# List of dynamic symbols we need for interop with google::api::expr::runtime::CelValue.
_DYNAMIC_SYMBOLS = [
"cel_common_internal_LegacyListValue_GetType",
"cel_common_internal_LegacyListValue_DebugString",
"cel_common_internal_LegacyListValue_GetSerializedSize",
"cel_common_internal_LegacyListValue_SerializeTo",
"cel_common_internal_LegacyListValue_ConvertToJsonArray",
"cel_common_internal_LegacyListValue_IsEmpty",
"cel_common_internal_LegacyListValue_Size",
"cel_common_internal_LegacyListValue_Get",
"cel_common_internal_LegacyListValue_ForEach",
"cel_common_internal_LegacyListValue_NewIterator",
"cel_common_internal_LegacyListValue_Contains",
"cel_common_internal_LegacyMapValue_GetType",
"cel_common_internal_LegacyMapValue_DebugString",
"cel_common_internal_LegacyMapValue_GetSerializedSize",
"cel_common_internal_LegacyMapValue_SerializeTo",
"cel_common_internal_LegacyMapValue_ConvertToJsonObject",
"cel_common_internal_LegacyMapValue_IsEmpty",
"cel_common_internal_LegacyMapValue_Size",
"cel_common_internal_LegacyMapValue_Find",
"cel_common_internal_LegacyMapValue_Get",
"cel_common_internal_LegacyMapValue_Has",
"cel_common_internal_LegacyMapValue_ListKeys",
"cel_common_internal_LegacyMapValue_ForEach",
"cel_common_internal_LegacyMapValue_NewIterator",
"cel_common_internal_LegacyStructValue_DebugString",
"cel_common_internal_LegacyStructValue_GetSerializedSize",
"cel_common_internal_LegacyStructValue_SerializeTo",
"cel_common_internal_LegacyStructValue_GetType",
"cel_common_internal_LegacyStructValue_GetTypeName",
"cel_common_internal_LegacyStructValue_ConvertToJsonObject",
"cel_common_internal_LegacyStructValue_GetFieldByName",
"cel_common_internal_LegacyStructValue_GetFieldByNumber",
"cel_common_internal_LegacyStructValue_HasFieldByName",
"cel_common_internal_LegacyStructValue_HasFieldByNumber",
"cel_common_internal_LegacyStructValue_Equal",
"cel_common_internal_LegacyStructValue_IsZeroValue",
"cel_common_internal_LegacyStructValue_ForEachField",
"cel_common_internal_LegacyStructValue_Qualify",
"cel_common_internal_LegacyTypeReflector_NewListValueBuilder",
"cel_common_internal_LegacyTypeReflector_NewMapValueBuilder",
]

cc_library(
alias(
name = "legacy_value",
srcs = ["legacy_value.cc"],
hdrs = ["legacy_value.h"],
# For potential compatibility with Windows and macOS, we avoid using weak symbols. Instead we
# use the dynamic linker to find the symbols at runtime. This only works if they are exported as
# dynamic symbols. When static linking, our symbols are not exported as dynamic by default. We
# workaround this by explicitly passing our symbols to the linker for exporting.
linkopts = ["-Wl,--export-dynamic-symbol=%s" % dynamic_symbol for dynamic_symbol in _DYNAMIC_SYMBOLS],
deps = [
":casting",
":json",
":kind",
":native_type",
":type",
":unknown",
":value",
":value_kind",
"//base:attributes",
"//base/internal:message_wrapper",
"//common/internal:arena_string",
"//eval/internal:cel_value_equal",
"//eval/public:cel_value",
"//eval/public:message_wrapper",
"//eval/public/containers:container_backed_list_impl",
"//eval/public/containers:container_backed_map_impl",
"//eval/public/structs:legacy_type_adapter",
"//eval/public/structs:legacy_type_info_apis",
"//extensions/protobuf:memory_manager",
"//extensions/protobuf/internal:legacy_value",
"//extensions/protobuf/internal:struct_lite",
"//internal:casts",
"//internal:status_macros",
"//internal:time",
"//runtime:runtime_options",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/functional:overload",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:cord",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
"@com_google_absl//absl/types:variant",
"@com_google_protobuf//:protobuf",
],
alwayslink = True,
actual = ":value",
)

# Due to how dynamic linking works for legacy types, we need this to be separate from the standard
Expand Down
Loading