From 0723d164366e274add60b09360105d5b8bace633 Mon Sep 17 00:00:00 2001 From: Yulong Wang Date: Thu, 3 Jun 2021 23:08:56 -0700 Subject: [PATCH] [wasm] allows to specify MALLOC setting for wasm build (#7934) --- cmake/onnxruntime_webassembly.cmake | 1 + tools/ci_build/build.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/cmake/onnxruntime_webassembly.cmake b/cmake/onnxruntime_webassembly.cmake index dff25b85ea..48e1705296 100644 --- a/cmake/onnxruntime_webassembly.cmake +++ b/cmake/onnxruntime_webassembly.cmake @@ -51,6 +51,7 @@ set_target_properties(onnxruntime_webassembly PROPERTIES LINK_FLAGS " -s LLD_REPORT_UNDEFINED \ -s VERBOSE=0 \ -s NO_FILESYSTEM=1 \ + -s MALLOC=${onnxruntime_WEBASSEMBLY_MALLOC} \ --no-entry") if (CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index f7e9255e03..482b39cd5a 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -346,6 +346,8 @@ def parse_arguments(): parser.add_argument( "--enable_wasm_debug_info", action='store_true', help="Build WebAssembly with DWARF format debug info") + parser.add_argument( + "--wasm_malloc", default="dlmalloc", help="Specify memory allocator for WebAssembly") # Arguments needed by CI parser.add_argument( @@ -750,6 +752,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home else "ON"), "-Donnxruntime_ENABLE_WEBASSEMBLY_THREADS=" + ("ON" if args.enable_wasm_threads else "OFF"), "-Donnxruntime_ENABLE_WEBASSEMBLY_DEBUG_INFO=" + ("ON" if args.enable_wasm_debug_info else "OFF"), + "-Donnxruntime_WEBASSEMBLY_MALLOC=" + args.wasm_malloc, "-Donnxruntime_ENABLE_EAGER_MODE=" + ("ON" if args.build_eager_mode else "OFF"), ]