Bundle binary footprint optimization and symbol visibility.
I've implemented a C++ bundle named json_config, which depends on https://github.com/nlohmann/json and https://github.com/pboettch/json-schema-validator. It turns out that building using common settings will produce a 2.4M binary:
CFLAGS=-fdata-sections -ffunction-sections -Os
CXXFLAGS=-fdata-sections -ffunction-sections -Os
LDFLAGS=-Wl,--gc-sections
Further inspection reveals that a lot of C++ template instantiation unused is built into the final binary. Linking using the following linker script eliminated all these unused code from the binary, resulting in 300K binary, which is a huge win:
{
global:
celix_bundleActivator_create;
celix_bundleActivator_start;
celix_bundleActivator_stop;
celix_bundleActivator_destroy;
local: *;
};
I noticed that the original API design took symbol visibility into account, but the new celix API did not: https://github.com/apache/celix/blob/d8b1f33635d735de5f5ba2c986a37338803bfec5/libs/framework/include/framework.h#L34
Shall we add symbol visibility control back to the whole Celix API? This is important especially for C++ bundle.