From c796c29bd3fc2de29eccb75a9144fee5fc7533d4 Mon Sep 17 00:00:00 2001 From: yejianwu Date: Thu, 5 Jul 2018 14:58:36 +0800 Subject: [PATCH] fix protobuf version conflict with os (remove unnecessary symbols) --- mace/mace_version_script.lds | 12 +++++++----- mace/public/mace.h | 5 +++-- mace/public/mace_runtime.h | 9 ++++++++- mace/tools/git/gen_version_source.sh | 1 + tools/bazel.rc | 1 + 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mace/mace_version_script.lds b/mace/mace_version_script.lds index 270952dc..db9797ee 100644 --- a/mace/mace_version_script.lds +++ b/mace/mace_version_script.lds @@ -2,13 +2,15 @@ mace { global: *MaceTensor*; *MaceEngine*; - *MaceVersion*; - *SetOpenMPThreadPolicy*; - *SetGPUHints*; - *SetOpenCLBinaryPaths*; + *CreateMaceEngineFromProto*; *FileStorageFactory*; *SetKVStorageFactory*; - *CreateMaceEngineFromProto*; + *SetOpenCLBinaryPaths*; + *SetGPUHints*; + *SetOpenMPThreadPolicy*; + *SetOpenMPThreadAffinity*; + *GetBigLittleCoreIDs*; + *MaceVersion*; local: *; }; diff --git a/mace/public/mace.h b/mace/public/mace.h index 87344410..9a35da5b 100644 --- a/mace/public/mace.h +++ b/mace/public/mace.h @@ -74,7 +74,7 @@ enum MaceStatus { } // MACE input/output tensor -class MaceTensor { +class __attribute__((visibility("default"))) MaceTensor { public: // shape - the shape of the tensor, with size n // data - the buffer of the tensor, must not be null with size equals @@ -97,7 +97,7 @@ class MaceTensor { std::unique_ptr impl_; }; -class MaceEngine { +class __attribute__((visibility("default"))) MaceEngine { public: explicit MaceEngine(DeviceType device_type); ~MaceEngine(); @@ -127,6 +127,7 @@ class MaceEngine { MaceEngine &operator=(const MaceEngine &) = delete; }; +__attribute__((visibility("default"))) MaceStatus CreateMaceEngineFromProto( const std::vector &model_pb, const std::string &model_data_file, diff --git a/mace/public/mace_runtime.h b/mace/public/mace_runtime.h index 38f8a62a..7f8b0576 100644 --- a/mace/public/mace_runtime.h +++ b/mace/public/mace_runtime.h @@ -63,7 +63,8 @@ class KVStorageFactory { virtual std::unique_ptr CreateStorage(const std::string &name) = 0; }; -class FileStorageFactory : public KVStorageFactory { +class __attribute__((visibility("default"))) FileStorageFactory + : public KVStorageFactory { public: explicit FileStorageFactory(const std::string &path); @@ -77,6 +78,7 @@ class FileStorageFactory : public KVStorageFactory { }; // Set KV store factory used as OpenCL cache. (Call Once) +__attribute__((visibility("default"))) void SetKVStorageFactory(std::shared_ptr storage_factory); // Just call once. (Not thread-safe) @@ -85,11 +87,13 @@ void SetKVStorageFactory(std::shared_ptr storage_factory); // Using OpenCL binary will speed up the initialization. // OpenCL binary is corresponding to the OpenCL Driver version, // you should update the binary when OpenCL Driver changed. +__attribute__((visibility("default"))) void SetOpenCLBinaryPaths(const std::vector &paths); // Set GPU hints, currently only supports Adreno GPU. // // Caution: this function may hurt performance if improper parameters provided. +__attribute__((visibility("default"))) void SetGPUHints(GPUPerfHint perf_hint, GPUPriorityHint priority_hint); // Set OpenMP threads number and affinity policy. @@ -109,6 +113,7 @@ void SetGPUHints(GPUPerfHint perf_hint, GPUPriorityHint priority_hint); // If successful, it returns MACE_SUCCESS and error if it can't reliabley // detect big-LITTLE cores (see GetBigLittleCoreIDs). In such cases, it's // suggested to use AFFINITY_NONE to use all cores. +__attribute__((visibility("default"))) MaceStatus SetOpenMPThreadPolicy(int num_threads_hint, CPUAffinityPolicy policy); @@ -119,6 +124,7 @@ MaceStatus SetOpenMPThreadPolicy(int num_threads_hint, // This function may not work well on some chips (e.g. MTK). Setting thread // affinity to offline cores may run very slow or unexpectedly. In such cases, // please use SetOpenMPThreadPolicy with default policy instead. +__attribute__((visibility("default"))) void SetOpenMPThreadAffinity(int num_threads, const std::vector &cpu_ids); // Get ARM big.LITTLE configuration. @@ -130,6 +136,7 @@ void SetOpenMPThreadAffinity(int num_threads, const std::vector &cpu_ids); // // If successful, it returns MACE_SUCCESS and error if it can't reliabley // detect the frequency of big-LITTLE cores (e.g. MTK). +__attribute__((visibility("default"))) MaceStatus GetBigLittleCoreIDs(std::vector *big_core_ids, std::vector *little_core_ids); diff --git a/mace/tools/git/gen_version_source.sh b/mace/tools/git/gen_version_source.sh index a3ef4daf..ac6b70c1 100644 --- a/mace/tools/git/gen_version_source.sh +++ b/mace/tools/git/gen_version_source.sh @@ -45,6 +45,7 @@ cat < ${OUTPUT_FILENAME} // This is a generated file. DO NOT EDIT! namespace mace { +__attribute__((visibility ("default"))) const char *MaceVersion() { return "MACEVER-${GIT_VERSION}" + 8; } } // namespace mace EOF diff --git a/tools/bazel.rc b/tools/bazel.rc index a0cb97d7..d5621063 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -22,6 +22,7 @@ build:optimization --linkopt=-Wl,--strip-all build:optimization --copt=-ffunction-sections build:optimization --copt=-fdata-sections build:optimization --linkopt=-Wl,--gc-sections +build:optimization --copt=-fvisibility=hidden # Address sanitizer build:asan --strip=never -- GitLab