Remove Windows Store specific code

This commit is contained in:
Tiago Koji Castro Shibata 2022-03-17 16:43:12 -07:00 committed by Changming Sun
parent a3eeb7b0f7
commit 5ed2f4ad5f
9 changed files with 21 additions and 80 deletions

View file

@ -877,8 +877,8 @@ else()
if (${onnxruntime_target_platform} MATCHES "^(ARM.*|arm.*)$" )
message(WARNING "Cpuinfo not included for compilation problems with Windows ARM.")
set(CPUINFO_SUPPORTED FALSE)
elseif (WINDOWS_STORE OR (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib))
message(WARNING "Cpuinfo not included in Windows Store or WCOS builds")
elseif (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
message(WARNING "Cpuinfo not included non-Desktop builds")
set(CPUINFO_SUPPORTED FALSE)
endif()
elseif (NOT ${onnxruntime_target_platform} MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
@ -1900,33 +1900,19 @@ else()
endif()
if (WIN32)
if (WINDOWS_STORE)
# Setting WINAPI_FAMILY, WINVER and _WIN32_WINNT restrict the APIs exposed in Windows headers to those available
# in store or desktop, and that support at least the version of Windows specified
add_compile_definitions(WINAPI_FAMILY=2) # Windows Store app
add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00 NTDDI_VERSION=0x0A000000) # Support Windows 10 or newer
# /ZW adds /FUplatform.winmd and /FUwindows.winmd. windows.winmd, in turn, overrides the include path for
# the cppwinrt headers, which we set to use the WinML built ones.
# Instead, we use /ZW:nostdlib and force include platform.winml only.
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:SHELL:/ZW:nostdlib /FUplatform.winmd>")
get_filename_component(msvc_path "${CMAKE_C_COMPILER}/../../../.." ABSOLUTE)
link_directories("${msvc_path}/lib/${onnxruntime_target_platform}/store")
add_link_options(/APPCONTAINER)
add_compile_definitions(WINAPI_FAMILY=100) # Desktop app
if (onnxruntime_USE_WINML)
add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602 NTDDI_VERSION=0x06020000) # Support Windows 8 and newer
else()
add_compile_definitions(WINAPI_FAMILY=100) # Desktop app
if (onnxruntime_USE_WINML)
add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602 NTDDI_VERSION=0x06020000) # Support Windows 8 and newer
else()
add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601 NTDDI_VERSION=0x06010000) # Support Windows 7 and newer
endif()
if (NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
# On onecore, link to the onecore build of the MSVC runtime
get_filename_component(msvc_path "${CMAKE_C_COMPILER}/../../../.." ABSOLUTE)
link_directories(BEFORE "${msvc_path}/lib/onecore/${onnxruntime_target_platform}")
# The .lib files in the MSVC runtime have a DEFAULITLIB entry for onecore.lib, which in turn links to reverse forwarders.
# We ignore that entry and use onecore_apiset.lib instead, since system components must not rely on reverse forwarders.
add_link_options("/NODEFAULTLIB:onecore.lib")
endif()
add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601 NTDDI_VERSION=0x06010000) # Support Windows 7 and newer
endif()
if (NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
# On onecore, link to the onecore build of the MSVC runtime
get_filename_component(msvc_path "${CMAKE_C_COMPILER}/../../../.." ABSOLUTE)
link_directories(BEFORE "${msvc_path}/lib/onecore/${onnxruntime_target_platform}")
# The .lib files in the MSVC runtime have a DEFAULITLIB entry for onecore.lib, which in turn links to reverse forwarders.
# We ignore that entry and use onecore_apiset.lib instead, since system components must not rely on reverse forwarders.
add_link_options("/NODEFAULTLIB:onecore.lib")
endif()
endif()
@ -2012,16 +1998,6 @@ if (onnxruntime_BUILD_WEBASSEMBLY)
include(onnxruntime_webassembly.cmake)
endif()
if (WINDOWS_STORE)
target_link_options(onnxruntime PRIVATE /DYNAMICBASE /NXCOMPAT /APPCONTAINER)
target_link_options(winml_dll PRIVATE /DYNAMICBASE /NXCOMPAT /APPCONTAINER)
if (onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY)
target_link_options(onnxruntime PRIVATE /SAFESEH)
target_link_options(winml_dll PRIVATE /SAFESEH)
endif()
endif()
if (UNIX)
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
else()

View file

@ -213,9 +213,6 @@ install(TARGETS onnxruntime
set_target_properties(onnxruntime PROPERTIES FOLDER "ONNXRuntime")
if (WINDOWS_STORE)
target_link_options(onnxruntime PRIVATE /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll)
endif()
if (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
# Workaround STL bug https://github.com/microsoft/STL/issues/434#issuecomment-921321254
# Note that the workaround makes std::system_error crash before Windows 10

View file

@ -206,7 +206,7 @@ endif()
if (ARM64 OR ARM OR X86 OR X64 OR X86_64)
if(WINDOWS_STORE OR (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib) OR ((ARM64 OR ARM) AND MSVC))
if((WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib) OR ((ARM64 OR ARM) AND MSVC))
# msvc compiler report syntax error with cpuinfo arm source files
# and cpuinfo does not have code for getting arm uarch info under windows
else()

View file

@ -21,16 +21,3 @@ set_target_properties(onnxruntime_flatbuffers PROPERTIES FOLDER "ONNXRuntime")
if (FLATBUFFERS_BUILD_FLATC)
add_dependencies(onnxruntime_flatbuffers flatc)
endif()
if (WINDOWS_STORE)
function(target_force_include target scope file)
if (MSVC)
target_compile_options(${target} ${scope} "/FI${file}")
else()
target_compile_options(${target} ${scope} -include "${file}")
endif()
endfunction()
target_force_include(flatbuffers PRIVATE uwp_stubs.h)
target_force_include(flatc PRIVATE uwp_stubs.h)
endif()

View file

@ -1004,11 +1004,7 @@ if (onnxruntime_USE_DML)
target_add_dml(onnxruntime_providers_dml)
target_link_libraries(onnxruntime_providers_dml PRIVATE d3d12.lib dxgi.lib)
if (WINDOWS_STORE)
target_link_libraries(onnxruntime_providers_dml PRIVATE dloadhelper.lib)
else()
target_link_libraries(onnxruntime_providers_dml PRIVATE delayimp.lib)
endif()
target_link_libraries(onnxruntime_providers_dml PRIVATE delayimp.lib)
set(onnxruntime_DELAYLOAD_FLAGS "${onnxruntime_DELAYLOAD_FLAGS} /DELAYLOAD:DirectML.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:dxgi.dll /DELAYLOAD:api-ms-win-core-com-l1-1-0.dll /DELAYLOAD:shlwapi.dll /DELAYLOAD:oleaut32.dll /ignore:4199")

View file

@ -1,5 +0,0 @@
set(CMAKE_SYSTEM_NAME WindowsStore)
set(CMAKE_SYSTEM_VERSION 10.0)
if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()

View file

@ -9,9 +9,6 @@ function(target_delayload target_name)
foreach(lib ${ARGN})
target_link_options(${target_name} PRIVATE /DELAYLOAD:"${lib}")
endforeach()
if (WINDOWS_STORE)
target_link_libraries(${target_name} PRIVATE dloadhelper.lib)
else()
target_link_libraries(${target_name} PRIVATE delayimp.lib)
endif()
target_link_libraries(${target_name} PRIVATE delayimp.lib)
endfunction()

View file

@ -190,7 +190,7 @@ set_winml_target_properties(winml_google_test_lib)
set_winml_target_properties(winml_test_common)
get_winml_test_api_src(${WINML_TEST_SRC_DIR} winml_test_api_src)
if (NOT WINDOWS_STORE AND NOT ${winml_is_inbox})
if (NOT ${winml_is_inbox})
get_winml_test_api_redist_only_src(${WINML_TEST_SRC_DIR} winml_test_api_redist_only_src)
endif()

View file

@ -487,9 +487,6 @@ def parse_arguments():
parser.add_argument(
"--enable_wcos", action='store_true',
help="Build for Windows Core OS.")
parser.add_argument(
"--enable_windows_store", action='store_true',
help="Build for Windows Store")
parser.add_argument(
"--enable_lto", action='store_true',
help="Enable Link Time Optimization")
@ -1931,7 +1928,7 @@ def is_cross_compiling_on_apple(args):
def build_protoc_for_host(cmake_path, source_dir, build_dir, args):
if (args.arm or args.arm64 or args.arm64ec or args.enable_windows_store) and \
if (args.arm or args.arm64 or args.arm64ec) and \
not (is_windows() or is_cross_compiling_on_apple(args)):
raise BuildError(
'Currently only support building protoc for Windows host while '
@ -2213,10 +2210,6 @@ def main():
cmake_extra_args = [
'-A', 'x64', '-T', toolset, '-G', args.cmake_generator
]
if args.enable_windows_store:
cmake_extra_defines.append(
'CMAKE_TOOLCHAIN_FILE=' + os.path.join(
source_dir, 'cmake', 'store_toolchain.cmake'))
if args.enable_wcos:
cmake_extra_defines.append('CMAKE_USER_MAKE_RULES_OVERRIDE=wcos_rules_override.cmake')
elif args.cmake_generator is not None and not (is_macOS() and args.use_xcode):
@ -2241,7 +2234,7 @@ def main():
log.info("Activating emsdk...")
run_subprocess([emsdk_file, "activate", emsdk_version], cwd=emsdk_dir)
if (args.android or args.ios or args.enable_windows_store or args.build_wasm
if (args.android or args.ios or args.build_wasm
or is_cross_compiling_on_apple(args)) and args.path_to_protoc_exe is None:
# Cross-compiling for Android, iOS, and WebAssembly
path_to_protoc_exe = build_protoc_for_host(