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

(bazel) cc-toolchain-wasm does not have mandatory providers: TemplateVariableInfo #1378

Closed
allsey87 opened this issue May 3, 2024 · 2 comments
Assignees

Comments

@allsey87
Copy link

allsey87 commented May 3, 2024

While wasm_cc_binary works nicely, I feel like I am quite in the dark when it comes to figuring out build a cmake or autotools based project inside of Bazel + Emscripten. For example, I am currently trying to get libffi to build inside Bazel using this script and have come up with the following:

# WORKSPACE
LIBFFI_COMMIT = "f08493d249d2067c8b3207ba46693dd858f95db3"
LIBFFI_BUILD_FILE_CONTENT = """
package(default_visibility = ['//visibility:public'])
filegroup(
    name = "all",
    srcs = glob(["**"]),
)
"""

http_archive(
    name = "libffi_src",
    sha256 = "0c4e5647b79e21b900eb872dd98a3e0a66be12b36ad89677f61fd901a2615778",
    url = "https://github.com/libffi/libffi/archive/{}.tar.gz".format(LIBFFI_COMMIT),
    build_file_content = LIBFFI_BUILD_FILE_CONTENT,
    strip_prefix = "libffi-{}".format(LIBFFI_COMMIT),
)
#BUILD
genrule(
    name = "libffi",
    srcs = ["@libffi_src//:all"],
    cmd = "cd external/libffi_src && ./testsuite/emscripten/build.sh  --wasm-bigint",
    # tools = [
    #     "@emscripten_bin_linux//:compiler_files",
    #     "@emsdk//emscripten_toolchain:compiler_files"
    # ],
    toolchains = ["@emsdk//emscripten_toolchain:cc-toolchain-wasm"],
    outs = ["libffi.a"]
)

However, this is reporting error:

ERROR: /workspaces/builder-bazel/main-emscripten/BUILD:38:8: in toolchains attribute of genrule rule //main-emscripten:libffi: '@@emsdk//emscripten_toolchain:cc-toolchain-wasm' does not have mandatory providers: 'TemplateVariableInfo'
ERROR: /workspaces/builder-bazel/main-emscripten/BUILD:38:8: Analysis of target '//main-emscripten:libffi' failed
ERROR: Analysis of target '//main-emscripten:libffi' failed; build aborted
INFO: Elapsed time: 0.044s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

Am I do something wrong here or is there an issue with the toolchain configuration?

@walkingeyerobot
Copy link
Collaborator

try passing --platforms=@emsdk//:platform_wasm and set the toolchains attribute of your genrule to @bazel_tools//tools/cpp:current_cc_toolchain

@allsey87
Copy link
Author

This works although for completeness, I would add that it doesn't seem like there is a need to pass @bazel_tools//tools/cpp:current_cc_toolchain to the toolchains attribute of the genrule if --platforms=@emsdk//:platform_wasm was already specified.

For the moment, I have just placed build --platforms=@emsdk//:platform_wasm in my .bazelrc since my whole workspace is targeting Emscripten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants