已合并
refactor: unify CXX11 ABI configuration #4540
yelongjian创建于 27 天前
refactor: unify CXX11 ABI configuration #4540
已合并
共 8 个文件变更+12-647
| @@ -13,9 +13,6 @@ include(cmake/fetch_cann_cmake.cmake) | |||
| 13 | project(CANN-GRAPH-ENGINE) | 13 | project(CANN-GRAPH-ENGINE) |
| 14 | 14 | ||
| 15 | init_cann_project() | 15 | init_cann_project() |
| 16 | -if(NOT DEFINED USE_CXX11_ABI) | ||
| 17 | - set(USE_CXX11_ABI 0) | ||
| 18 | -endif() | ||
| 19 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH}) | 16 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH}) |
| 20 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH}) | 17 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH}) |
| 21 | set(BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) | 18 | set(BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| @@ -80,7 +77,7 @@ cmake_print_variables(CMAKE_INSTALL_PREFIX) | |||
| 80 | cmake_print_variables(CMAKE_PREFIX_PATH) | 77 | cmake_print_variables(CMAKE_PREFIX_PATH) |
| 81 | cmake_print_variables(CMAKE_MODULE_PATH) | 78 | cmake_print_variables(CMAKE_MODULE_PATH) |
| 82 | cmake_print_variables(BUILD_COMPONENT) | 79 | cmake_print_variables(BUILD_COMPONENT) |
| 83 | -cmake_print_variables(ENABLE_BUILD_DEVICE USE_CXX11_ABI CMAKE_TOOLCHAIN_FILE) | 80 | +cmake_print_variables(ENABLE_BUILD_DEVICE CANN_CXX11_ABI CMAKE_TOOLCHAIN_FILE) |
| 84 | cmake_print_variables(CMAKE_CXX_COMPILER_ID) | 81 | cmake_print_variables(CMAKE_CXX_COMPILER_ID) |
| 85 | 82 | ||
| 86 | if(NOT ENABLE_BUILD_DEVICE) | 83 | if(NOT ENABLE_BUILD_DEVICE) |
| @@ -22,7 +22,6 @@ RULE_LAUNCH_ARG="" | |||
| 22 | # MDC build para | 22 | # MDC build para |
| 23 | ENABLE_BUILD_DEVICE=ON | 23 | ENABLE_BUILD_DEVICE=ON |
| 24 | ENABLE_MOD_EXT=OFF | 24 | ENABLE_MOD_EXT=OFF |
| 25 | -USE_CXX11_ABI=0 | ||
| 26 | CMAKE_TOOLCHAIN_FILE="" | 25 | CMAKE_TOOLCHAIN_FILE="" |
| 27 | MDC_BUILD_COMPONENT="" | 26 | MDC_BUILD_COMPONENT="" |
| 28 | CMAKE_TOOLCHAIN_PREFIX="${BASEPATH}/../cmake/toolchain" | 27 | CMAKE_TOOLCHAIN_PREFIX="${BASEPATH}/../cmake/toolchain" |
| @@ -135,11 +134,13 @@ parse_cmake_extra_args() { | |||
| 135 | ENABLE_MOD_EXT=ON | 134 | ENABLE_MOD_EXT=ON |
| 136 | fi | 135 | fi |
| 137 | 136 | ||
| 138 | - lower_abi=$(echo "$USE_CXX11_ABI" | tr '[:upper:]' '[:lower:]') | 137 | + if [[ -n "$USE_CXX11_ABI" ]]; then |
| 139 | - if [[ "$lower_abi" == "on" || "$USE_CXX11_ABI" == "1" ]]; then | 138 | + lower_abi=$(echo "$USE_CXX11_ABI" | tr '[:upper:]' '[:lower:]') |
| 140 | - USE_CXX11_ABI=1 | 139 | + if [[ "$lower_abi" == "on" || "$USE_CXX11_ABI" == "1" ]]; then |
| 141 | - elif [[ "$lower_abi" == "off" || "$USE_CXX11_ABI" == "0" ]]; then | 140 | + USE_CXX11_ABI=1 |
| 142 | - USE_CXX11_ABI=0 | 141 | + elif [[ "$lower_abi" == "off" || "$USE_CXX11_ABI" == "0" ]]; then |
| 142 | + USE_CXX11_ABI=0 | ||
| 143 | + fi | ||
| 143 | fi | 144 | fi |
| 144 | } | 145 | } |
| 145 | 146 | ||
| @@ -457,7 +458,7 @@ build_single_pkg() { | |||
| 457 | -D CUSTOM_SIGN_SCRIPT=${CUSTOM_SIGN_SCRIPT} \ | 458 | -D CUSTOM_SIGN_SCRIPT=${CUSTOM_SIGN_SCRIPT} \ |
| 458 | -D PACKAGE_TYPE=${PACKAGE_TYPE} \ | 459 | -D PACKAGE_TYPE=${PACKAGE_TYPE} \ |
| 459 | -D ENABLE_BUILD_DEVICE=${ENABLE_BUILD_DEVICE} \ | 460 | -D ENABLE_BUILD_DEVICE=${ENABLE_BUILD_DEVICE} \ |
| 460 | - -D USE_CXX11_ABI=${USE_CXX11_ABI} \ | 461 | + ${USE_CXX11_ABI:+-D USE_CXX11_ABI=${USE_CXX11_ABI}} \ |
| 461 | -D LLVM_PATH=${LLVM_PATH} \ | 462 | -D LLVM_PATH=${LLVM_PATH} \ |
| 462 | -D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \ | 463 | -D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \ |
| 463 | -D ENABLE_MOD_EXT=${ENABLE_MOD_EXT} \ | 464 | -D ENABLE_MOD_EXT=${ENABLE_MOD_EXT} \ |
| @@ -1,13 +1,5 @@ | |||
| 1 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | 1 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 2 | set(CMAKE_CXX_STANDARD 17) | 2 | set(CMAKE_CXX_STANDARD 17) |
| 3 | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -Wl,-z,now") | ||
| 4 | -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -Wl,-z,now") | ||
| 5 | - | ||
| 6 | -if(NOT MDC_COMPILE_RUNTIME) | ||
| 7 | - add_compile_options(-D_GLIBCXX_USE_CXX11_ABI=0) | ||
| 8 | -else() | ||
| 9 | - add_compile_options(-D_GLIBCXX_USE_CXX11_ABI=${USE_CXX11_ABI}) | ||
| 10 | -endif() | ||
| 11 | 3 | ||
| 12 | if (EXISTS "${CMAKE_SOURCE_DIR}/.dev_env") | 4 | if (EXISTS "${CMAKE_SOURCE_DIR}/.dev_env") |
| 13 | # 存在`.dev_env`文件说明是蓝区开发环境,并且调用了`prepare_dev_env.sh`完成了开发环境准备 | 5 | # 存在`.dev_env`文件说明是蓝区开发环境,并且调用了`prepare_dev_env.sh`完成了开发环境准备 |
| @@ -77,6 +77,7 @@ target_link_options(aihac_autofusion PRIVATE | |||
| 77 | 77 | ||
| 78 | if (ENABLE_OPEN_SRC) | 78 | if (ENABLE_OPEN_SRC) |
| 79 | target_link_libraries(aihac_autofusion PUBLIC | 79 | target_link_libraries(aihac_autofusion PUBLIC |
| 80 | + ge_intf_pub | ||
| 80 | graph | 81 | graph |
| 81 | unified_dlog | 82 | unified_dlog |
| 82 | atrace_share | 83 | atrace_share |
| @@ -93,6 +94,7 @@ if (ENABLE_OPEN_SRC) | |||
| 93 | ) | 94 | ) |
| 94 | else () | 95 | else () |
| 95 | target_link_libraries(aihac_autofusion PRIVATE | 96 | target_link_libraries(aihac_autofusion PRIVATE |
| 97 | + ge_intf_pub | ||
| 96 | graph | 98 | graph |
| 97 | unified_dlog | 99 | unified_dlog |
| 98 | atrace_share | 100 | atrace_share |
| @@ -31,14 +31,12 @@ if (NOT TARGET ge_autofuse_metadef_graph_protos_obj_af) | |||
| 31 | target_compile_definitions(ge_autofuse_metadef_graph_protos_obj_af PRIVATE | 31 | target_compile_definitions(ge_autofuse_metadef_graph_protos_obj_af PRIVATE |
| 32 | google=ascend_private | 32 | google=ascend_private |
| 33 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 | 33 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 |
| 34 | - _GLIBCXX_USE_CXX11_ABI=0 | ||
| 35 | ) | 34 | ) |
| 36 | target_compile_options(ge_autofuse_metadef_graph_protos_obj_af PRIVATE | 35 | target_compile_options(ge_autofuse_metadef_graph_protos_obj_af PRIVATE |
| 37 | - -fPIC | ||
| 38 | -O2 | 36 | -O2 |
| 39 | -fno-common | 37 | -fno-common |
| 40 | -Wextra | 38 | -Wextra |
| 41 | -Wfloat-equal | 39 | -Wfloat-equal |
| 42 | ) | 40 | ) |
| 43 | - target_link_libraries(ge_autofuse_metadef_graph_protos_obj_af PRIVATE ascend_protobuf) | 41 | + target_link_libraries(ge_autofuse_metadef_graph_protos_obj_af PRIVATE ascend_protobuf ge_intf_pub) |
| 44 | endif () | 42 | endif () |
| @@ -1,78 +0,0 @@ | |||
| 1 | -diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake | ||
| 2 | -index 3bd33ce..380e262 100644 | ||
| 3 | ---- a/CMake/AbseilHelpers.cmake | ||
| 4 | -+++ b/CMake/AbseilHelpers.cmake | ||
| 5 | - Cflags: -I\${includedir}${PC_CFLAGS}\n") | ||
| 6 | - ) | ||
| 7 | - | ||
| 8 | - elseif(_build_type STREQUAL "static" OR _build_type STREQUAL "shared") | ||
| 9 | -- add_library(${_NAME} "") | ||
| 10 | -+ if (ABSL_COMPILE_OBJ) | ||
| 11 | -+ add_library(${_NAME} OBJECT "") | ||
| 12 | -+ else() | ||
| 13 | -+ add_library(${_NAME} "") | ||
| 14 | -+ endif() | ||
| 15 | - target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS}) | ||
| 16 | - target_link_libraries(${_NAME} | ||
| 17 | - PUBLIC ${ABSL_CC_LIB_DEPS} | ||
| 18 | -diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| 19 | -index eef6626..c054264 100644 | ||
| 20 | ---- a/CMakeLists.txt | ||
| 21 | -+++ b/CMakeLists.txt | ||
| 22 | - | ||
| 23 | - # As of 2022-09-06, CMake 3.10 is the minimum supported version. | ||
| 24 | - cmake_minimum_required(VERSION 3.10) | ||
| 25 | - | ||
| 26 | -+# NOTICE: force using static libraries | ||
| 27 | -+set(BUILD_SHARED_LIBS OFF) | ||
| 28 | -+ | ||
| 29 | - # Compiler id for Apple Clang is now AppleClang. | ||
| 30 | - if (POLICY CMP0025) | ||
| 31 | - cmake_policy(SET CMP0025 NEW) | ||
| 32 | - if(ABSL_ENABLE_INSTALL) | ||
| 33 | - PATTERN "*.h" | ||
| 34 | - PATTERN "copts" EXCLUDE | ||
| 35 | - PATTERN "testdata" EXCLUDE | ||
| 36 | -+ PATTERN "options.h" EXCLUDE | ||
| 37 | - ) | ||
| 38 | - | ||
| 39 | - file(READ "absl/base/options.h" ABSL_INTERNAL_OPTIONS_H_CONTENTS) | ||
| 40 | -diff --git a/absl/base/options.h b/absl/base/options.h | ||
| 41 | -index f308e1b..09617e0 100644 | ||
| 42 | ---- a/absl/base/options.h | ||
| 43 | -+++ b/absl/base/options.h | ||
| 44 | - | ||
| 45 | - // allowed. | ||
| 46 | - | ||
| 47 | - #define ABSL_OPTION_USE_INLINE_NAMESPACE 1 | ||
| 48 | --#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20230802 | ||
| 49 | -+#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_ascend_private | ||
| 50 | - | ||
| 51 | - // ABSL_OPTION_HARDENED | ||
| 52 | - // | ||
| 53 | -diff --git a/absl/hash/internal/hash.cc b/absl/hash/internal/hash.cc | ||
| 54 | -index 11451e5..75886d3 100644 | ||
| 55 | ---- a/absl/hash/internal/hash.cc | ||
| 56 | -+++ b/absl/hash/internal/hash.cc | ||
| 57 | - uint64_t MixingHashState::CombineLargeContiguousImpl64( | ||
| 58 | - std::integral_constant<int, 8>{}); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | --ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed; | ||
| 62 | -+ABSL_CONST_INIT const void* const MixingHashState::kSeed = 0; | ||
| 63 | - | ||
| 64 | - // The salt array used by LowLevelHash. This array is NOT the mechanism used to | ||
| 65 | - // make absl::Hash non-deterministic between program invocations. See `Seed()` | ||
| 66 | -diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h | ||
| 67 | -index ef3f366..7714cdb 100644 | ||
| 68 | ---- a/absl/hash/internal/hash.h | ||
| 69 | -+++ b/absl/hash/internal/hash.h | ||
| 70 | - class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> { | ||
| 71 | - #if (!defined(__clang__) || __clang_major__ > 11) && \ | ||
| 72 | - (!defined(__apple_build_version__) || \ | ||
| 73 | - __apple_build_version__ >= 19558921) // Xcode 12 | ||
| 74 | -- return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(&kSeed)); | ||
| 75 | -+ return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(kSeed)); | ||
| 76 | - #else | ||
| 77 | - // Workaround the absence of | ||
| 78 | - // https://github.com/llvm/llvm-project/commit/bc15bf66dcca76cc06fe71fca35b74dc4d521021. | ||
| @@ -1,486 +0,0 @@ | |||
| 1 | -diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| 2 | -index 4137ce2..1d9e1ca 100644 | ||
| 3 | ---- a/CMakeLists.txt | ||
| 4 | -+++ b/CMakeLists.txt | ||
| 5 | - if (protobuf_BUILD_SHARED_LIBS) | ||
| 6 | - endif () | ||
| 7 | - | ||
| 8 | - # Version metadata | ||
| 9 | --set(protobuf_VERSION_STRING "4.25.1") | ||
| 10 | -+set(protobuf_VERSION_STRING "3.13.0") | ||
| 11 | - set(protobuf_DESCRIPTION "Protocol Buffers") | ||
| 12 | - set(protobuf_CONTACT "protobuf@googlegroups.com") | ||
| 13 | - | ||
| 14 | - message(STATUS "${protobuf_VERSION_PRERELEASE}") | ||
| 15 | - | ||
| 16 | - # Package version | ||
| 17 | - set(protobuf_VERSION | ||
| 18 | -- "${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") | ||
| 19 | -+ "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") | ||
| 20 | - | ||
| 21 | - if(protobuf_VERSION_PRERELEASE) | ||
| 22 | - set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}") | ||
| 23 | - if(protobuf_VERBOSE) | ||
| 24 | - message(STATUS "]") | ||
| 25 | - endif() | ||
| 26 | - | ||
| 27 | --file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map | ||
| 28 | --"{ | ||
| 29 | -- global: | ||
| 30 | -- main; | ||
| 31 | -- local: | ||
| 32 | -- *; | ||
| 33 | --};") | ||
| 34 | --# CheckLinkerFlag module available in CMake >=3.18. | ||
| 35 | --if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18) | ||
| 36 | -- include(CheckLinkerFlag) | ||
| 37 | -- check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT) | ||
| 38 | --else() | ||
| 39 | -- include(CheckCXXSourceCompiles) | ||
| 40 | -- set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) | ||
| 41 | -- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map) | ||
| 42 | -- check_cxx_source_compiles(" | ||
| 43 | -- int main() { | ||
| 44 | -- return 0; | ||
| 45 | -- } | ||
| 46 | -- " protobuf_HAVE_LD_VERSION_SCRIPT) | ||
| 47 | -- set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) | ||
| 48 | --endif() | ||
| 49 | --file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map) | ||
| 50 | -- | ||
| 51 | - find_package(Threads REQUIRED) | ||
| 52 | - | ||
| 53 | - # We can install dependencies from submodules if we're running | ||
| 54 | -diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake | ||
| 55 | -index b50fb89..82bbab7 100644 | ||
| 56 | ---- a/cmake/abseil-cpp.cmake | ||
| 57 | -+++ b/cmake/abseil-cpp.cmake | ||
| 58 | - else() | ||
| 59 | - absl::utility | ||
| 60 | - absl::variant | ||
| 61 | - ) | ||
| 62 | -+ if (NOT BUILD_SHARED_LIBS) | ||
| 63 | -+ set(protobuf_ABSL_USED_TARGETS_EXTEND | ||
| 64 | -+ absl::log_internal_check_op | ||
| 65 | -+ absl::leak_check | ||
| 66 | -+ absl::log_internal_conditions | ||
| 67 | -+ absl::log_internal_message | ||
| 68 | -+ absl::log_internal_nullguard | ||
| 69 | -+ absl::examine_stack | ||
| 70 | -+ absl::log_internal_format | ||
| 71 | -+ absl::log_internal_proto | ||
| 72 | -+ absl::log_internal_log_sink_set | ||
| 73 | -+ absl::log_sink | ||
| 74 | -+ absl::log_entry | ||
| 75 | -+ absl::flags_internal | ||
| 76 | -+ absl::flags_marshalling | ||
| 77 | -+ absl::flags_reflection | ||
| 78 | -+ absl::flags_config | ||
| 79 | -+ absl::flags_program_name | ||
| 80 | -+ absl::flags_private_handle_accessor | ||
| 81 | -+ absl::flags_commandlineflag | ||
| 82 | -+ absl::flags_commandlineflag_internal | ||
| 83 | -+ absl::log_globals | ||
| 84 | -+ absl::log_internal_globals | ||
| 85 | -+ absl::raw_hash_set | ||
| 86 | -+ absl::city | ||
| 87 | -+ absl::low_level_hash | ||
| 88 | -+ absl::hashtablez_sampler | ||
| 89 | -+ absl::cordz_info | ||
| 90 | -+ absl::cord_internal | ||
| 91 | -+ absl::cordz_functions | ||
| 92 | -+ absl::exponential_biased | ||
| 93 | -+ absl::cordz_handle | ||
| 94 | -+ absl::crc_cord_state | ||
| 95 | -+ absl::crc32c | ||
| 96 | -+ absl::crc_internal | ||
| 97 | -+ absl::crc_cpu_detect | ||
| 98 | -+ absl::bad_optional_access | ||
| 99 | -+ absl::str_format_internal | ||
| 100 | -+ absl::strerror | ||
| 101 | -+ absl::stacktrace | ||
| 102 | -+ absl::symbolize | ||
| 103 | -+ absl::debugging_internal | ||
| 104 | -+ absl::demangle_internal | ||
| 105 | -+ absl::graphcycles_internal | ||
| 106 | -+ absl::kernel_timeout_internal | ||
| 107 | -+ absl::malloc_internal | ||
| 108 | -+ absl::string_view | ||
| 109 | -+ absl::throw_delegate | ||
| 110 | -+ absl::strings_internal | ||
| 111 | -+ absl::spinlock_wait | ||
| 112 | -+ absl::int128 | ||
| 113 | -+ absl::civil_time | ||
| 114 | -+ absl::time_zone | ||
| 115 | -+ absl::bad_variant_access | ||
| 116 | -+ absl::raw_logging_internal | ||
| 117 | -+ ) | ||
| 118 | -+ list(APPEND protobuf_ABSL_USED_TARGETS ${protobuf_ABSL_USED_TARGETS_EXTEND}) | ||
| 119 | -+ endif () | ||
| 120 | - set(protobuf_ABSL_USED_TEST_TARGETS | ||
| 121 | - absl::scoped_mock_log | ||
| 122 | - ) | ||
| 123 | -diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc | ||
| 124 | -index bf9d0bb..0e4f450 100644 | ||
| 125 | ---- a/src/google/protobuf/arenastring.cc | ||
| 126 | -+++ b/src/google/protobuf/arenastring.cc | ||
| 127 | - | ||
| 128 | - | ||
| 129 | - #include "absl/log/absl_check.h" | ||
| 130 | - #include "absl/strings/string_view.h" | ||
| 131 | -+#include "absl/strings/escaping.h" | ||
| 132 | - #include "absl/synchronization/mutex.h" | ||
| 133 | - #include "google/protobuf/io/coded_stream.h" | ||
| 134 | - #include "google/protobuf/message_lite.h" | ||
| 135 | - void ArenaStringPtr::Set(absl::string_view value, Arena* arena) { | ||
| 136 | - old->assign("garbagedata"); | ||
| 137 | - } | ||
| 138 | - #else // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 139 | -- UnsafeMutablePointer()->assign(value.data(), value.length()); | ||
| 140 | -+ UnsafeMutablePointer()->assign(std::string(value.data(), value.length())); | ||
| 141 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 142 | - } | ||
| 143 | - } | ||
| 144 | - void ArenaStringPtr::ClearToDefault(const LazyString& default_value, | ||
| 145 | - } | ||
| 146 | - } | ||
| 147 | - | ||
| 148 | -+void ArenaStringPtr::Set(EmptyDefault, const std::string& value, Arena* arena) { | ||
| 149 | -+ Set(value, arena); | ||
| 150 | -+} | ||
| 151 | -+ | ||
| 152 | -+void ArenaStringPtr::Set(EmptyDefault, absl::string_view value, Arena* arena) { | ||
| 153 | -+ Set(value, arena); | ||
| 154 | -+} | ||
| 155 | -+ | ||
| 156 | -+void ArenaStringPtr::Set(EmptyDefault, std::string&& value, Arena* arena) { | ||
| 157 | -+ Set(value, arena); | ||
| 158 | -+} | ||
| 159 | -+ | ||
| 160 | -+void ArenaStringPtr::Set(EmptyDefault, const char* s, Arena* arena) { | ||
| 161 | -+ Set(s, arena); | ||
| 162 | -+} | ||
| 163 | -+ | ||
| 164 | -+void ArenaStringPtr::Set(EmptyDefault, const char* s, size_t n, Arena* arena) { | ||
| 165 | -+ Set(s, n, arena); | ||
| 166 | -+} | ||
| 167 | -+ | ||
| 168 | -+void ArenaStringPtr::Set(EmptyDefault, const void* p, size_t n, Arena* arena) { | ||
| 169 | -+ Set(absl::string_view{static_cast<const char*>(p), n}, arena); | ||
| 170 | -+} | ||
| 171 | -+ | ||
| 172 | - const char* EpsCopyInputStream::ReadArenaString(const char* ptr, | ||
| 173 | - ArenaStringPtr* s, | ||
| 174 | - Arena* arena) { | ||
| 175 | - const char* EpsCopyInputStream::ReadArenaString(const char* ptr, | ||
| 176 | - GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); | ||
| 177 | - return ptr; | ||
| 178 | - } | ||
| 179 | -- | ||
| 180 | - } // namespace internal | ||
| 181 | -+ | ||
| 182 | -+std::string CEscape(const std::string &src) { | ||
| 183 | -+ return absl::CEscape(absl::string_view(src)); | ||
| 184 | -+} | ||
| 185 | - } // namespace protobuf | ||
| 186 | - } // namespace google | ||
| 187 | - | ||
| 188 | -diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h | ||
| 189 | -index dea2aec..ffe2343 100644 | ||
| 190 | ---- a/src/google/protobuf/arenastring.h | ||
| 191 | -+++ b/src/google/protobuf/arenastring.h | ||
| 192 | - | ||
| 193 | - #include "google/protobuf/arena.h" | ||
| 194 | - #include "google/protobuf/explicitly_constructed.h" | ||
| 195 | - #include "google/protobuf/port.h" | ||
| 196 | -+#include "absl/strings/string_view.h" | ||
| 197 | -+#include "absl/strings/escaping.h" | ||
| 198 | - | ||
| 199 | - // must be last: | ||
| 200 | - #include "google/protobuf/port_def.inc" | ||
| 201 | - struct PROTOBUF_EXPORT ArenaStringPtr { | ||
| 202 | - void Set(const std::string& value, Arena* arena); | ||
| 203 | - void Set(const char* s, Arena* arena); | ||
| 204 | - void Set(const char* s, size_t n, Arena* arena); | ||
| 205 | -- | ||
| 206 | -+ // Compatibility with undefined symbol modifications in opp_kernel packages compiled based on protobuf 3.14 | ||
| 207 | -+ struct EmptyDefault {}; | ||
| 208 | -+ void Set(EmptyDefault, const std::string& value, Arena* arena); | ||
| 209 | -+ void Set(EmptyDefault, absl::string_view value, Arena* arena); | ||
| 210 | -+ void Set(EmptyDefault, std::string&& value, Arena* arena); | ||
| 211 | -+ void Set(EmptyDefault, const char* s, Arena* arena); | ||
| 212 | -+ void Set(EmptyDefault, const char* s, size_t n, Arena* arena); | ||
| 213 | -+ void Set(EmptyDefault, const void* p, size_t n, Arena* arena); | ||
| 214 | -+ | ||
| 215 | - void SetBytes(absl::string_view value, Arena* arena); | ||
| 216 | - void SetBytes(std::string&& value, Arena* arena); | ||
| 217 | - template <typename... OverloadDisambiguator> | ||
| 218 | - inline std::string* ArenaStringPtr::UnsafeMutablePointer() { | ||
| 219 | - ABSL_DCHECK(tagged_ptr_.Get() != nullptr); | ||
| 220 | - return tagged_ptr_.Get(); | ||
| 221 | - } | ||
| 222 | -- | ||
| 223 | -- | ||
| 224 | - } // namespace internal | ||
| 225 | -+ | ||
| 226 | -+PROTOBUF_EXPORT std::string CEscape(const std::string& src); | ||
| 227 | - } // namespace protobuf | ||
| 228 | - } // namespace google | ||
| 229 | - | ||
| 230 | -diff --git a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc | ||
| 231 | -index 748a8d6..1834c39 100644 | ||
| 232 | ---- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc | ||
| 233 | -+++ b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc | ||
| 234 | - void SingularString::ReleaseImpl(io::Printer* p) const { | ||
| 235 | - p->Emit(R"cc( | ||
| 236 | - auto* released = $field_$.Release(); | ||
| 237 | - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 238 | -- $field_$.Set("", $set_args$); | ||
| 239 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", $set_args$); | ||
| 240 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 241 | - return released; | ||
| 242 | - )cc"); | ||
| 243 | - void SingularString::SetAllocatedImpl(io::Printer* p) const { | ||
| 244 | - p->Emit(R"cc( | ||
| 245 | - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 246 | - if ($field_$.IsDefault()) { | ||
| 247 | -- $field_$.Set("", $set_args$); | ||
| 248 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", $set_args$); | ||
| 249 | - } | ||
| 250 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 251 | - )cc"); | ||
| 252 | - void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const { | ||
| 253 | - $TsanDetectConcurrentMutation$; | ||
| 254 | - $PrepareSplitMessageForWrite$; | ||
| 255 | - $update_hasbit$; | ||
| 256 | -- $field_$.$Set$(static_cast<Arg_&&>(arg), args..., $set_args$); | ||
| 257 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, static_cast<Arg_&&>(arg), args..., $set_args$); | ||
| 258 | - $annotate_set$; | ||
| 259 | - // @@protoc_insertion_point(field_set:$pkg.Msg.field$) | ||
| 260 | - } | ||
| 261 | - void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const { | ||
| 262 | - $update_hasbit$; | ||
| 263 | - //~ Don't use $Set$ here; we always want the std::string variant | ||
| 264 | - //~ regardless of whether this is a `bytes` field. | ||
| 265 | -- $field_$.Set(value, $set_args$); | ||
| 266 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, value, $set_args$); | ||
| 267 | - } | ||
| 268 | - inline std::string* $Msg$::_internal_mutable_$name$() { | ||
| 269 | - $TsanDetectConcurrentMutation$; | ||
| 270 | - void SingularString::GenerateConstructorCode(io::Printer* p) const { | ||
| 271 | - if (IsString(field_, *opts_) && EmptyDefault()) { | ||
| 272 | - p->Emit(R"cc( | ||
| 273 | - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 274 | -- $field_$.Set("", GetArena()); | ||
| 275 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", GetArena()); | ||
| 276 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 277 | - )cc"); | ||
| 278 | - } | ||
| 279 | - void SingularString::GenerateCopyConstructorCode(io::Printer* p) const { | ||
| 280 | - }}}, | ||
| 281 | - R"cc( | ||
| 282 | - if ($hazzer$) { | ||
| 283 | -- _this->$field_$.Set(from._internal_$name$(), $set_args$); | ||
| 284 | -+ _this->$field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, from._internal_$name$(), $set_args$); | ||
| 285 | - } | ||
| 286 | - )cc"); | ||
| 287 | - } | ||
| 288 | -diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc | ||
| 289 | -index 2c8d275..d0abac8 100644 | ||
| 290 | ---- a/src/google/protobuf/compiler/cpp/helpers.cc | ||
| 291 | -+++ b/src/google/protobuf/compiler/cpp/helpers.cc | ||
| 292 | - bool IsFileDescriptorProto(const FileDescriptor* file, const Options& options) { | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - bool ShouldGenerateClass(const Descriptor* descriptor, const Options& options) { | ||
| 296 | -- return !IsMapEntryMessage(descriptor) || | ||
| 297 | -- HasDescriptorMethods(descriptor->file(), options); | ||
| 298 | -+ return true; | ||
| 299 | - } | ||
| 300 | - | ||
| 301 | - } // namespace cpp | ||
| 302 | -diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h | ||
| 303 | -index 9b74835..a1b6f58 100644 | ||
| 304 | ---- a/src/google/protobuf/compiler/cpp/helpers.h | ||
| 305 | -+++ b/src/google/protobuf/compiler/cpp/helpers.h | ||
| 306 | - inline bool ShouldGenerateExternSpecializations(const Options& options) { | ||
| 307 | - // Some compilers can't handle that much input in a single translation unit. | ||
| 308 | - // These specializations are just a link size optimization and do not affect | ||
| 309 | - // correctness or performance, so it is ok to omit them. | ||
| 310 | -- return !options.opensource_runtime; | ||
| 311 | -+ return true; | ||
| 312 | - } | ||
| 313 | - | ||
| 314 | - struct OneOfRangeImpl { | ||
| 315 | -diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc | ||
| 316 | -index af5c0b2..254e77c 100644 | ||
| 317 | ---- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc | ||
| 318 | -+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc | ||
| 319 | - std::string GetFieldConstantName(const FieldDescriptor* field) { | ||
| 320 | - | ||
| 321 | - std::string GetPropertyName(const FieldDescriptor* descriptor) { | ||
| 322 | - // Names of members declared or overridden in the message. | ||
| 323 | -- static const auto& reserved_member_names = *new absl::flat_hash_set<absl::string_view>({ | ||
| 324 | -+ static const auto& reserved_member_names = *new std::set<absl::string_view>({ | ||
| 325 | - "Types", | ||
| 326 | - "Descriptor", | ||
| 327 | - "Equals", | ||
| 328 | -diff --git a/src/google/protobuf/compiler/java/names.cc b/src/google/protobuf/compiler/java/names.cc | ||
| 329 | -index d934973..caa3c47 100644 | ||
| 330 | ---- a/src/google/protobuf/compiler/java/names.cc | ||
| 331 | -+++ b/src/google/protobuf/compiler/java/names.cc | ||
| 332 | - const char* DefaultPackage(Options options) { | ||
| 333 | - | ||
| 334 | - bool IsReservedName(absl::string_view name) { | ||
| 335 | - static const auto& kReservedNames = | ||
| 336 | -- *new absl::flat_hash_set<absl::string_view>({ | ||
| 337 | -+ *new std::set<absl::string_view>({ | ||
| 338 | - "abstract", "assert", "boolean", "break", "byte", | ||
| 339 | - "case", "catch", "char", "class", "const", | ||
| 340 | - "continue", "default", "do", "double", "else", | ||
| 341 | - bool IsReservedName(absl::string_view name) { | ||
| 342 | - "switch", "synchronized", "this", "throw", "throws", | ||
| 343 | - "transient", "try", "void", "volatile", "while", | ||
| 344 | - }); | ||
| 345 | -- return kReservedNames.contains(name); | ||
| 346 | -+ return kReservedNames.count(name) != 0U; | ||
| 347 | - } | ||
| 348 | - | ||
| 349 | - bool IsForbidden(absl::string_view field_name) { | ||
| 350 | - bool IsForbidden(absl::string_view field_name) { | ||
| 351 | - // Keep this list in sync with specialFieldNames in | ||
| 352 | - // java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java | ||
| 353 | - static const auto& kForbiddenNames = | ||
| 354 | -- *new absl::flat_hash_set<absl::string_view>({ | ||
| 355 | -+ *new std::set<absl::string_view>({ | ||
| 356 | - // java.lang.Object: | ||
| 357 | - "Class", | ||
| 358 | - // com.google.protobuf.MessageLiteOrBuilder: | ||
| 359 | - bool IsForbidden(absl::string_view field_name) { | ||
| 360 | - // obsolete. kept for backwards compatibility of generated code | ||
| 361 | - "CachedSize", | ||
| 362 | - }); | ||
| 363 | -- return kForbiddenNames.contains(UnderscoresToCamelCase(field_name, true)); | ||
| 364 | -+ return kForbiddenNames.count(UnderscoresToCamelCase(field_name, true)) != 0U; | ||
| 365 | - } | ||
| 366 | - | ||
| 367 | - std::string FieldName(const FieldDescriptor* field) { | ||
| 368 | -diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h | ||
| 369 | -index f45a1c8..e2191b7 100644 | ||
| 370 | ---- a/src/google/protobuf/extension_set.h | ||
| 371 | -+++ b/src/google/protobuf/extension_set.h | ||
| 372 | - class PROTOBUF_EXPORT GeneratedExtensionFinder { | ||
| 373 | - // off to the ExtensionSet for parsing. Etc. | ||
| 374 | - class PROTOBUF_EXPORT ExtensionSet { | ||
| 375 | - public: | ||
| 376 | -- constexpr ExtensionSet() : ExtensionSet(nullptr) {} | ||
| 377 | -+ constexpr ExtensionSet(); | ||
| 378 | - ExtensionSet(const ExtensionSet& rhs) = delete; | ||
| 379 | - | ||
| 380 | - // Arena enabled constructors: for internal use only. | ||
| 381 | - class PROTOBUF_EXPORT ExtensionSet { | ||
| 382 | - static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity); | ||
| 383 | - }; | ||
| 384 | - | ||
| 385 | -+constexpr ExtensionSet::ExtensionSet() | ||
| 386 | -+ : arena_(nullptr), flat_capacity_(0), flat_size_(0), map_{nullptr} {} | ||
| 387 | -+ | ||
| 388 | - constexpr ExtensionSet::ExtensionSet(Arena* arena) | ||
| 389 | - : arena_(arena), flat_capacity_(0), flat_size_(0), map_{nullptr} {} | ||
| 390 | - | ||
| 391 | -diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h | ||
| 392 | -index de8bd19..60bc923 100644 | ||
| 393 | ---- a/src/google/protobuf/message_lite.h | ||
| 394 | -+++ b/src/google/protobuf/message_lite.h | ||
| 395 | - class PROTOBUF_EXPORT MessageLite { | ||
| 396 | - return Arena::CreateMaybeMessage<T>(arena); | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | --#ifdef PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 400 | - template <typename T> | ||
| 401 | - static T* CreateMaybeMessage(Arena* arena, const T& from) { | ||
| 402 | - return Arena::CreateMaybeMessage<T>(arena, from); | ||
| 403 | - } | ||
| 404 | --#endif // PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 405 | - | ||
| 406 | - inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {} | ||
| 407 | - | ||
| 408 | -diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc | ||
| 409 | -index 25abc30..f17d861 100644 | ||
| 410 | ---- a/src/google/protobuf/port_def.inc | ||
| 411 | -+++ b/src/google/protobuf/port_def.inc | ||
| 412 | - static_assert(PROTOBUF_ABSL_MIN(20230125, 3), | ||
| 413 | - #error PROTOBUF_FORCE_COPY_DEFAULT_STRING was previously defined | ||
| 414 | - #endif | ||
| 415 | - | ||
| 416 | --// Set (and leave set) PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 417 | --// This flag changes the internal implementation class and its uses from using | ||
| 418 | --// aggregate initialization to using explicit constructor based initialization. | ||
| 419 | --// TODO: remove this flag and make the code permanent. | ||
| 420 | --#ifndef PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 421 | --#define PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 422 | --#endif | ||
| 423 | -- | ||
| 424 | - #ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION | ||
| 425 | - #error PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION was previously defined | ||
| 426 | - #endif | ||
| 427 | -diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc | ||
| 428 | -index a61cbd2..b08905d 100644 | ||
| 429 | ---- a/src/google/protobuf/stubs/common.cc | ||
| 430 | -+++ b/src/google/protobuf/stubs/common.cc | ||
| 431 | - namespace internal { | ||
| 432 | - void VerifyVersion(int headerVersion, | ||
| 433 | - int minLibraryVersion, | ||
| 434 | - const char* filename) { | ||
| 435 | -- if (GOOGLE_PROTOBUF_VERSION < minLibraryVersion) { | ||
| 436 | -- // Library is too old for headers. | ||
| 437 | -- ABSL_LOG(FATAL) | ||
| 438 | -- << "This program requires version " << VersionString(minLibraryVersion) | ||
| 439 | -- << " of the Protocol Buffer runtime library, but the installed version " | ||
| 440 | -- "is " | ||
| 441 | -- << VersionString(GOOGLE_PROTOBUF_VERSION) | ||
| 442 | -- << ". Please update " | ||
| 443 | -- "your library. If you compiled the program yourself, make sure " | ||
| 444 | -- "that " | ||
| 445 | -- "your headers are from the same version of Protocol Buffers as your " | ||
| 446 | -- "link-time library. (Version verification failed in \"" | ||
| 447 | -- << filename << "\".)"; | ||
| 448 | -- } | ||
| 449 | -- if (headerVersion < kMinHeaderVersionForLibrary) { | ||
| 450 | -- // Headers are too old for library. | ||
| 451 | -- ABSL_LOG(FATAL) | ||
| 452 | -- << "This program was compiled against version " | ||
| 453 | -- << VersionString(headerVersion) | ||
| 454 | -- << " of the Protocol Buffer runtime " | ||
| 455 | -- "library, which is not compatible with the installed version (" | ||
| 456 | -- << VersionString(GOOGLE_PROTOBUF_VERSION) | ||
| 457 | -- << "). Contact the program " | ||
| 458 | -- "author for an update. If you compiled the program yourself, make " | ||
| 459 | -- "sure that your headers are from the same version of Protocol " | ||
| 460 | -- "Buffers " | ||
| 461 | -- "as your link-time library. (Version verification failed in \"" | ||
| 462 | -- << filename << "\".)"; | ||
| 463 | -- } | ||
| 464 | -+ (void)headerVersion; | ||
| 465 | -+ (void)minLibraryVersion; | ||
| 466 | -+ (void)filename; | ||
| 467 | - } | ||
| 468 | - | ||
| 469 | - std::string VersionString(int version) { | ||
| 470 | -diff --git a/third_party/utf8_range/CMakeLists.txt b/third_party/utf8_range/CMakeLists.txt | ||
| 471 | -index 344952d..46c343b 100644 | ||
| 472 | ---- a/third_party/utf8_range/CMakeLists.txt | ||
| 473 | -+++ b/third_party/utf8_range/CMakeLists.txt | ||
| 474 | - add_library (utf8_range STATIC | ||
| 475 | - | ||
| 476 | - ## | ||
| 477 | - # A heavier-weight C++ wrapper that supports Abseil. | ||
| 478 | --add_library (utf8_validity STATIC utf8_validity.cc) | ||
| 479 | -+if (ABSL_COMPILE_OBJ) | ||
| 480 | -+ add_library (utf8_validity OBJECT utf8_validity.cc) | ||
| 481 | -+else() | ||
| 482 | -+ add_library (utf8_validity STATIC utf8_validity.cc) | ||
| 483 | -+endif() | ||
| 484 | - | ||
| 485 | - # Load Abseil dependency. | ||
| 486 | - if (NOT TARGET absl::strings) | ||
| @@ -1,61 +0,0 @@ | |||
| 1 | -# ----------------------------------------------------------------------------------------------------------- | ||
| 2 | -# Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| 3 | -# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | -# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | -# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ----------------------------------------------------------------------------------------------------------- | ||
| 10 | - | ||
| 11 | -if(POLICY CMP0135) | ||
| 12 | - cmake_policy(SET CMP0135 NEW) | ||
| 13 | -endif() | ||
| 14 | - | ||
| 15 | -set(seccomp_download_dependent FALSE) | ||
| 16 | -if (IS_DIRECTORY "${CANN_3RD_LIB_PATH}/../tools/minios/arm64/include/libseccomp") | ||
| 17 | - set(LIB_SECCOMP_INCLUDE_PATH "${CANN_3RD_LIB_PATH}/../tools/minios/arm64/include/libseccomp") | ||
| 18 | -elseif (EXISTS "${CANN_3RD_LIB_PATH}/lib_cache/libseccomp-2.5.4/include/seccomp.h") | ||
| 19 | - message("seccomp use opensource cache.") | ||
| 20 | - set(LIB_SECCOMP_INCLUDE_PATH "${CANN_3RD_LIB_PATH}/lib_cache/libseccomp-2.5.4/include") | ||
| 21 | -elseif (EXISTS "/usr/local/include/seccomp.h") | ||
| 22 | - set(LIB_SECCOMP_INCLUDE_PATH "/usr/local/include") | ||
| 23 | -else() | ||
| 24 | - set(REQ_URL "${CANN_3RD_LIB_PATH}/libseccomp-2.5.4/libseccomp-2.5.4.tar.gz") | ||
| 25 | - if(EXISTS ${REQ_URL}) | ||
| 26 | - message(STATUS "[UDF seccomp] ${REQ_URL} found in local") | ||
| 27 | - elseif(EXISTS "${CANN_3RD_LIB_PATH}/libseccomp-2.5.4") | ||
| 28 | - message(STATUS "[UDF seccomp] ${CANN_3RD_LIB_PATH}/libseccomp-2.5.4 found in local") | ||
| 29 | - set(REQ_URL "${CANN_3RD_LIB_PATH}/libseccomp-2.5.4") | ||
| 30 | - else() | ||
| 31 | - message(STATUS "[UDF seccomp] libseccomp-2.5.4 not found, download.") | ||
| 32 | - set(REQ_URL "https://gitcode.com/cann-src-third-party/libseccomp/releases/download/v2.5.4/libseccomp-2.5.4.tar.gz") | ||
| 33 | - endif() | ||
| 34 | - include(ExternalProject) | ||
| 35 | - ExternalProject_Add(external_seccomp | ||
| 36 | - URL ${REQ_URL} | ||
| 37 | - TLS_VERIFY OFF | ||
| 38 | - DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/downloads | ||
| 39 | - PREFIX third_party | ||
| 40 | - CONFIGURE_COMMAND bash -c "cd <SOURCE_DIR> && test -f include/seccomp.h || (./autogen.sh && ./configure --prefix=<INSTALL_DIR>)" | ||
| 41 | - INSTALL_COMMAND "" | ||
| 42 | - BUILD_COMMAND "" | ||
| 43 | - ) | ||
| 44 | - | ||
| 45 | - ExternalProject_Get_Property(external_seccomp SOURCE_DIR) | ||
| 46 | - set(LIB_SECCOMP_INCLUDE_PATH ${SOURCE_DIR}/include) | ||
| 47 | - set(seccomp_download_dependent TRUE) | ||
| 48 | -endif() | ||
| 49 | - | ||
| 50 | -add_library(seccomp_headers INTERFACE) | ||
| 51 | -set_target_properties(seccomp_headers PROPERTIES | ||
| 52 | - INTERFACE_INCLUDE_DIRECTORIES "${LIB_SECCOMP_INCLUDE_PATH}" | ||
| 53 | - ) | ||
| 54 | -if (seccomp_download_dependent) | ||
| 55 | - add_dependencies(seccomp_headers external_seccomp) | ||
| 56 | -endif() | ||
| 57 | - | ||
| 58 | -include(CMakePrintHelpers) | ||
| 59 | -cmake_print_properties(TARGETS seccomp_headers | ||
| 60 | - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES | ||
| 61 | - ) | ||