From 3f91341cbbb908c43f1ada62e2c7f8cb9a3a0828 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 8 Mar 2023 13:57:20 -0800 Subject: [PATCH 1/2] Fix wasm dynamic library extension crash --- .../google/devtools/build/lib/rules/cpp/CppFileTypes.java | 2 +- src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java index c4b502e8c8d089..c18a1d4c15c311 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java @@ -206,7 +206,7 @@ public ImmutableList getExtensions() { // TODO(bazel-team): File types should not be read from this hard-coded list but should come from // the toolchain instead. See https://github.com/bazelbuild/bazel/issues/17117 - public static final FileType SHARED_LIBRARY = FileType.of(".so", ".dylib", ".dll", ".pyd"); + public static final FileType SHARED_LIBRARY = FileType.of(".so", ".dylib", ".dll", ".pyd", ".wasm"); // Unix shared libraries can be passed to linker, but not .dll on Windows public static final FileType UNIX_SHARED_LIBRARY = FileType.of(".so", ".dylib"); public static final FileType INTERFACE_SHARED_LIBRARY = diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl index fd56982cc5df58..83184a107e56ad 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl @@ -387,7 +387,7 @@ ARCHIVE = [".a", ".lib"] PIC_ARCHIVE = [".pic.a"] ALWAYSLINK_LIBRARY = [".lo"] ALWAYSLINK_PIC_LIBRARY = [".pic.lo"] -SHARED_LIBRARY = [".so", ".dylib", ".dll"] +SHARED_LIBRARY = [".so", ".dylib", ".dll", ".wasm"] INTERFACE_SHARED_LIBRARY = [".ifso", ".tbd", ".lib", ".dll.a"] OBJECT_FILE = [".o", ".obj"] PIC_OBJECT_FILE = [".pic.o"] @@ -569,12 +569,13 @@ def _is_versioned_shared_library_extension_valid(shared_library_name): def _is_valid_shared_library_name(shared_library_name): if (shared_library_name.endswith(".so") or shared_library_name.endswith(".dll") or - shared_library_name.endswith(".dylib")): + shared_library_name.endswith(".dylib") or + shared_library_name.endswith(".wasm")): return True return _is_versioned_shared_library_extension_valid(shared_library_name) -_SHARED_LIBRARY_EXTENSIONS = ["so", "dll", "dylib"] +_SHARED_LIBRARY_EXTENSIONS = ["so", "dll", "dylib", "wasm"] def _is_valid_shared_library_artifact(shared_library): if (shared_library.extension in _SHARED_LIBRARY_EXTENSIONS): From 07155eec477bdd7b2277570eec368537e792727d Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 8 Mar 2023 14:32:43 -0800 Subject: [PATCH 2/2] update wrong extension test --- .../devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java index 5debe8d15d5550..bdf09088188ff2 100755 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java @@ -5297,10 +5297,10 @@ public void testWrongExtensionThrowsError() throws Exception { "'a.pic.o' does not have any of the allowed extensions .a, .lib, .pic.a or .rlib"); assertThat(e) .hasMessageThat() - .contains("'a.ifso' does not have any of the allowed extensions .so, .dylib, .dll or .pyd"); + .contains("'a.ifso' does not have any of the allowed extensions .so, .dylib, .dll, .pyd or .wasm"); assertThat(e) .hasMessageThat() - .contains("'a.lib' does not have any of the allowed extensions .so, .dylib, .dll or .pyd"); + .contains("'a.lib' does not have any of the allowed extensions .so, .dylib, .dll, .pyd or .wasm"); assertThat(e) .hasMessageThat() .contains(