Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.1.1] Fix wasm dynamic library extension crash #17757

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ public ImmutableList<String> 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 =
Expand Down
8 changes: 5 additions & 3 deletions src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ 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"]

Expand Down Expand Up @@ -539,12 +540,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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5296,10 +5296,13 @@ 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(
Expand Down