Support Relaxed SIMD in xnnpack_cc_library and xnnpack_aggregate_library

PiperOrigin-RevId: 417730327
diff --git a/BUILD.bazel b/BUILD.bazel
index d4f04f8..d571a59 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -6755,6 +6755,7 @@
     gcc_copts = xnnpack_gcc_std_copts(),
     msvc_copts = xnnpack_msvc_std_copts(),
     wasm_srcs = ALL_WASM_MICROKERNEL_SRCS,
+    wasmrelaxedsimd_srcs = ALL_WASM_MICROKERNEL_SRCS + ALL_WASMSIMD_MICROKERNEL_SRCS,
     wasmsimd_srcs = ALL_WASM_MICROKERNEL_SRCS + ALL_WASMSIMD_MICROKERNEL_SRCS,
     deps = [
         ":tables",
@@ -6770,6 +6771,7 @@
     gcc_copts = xnnpack_gcc_std_copts(),
     msvc_copts = xnnpack_msvc_std_copts(),
     wasm_srcs = ALL_WASM_MICROKERNEL_SRCS,
+    wasmrelaxedsimd_srcs = ALL_WASM_MICROKERNEL_SRCS + ALL_WASMSIMD_MICROKERNEL_SRCS,
     wasmsimd_srcs = ALL_WASM_MICROKERNEL_SRCS + ALL_WASMSIMD_MICROKERNEL_SRCS,
     deps = [
         ":tables",
@@ -6789,6 +6791,7 @@
     gcc_copts = xnnpack_gcc_std_copts(),
     msvc_copts = xnnpack_msvc_std_copts(),
     wasm_srcs = ALL_WASM_MICROKERNEL_SRCS,
+    wasmrelaxedsimd_srcs = ALL_WASM_MICROKERNEL_SRCS + ALL_WASMSIMD_MICROKERNEL_SRCS,
     wasmsimd_srcs = ALL_WASM_MICROKERNEL_SRCS + ALL_WASMSIMD_MICROKERNEL_SRCS,
     deps = [
         ":tables",
@@ -7747,6 +7750,7 @@
     aarch64_copts = ["-march=armv8.2-a+fp16+dotprod"],
     aarch64_srcs = AARCH64_ASM_MICROKERNEL_SRCS,
     wasm_srcs = WASM32_ASM_MICROKERNEL_SRCS,
+    wasmrelaxedsimd_srcs = WASM32_ASM_MICROKERNEL_SRCS,
     wasmsimd_srcs = WASM32_ASM_MICROKERNEL_SRCS,
 )
 
@@ -7804,6 +7808,10 @@
         ":wasm_bench_microkernels",
         ":asm_microkernels",
     ],
+    wasmrelaxedsimd_deps = [
+        ":wasm_bench_microkernels",
+        ":asm_microkernels",
+    ],
     wasmsimd_deps = [
         ":wasm_bench_microkernels",
         ":asm_microkernels",
@@ -7855,6 +7863,10 @@
         ":wasm_prod_microkernels",
         ":asm_microkernels",
     ],
+    wasmrelaxedsimd_deps = [
+        ":wasm_prod_microkernels",
+        ":asm_microkernels",
+    ],
     wasmsimd_deps = [
         ":wasm_prod_microkernels",
         ":asm_microkernels",
@@ -7906,6 +7918,10 @@
         ":wasm_test_microkernels",
         ":asm_microkernels",
     ],
+    wasmrelaxedsimd_deps = [
+        ":wasm_test_microkernels",
+        ":asm_microkernels",
+    ],
     wasmsimd_deps = [
         ":wasm_test_microkernels",
         ":asm_microkernels",
@@ -11691,15 +11707,12 @@
 )
 
 config_setting(
-    name = "emscripten_relaxedsimd",
-    flag_values = {
-        "//tools/cpp:cc_target_os": "emscripten",
-    },
+    name = "emscripten_wasmrelaxedsimd",
     values = {
+        "crosstool_top": "@emsdk//emscripten_toolchain:everything",
         "cpu": "wasm",
-        "features": "wasm_simd",
+        "copt": "-msimd128",
         "copt": "-mrelaxed-simd",
-        "linkopt": "-mrelaxed-simd",
     },
 )
 
diff --git a/build_defs.bzl b/build_defs.bzl
index d79ad63..fbadb40 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -74,6 +74,7 @@
         aarch64_srcs = [],
         wasm_srcs = [],
         wasmsimd_srcs = [],
+        wasmrelaxedsimd_srcs = [],
         copts = [],
         gcc_copts = [],
         msvc_copts = [],
@@ -87,6 +88,7 @@
         aarch64_copts = [],
         wasm_copts = [],
         wasmsimd_copts = [],
+        wasmrelaxedsimd_copts = [],
         optimized_copts = ["-O2"],
         hdrs = [],
         defines = [],
@@ -104,8 +106,10 @@
       x86_srcs: The list of x86-specific source files.
       aarch32_srcs: The list of AArch32-specific source files.
       aarch64_srcs: The list of AArch64-specific source files.
-      wasm_srcs: The list of WebAssembly/MVP-specific source files.
-      wasmsimd_srcs: The list of WebAssembly/SIMD-specific source files.
+      wasm_srcs: The list of WebAssembly 1.0-specific source files.
+      wasmsimd_srcs: The list of WebAssembly SIMD-specific source files.
+      wasmrelaxedsimd_srcs: The list of WebAssembly Relaxed SIMD-specific
+                            source files.
       copts: The list of compiler flags to use in all builds. -I flags for
              include/ and src/ directories of XNNPACK are always prepended
              before these user-specified flags.
@@ -124,9 +128,11 @@
                            with Apple Clang.
       aarch32_copts: The list of compiler flags to use in AArch32 builds.
       aarch64_copts: The list of compiler flags to use in AArch64 builds.
-      wasm_copts: The list of compiler flags to use in WebAssembly/MVP builds.
-      wasmsimd_copts: The list of compiler flags to use in WebAssembly/SIMD
+      wasm_copts: The list of compiler flags to use in WebAssembly 1.0 builds.
+      wasmsimd_copts: The list of compiler flags to use in WebAssembly SIMD
                       builds.
+      wasmrelaxedsimd_copts: The list of compiler flags to use in WebAssembly
+                             Relaxed SIMD builds.
       optimized_copts: The list of compiler flags to use in optimized builds.
                        Defaults to -O2.
       hdrs: The list of header files published by this library to be textually
@@ -168,6 +174,7 @@
             ":tvos_x86_64": x86_srcs,
             ":emscripten_wasm": wasm_srcs,
             ":emscripten_wasmsimd": wasmsimd_srcs,
+            ":emscripten_wasmrelaxedsimd": wasmrelaxedsimd_srcs,
             "//conditions:default": [],
         }),
         copts = [
@@ -203,6 +210,7 @@
             ":tvos_x86_64": gcc_x86_copts,
             ":emscripten_wasm": wasm_copts,
             ":emscripten_wasmsimd": wasmsimd_copts,
+            ":emscripten_wasmrelaxedsimd": wasmrelaxedsimd_copts,
             "//conditions:default": [],
         }) + select({
             ":windows_x86_64_clang": ["/clang:" + opt for opt in gcc_copts],
@@ -240,18 +248,23 @@
         aarch32_nonios_deps = [],
         aarch64_deps = [],
         wasm_deps = [],
-        wasmsimd_deps = []):
+        wasmsimd_deps = [],
+        wasmrelaxedsimd_deps = []):
     """Static library that aggregates architecture-specific dependencies.
 
     Args:
       name: The name of the library target to define.
       generic_deps: The list of libraries to link on all architectures.
       x86_deps: The list of libraries to link in x86 and x86-64 builds.
-      aarch32_ios_deps: The list of libraries to link in AArch32 iOS (incl WatchOS) builds.
-      aarch32_nonios_deps: The list of libraries to link in AArch32 non-iOS builds.
+      aarch32_ios_deps: The list of libraries to link in AArch32 iOS (incl
+                        WatchOS) builds.
+      aarch32_nonios_deps: The list of libraries to link in AArch32 non-iOS
+                           builds.
       aarch64_deps: The list of libraries to link in AArch32 builds.
-      wasm_deps: The list of libraries to link in WebAssembly (MVP) builds.
+      wasm_deps: The list of libraries to link in WebAssembly 1.0 builds.
       wasmsimd_deps: The list of libraries to link in WebAssembly SIMD builds.
+      wasmrelaxedsimd_deps: The list of libraries to link in WebAssembly
+                            Relaxed SIMD builds.
     """
 
     native.cc_library(
@@ -287,6 +300,7 @@
             ":tvos_x86_64": x86_deps,
             ":emscripten_wasm": wasm_deps,
             ":emscripten_wasmsimd": wasmsimd_deps,
+            ":emscripten_wasmrelaxedsimd": wasmrelaxedsimd_deps,
         }),
     )