From cfbfa18f34211429aa7586fd75a85b67addcc133 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 26 Apr 2023 16:32:36 +0400 Subject: [PATCH] Fixed WASM build in update docker container / new dependencies (#17224) --- cmake/developer_package/native_compile.cmake | 31 ++++++++++++++----- src/core/include/openvino/core/visibility.hpp | 3 +- src/plugins/intel_cpu/src/plugin.cpp | 2 +- thirdparty/CMakeLists.txt | 9 ++++-- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/cmake/developer_package/native_compile.cmake b/cmake/developer_package/native_compile.cmake index 638d2b15cf1..51101a64712 100644 --- a/cmake/developer_package/native_compile.cmake +++ b/cmake/developer_package/native_compile.cmake @@ -18,7 +18,7 @@ function(ov_native_compile_external_project) set(multiValueArgs CMAKE_ARGS NATIVE_TARGETS) cmake_parse_arguments(ARG "" "${oneValueRequiredArgs};${oneValueOptionalArgs}" "${multiValueArgs}" ${ARGN}) - if(YOCTO_AARCH64) + if(YOCTO_AARCH64 OR EMSCRIPTEN) # need to unset several variables which can set env to cross-environment foreach(var SDKTARGETSYSROOT CONFIG_SITE OECORE_NATIVE_SYSROOT OECORE_TARGET_SYSROOT OECORE_ACLOCAL_OPTS OECORE_BASELIB OECORE_TARGET_ARCH OECORE_TARGET_OS CC CXX @@ -31,10 +31,17 @@ function(ov_native_compile_external_project) endif() endforeach() + # set root path + if(YOCTO_AARCH64) + set(root_path "$ENV{OECORE_NATIVE_SYSROOT}") + elseif(EMSCRIPTEN) + set(root_path "$ENV{EMSDK}") + endif() + # filter out PATH from yocto locations string(REPLACE ":" ";" custom_path "$ENV{PATH}") foreach(path IN LISTS custom_path) - if(NOT path MATCHES "^$ENV{OECORE_NATIVE_SYSROOT}") + if(DEFINED root_path AND NOT path MATCHES "^${root_path}") list(APPEND clean_path "${path}") endif() endforeach() @@ -81,6 +88,17 @@ function(ov_native_compile_external_project) endif() endif() + if(compile_flags) + list(APPEND ARG_CMAKE_ARGS "-DCMAKE_CXX_FLAGS=${compile_flags}" "-DCMAKE_C_FLAGS=${compile_flags}") + endif() + + if(DEFINED CMAKE_CXX_COMPILER_LAUNCHER) + list(APPEND ARG_CMAKE_ARGS "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}") + endif() + if(DEFINED CMAKE_C_COMPILER_LAUNCHER) + list(APPEND ARG_CMAKE_ARGS "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}") + endif() + ExternalProject_Add(${ARG_TARGET_NAME} # Directory Options SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" @@ -89,12 +107,9 @@ function(ov_native_compile_external_project) INSTALL_DIR "${ARG_NATIVE_INSTALL_DIR}" # Configure Step Options: CMAKE_COMMAND - ${NATIVE_CMAKE_COMMAND} + "${NATIVE_CMAKE_COMMAND}" -E env ${cmake_env} + "${NATIVE_CMAKE_COMMAND}" CMAKE_ARGS - "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}" - "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}" - "-DCMAKE_CXX_FLAGS=${compile_flags}" - "-DCMAKE_C_FLAGS=${compile_flags}" "-DCMAKE_POLICY_DEFAULT_CMP0069=NEW" "-DCMAKE_INSTALL_PREFIX=${ARG_NATIVE_INSTALL_DIR}" ${ARG_CMAKE_ARGS} @@ -102,7 +117,7 @@ function(ov_native_compile_external_project) ${ARG_NATIVE_SOURCE_SUBDIR} # Build Step Options: BUILD_COMMAND - ${NATIVE_CMAKE_COMMAND} + "${NATIVE_CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/build" --config Release --parallel diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index 31b67c15067..11c132b7a7e 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -53,7 +53,8 @@ # define OPENVINO_ARCH_ARM64 # define OPENVINO_ARCH_64_BIT #elif defined(i386) || defined(__i386) || defined(__i386__) || defined(__IA32__) || defined(_M_I86) || \ - defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__386) + defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__386) || \ + defined(__ILP32__) || defined(_ILP32) || defined(__wasm32__) || defined(__wasm32) # define OPENVINO_ARCH_X86 # define OPENVINO_ARCH_32_BIT #elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || \ diff --git a/src/plugins/intel_cpu/src/plugin.cpp b/src/plugins/intel_cpu/src/plugin.cpp index 7705efc3c3a..d8917e6ee30 100644 --- a/src/plugins/intel_cpu/src/plugin.cpp +++ b/src/plugins/intel_cpu/src/plugin.cpp @@ -46,7 +46,7 @@ namespace intel_cpu { static std::string getDeviceFullName() { std::string brand_string; -#if defined(__EMSCRIPTEN___) +#if defined(__EMSCRIPTEN__) brand_string = "WebAssembly CPU"; #elif defined(OPENVINO_ARCH_RISCV64) // TODO: extract actual device name diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index cc53f33cbbc..c389dcf9e54 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -427,7 +427,7 @@ if(ENABLE_SNAPPY_COMPRESSION) endif() if(NOT TARGET Snappy::snappy) - function(tf_build_snappy) + function(ov_build_snappy) set(BUILD_SHARED_LIBS OFF) set(SNAPPY_BUILD_BENCHMARKS OFF) set(SNAPPY_BUILD_TESTS OFF) @@ -454,9 +454,14 @@ if(ENABLE_SNAPPY_COMPRESSION) add_subdirectory(snappy EXCLUDE_FROM_ALL) # need to create alias Snappy::snappy add_library(Snappy::snappy ALIAS snappy) + + # WA for emscriptem build which currently requires -fexceptions + if(EMSCRIPTEN) + target_compile_options(snappy PRIVATE "-fexceptions") + endif() endfunction() - tf_build_snappy() + ov_build_snappy() ov_install_static_lib(snappy ${OV_CPACK_COMP_CORE}) endif() endif()