From d589d7e01878cca6954823945acddbaa6dc75f2d Mon Sep 17 00:00:00 2001 From: Andri Saar Date: Tue, 13 Feb 2024 14:36:48 +0000 Subject: [PATCH] Reduce the number of exported symbols from the native lookup library --- cc/native_sdk/BUILD | 2 ++ cc/native_sdk/native_sdk.h | 2 +- cc/native_sdk/symbols.map.ld | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 cc/native_sdk/symbols.map.ld diff --git a/cc/native_sdk/BUILD b/cc/native_sdk/BUILD index a6bd2afcbc8..a8835f2b27f 100644 --- a/cc/native_sdk/BUILD +++ b/cc/native_sdk/BUILD @@ -36,8 +36,10 @@ cc_library( cc_binary( name = "key_value_lookup", srcs = ["key_value_lookup.cc"], + linkopts = ["-Wl,--version-script,$(location symbols.map.ld)"], linkshared = True, deps = [ + "symbols.map.ld", ":native_sdk", "@com_google_absl//absl/log:check", ], diff --git a/cc/native_sdk/native_sdk.h b/cc/native_sdk/native_sdk.h index 2d88be56193..f98b622a595 100644 --- a/cc/native_sdk/native_sdk.h +++ b/cc/native_sdk/native_sdk.h @@ -26,7 +26,7 @@ // We call oak_main without arguments, and oak_main then calls read_request, // processes the request, and then calls write_response. This makes the API // compatible with Oak Functions. -#define OAK_MAIN void oak_main() +#define OAK_MAIN extern "C" void oak_main() namespace oak::functions::sdk { diff --git a/cc/native_sdk/symbols.map.ld b/cc/native_sdk/symbols.map.ld new file mode 100644 index 00000000000..c67a82a81d7 --- /dev/null +++ b/cc/native_sdk/symbols.map.ld @@ -0,0 +1,7 @@ +{ + global: + register_callbacks; + oak_main; + local: + *; +};