Skip to content

feat: Replace file_ops WASM Component with Bazel-Native Operations #252

@avrabe

Description

@avrabe

Summary

Replace the custom file_ops WASM component with Bazel-native file operations to reduce dependencies and improve performance.

Current State

  • Custom file_ops WASM component for cross-platform file operations
  • Runs via wasmtime to copy/move/create files
  • Adds overhead: wasmtime startup + WASI filesystem operations
  • Used extensively in cpp_component, wit_library, etc.

Why file_ops Exists

  • Cross-platform (Windows) compatibility
  • Replaces shell scripts (cp, mv, mkdir)
  • Provides consistent behavior

Proposed Solution

Replace file_ops with Bazel-native operations:

file_ops Operation Bazel Alternative
copy_file ctx.actions.symlink() or ctx.actions.run() with platform tool
create_directory Implicit in output paths
move_file ctx.actions.run() with platform tool
concatenate_files ctx.actions.write() or small helper binary

For Complex Cases

Use a small Go binary (already have Go toolchain for wac_deps tool).

Benefits

  • Remove wasmtime dependency from basic builds
  • Faster file operations (no WASM overhead)
  • Simpler debugging (native tools)
  • Smaller toolchain footprint

Risks

  • file_ops was created to solve real cross-platform issues
  • Need to verify Bazel-native alternatives work on Windows
  • Some operations may not have direct equivalents

New Features Enabled

  • Pure Bazel builds without runtime dependencies
  • Better integration with Bazel's action cache

Impact

  • Effort: Medium
  • Risk: Medium
  • Value: Medium

Related

  • Phase 4 shell elimination work already reduced file_ops usage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions