Skip to content

FFI refactor: reduce/remove indirect symbol lookup #277

@HamdaanAliQuatil

Description

@HamdaanAliQuatil

Today most of the native BoringSSL surface is reached indirectly through:

  • src/symbols.yaml
  • tool/generate_symbols_table.dart
  • src/symbols.generated.c
  • lib/src/boringssl/lookup/symbols.generated.dart
  • lib/src/boringssl/lookup/lookup.dart
  • lib/src/third_party/boringssl/generated_bindings.dart

The core pattern is:

  • export one webcrypto_lookup_symbol(index) function from src/webcrypto.c
  • map symbol name -> enum -> index in Dart
  • resolve function pointers at runtime
  • call most of BoringSSL through BoringSsl.fromLookup(lookup)

This solved symbol-conflict concerns, but it has some downsides:

  1. It hides actual symbol usage from the linker/toolchain.
  2. It makes native tree shaking / dead stripping much harder.
  3. It keeps a fair amount of custom codegen and symbol-table machinery alive.
  4. It makes the native interface harder to reason about than direct bindings.

The single generic lookup function likely makes tree shaking effectively impossible in the current shape.

Goal

Rework the FFI layer so that more of the native surface is explicit and direct.

Possible directions:

  • move practical parts of the surface to direct @Native(..., assetId: ...) bindings
  • reduce dependence on BoringSsl.fromLookup(lookup)
  • keep wrapper/helper exports only where they are actually needed
  • if symbol conflicts are still a concern, evaluate prefixing/renaming exported symbols instead of using a generic runtime lookup trampoline

Non-goals

This issue is not the full prebuilt-assets rollout and not the full static-linking/tree-shaking redesign. It is the architectural cleanup needed before those later steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions