This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wasm-micro-runtime/samples/workload/XNNPACK/xnnpack.patch
Wenyong Huang 7be0d385a6
Implement SIMD latest opcodes and update LLVM to 13.0 (#758)
Implement the latest SIMD opcodes and update LLVM 13.0,
update the llvm build scripts, update the sample workloads‘ build scripts,
and build customized wasi-sdk to build some workloads.
Also refine the CI rules.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-09-17 19:12:57 +08:00

101 lines
3.2 KiB
Diff

diff --git a/.bazelrc b/.bazelrc
index ec740f38..29f9d56e 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -49,4 +49,9 @@ build:ios_fat --watchos_cpus=armv7k
build:macos --apple_platform_type=macos
build:macos_arm64 --config=macos
-build:macos_arm64 --cpu=darwin_arm64
\ No newline at end of file
+build:macos_arm64 --cpu=darwin_arm64
+
+build:wasm --cpu=wasm
+build:wasm --copt=-msimd128
+build:wasm --crosstool_top=@emsdk//emscripten_toolchain:everything
+build:wasm --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
diff --git a/WORKSPACE b/WORKSPACE
index c58e76b6..30934678 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -21,6 +21,7 @@ http_archive(
name = "com_google_benchmark",
strip_prefix = "benchmark-master",
urls = ["https://github.com/google/benchmark/archive/master.zip"],
+ patches = ["@//third_party:benchmark.patch"],
)
# FP16 library, used for half-precision conversions
@@ -84,6 +85,19 @@ http_archive(
],
)
+http_archive(
+ name = "emsdk",
+ strip_prefix = "emsdk-2.0.26/bazel",
+ url = "https://github.com/emscripten-core/emsdk/archive/refs/tags/2.0.26.tar.gz",
+ sha256 = "79e7166aa8eaae6e52cef1363b2d8db795d03684846066bc51f9dcf905dd58ad",
+)
+
+load("@emsdk//:deps.bzl", emsdk_deps = "deps")
+emsdk_deps()
+
+load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
+emsdk_emscripten_deps()
+
# Android NDK location and version is auto-detected from $ANDROID_NDK_HOME environment variable
android_ndk_repository(name = "androidndk")
diff --git a/build_defs.bzl b/build_defs.bzl
index 2442bed1..b860dfef 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -414,7 +414,7 @@ def xnnpack_benchmark(name, srcs, copts = [], deps = [], tags = []):
explicitly specified.
"""
native.cc_binary(
- name = name,
+ name = name + ".wasm",
srcs = srcs,
copts = xnnpack_std_cxxopts() + [
"-Iinclude",
diff --git a/emscripten.bzl b/emscripten.bzl
index 130d5f16..2696ad54 100644
--- a/emscripten.bzl
+++ b/emscripten.bzl
@@ -25,12 +25,19 @@ def xnnpack_emscripten_benchmark_linkopts():
"""Emscripten-specific linkopts for benchmarks."""
return [
"-s ASSERTIONS=1",
- "-s ENVIRONMENT=node,shell,web",
- "-s ERROR_ON_UNDEFINED_SYMBOLS=1",
- "-s EXIT_RUNTIME=1",
+ "-s ERROR_ON_UNDEFINED_SYMBOLS=0",
"-s ALLOW_MEMORY_GROWTH=1",
"-s TOTAL_MEMORY=445644800", # 425M
- "--pre-js $(location :preamble.js.lds)",
+ "-s USE_PTHREADS=0",
+ "-s STANDALONE_WASM=1",
+ "-Wno-unused",
+ "-Wno-unused-variable",
+ "-Wno-unused-command-line-argument",
+ "-Wl,--export=__heap_base",
+ "-Wl,--export=__data_end",
+ "-Wl,--export=malloc",
+ "-Wl,--export=free",
+ "--oformat=wasm",
]
def xnnpack_emscripten_deps():
diff --git a/third_party/cpuinfo.BUILD b/third_party/cpuinfo.BUILD
index 128d683e..f6c287c4 100644
--- a/third_party/cpuinfo.BUILD
+++ b/third_party/cpuinfo.BUILD
@@ -343,5 +343,5 @@ config_setting(
config_setting(
name = "emscripten",
- values = {"crosstool_top": "//toolchain:emscripten"},
+ values = {"crosstool_top": "@emsdk//emscripten_toolchain:everything"},
)