Skip to content

Towards eliminating the global ctx variable for lld/wasm #119180

Open
@anutosh491

Description

@anutosh491

The goal is to drop the reset function as pointed here.

For this we can do the following (inspired by changes in lld/ELF & https://maskray.me/blog/2024-11-17-removing-global-state-from-lld)

  • Move driver into ctx and add LinkerDriver::ctx
  1. f596d82#diff-5514d8102381f1f4b47bfb1caf0b7c06bbc3b3d2677c6844d0001eb022b64d88
  2. bffb26f#diff-5514d8102381f1f4b47bfb1caf0b7c06bbc3b3d2677c6844d0001eb022b64d88R94
  • Move Config into ctx and migrate LinkerDriver member functions to use ctx.arg.x instead of
    config->x
  1. d904542
  2. e1a1f18
  3. eba30b3#diff-1a6e8fdd6339ca831ba81ed9fb4f94c42419f91d67c9e16322b71a3e011b42d2
  • Add Context aware diagnostic functions
  1. 201d760#diff-aab11f6988e1c802cd24d6e9842068288284b0a06366b0121f37493c929bd8e0R55
  • Pass ctx to bAlloc/saver/uniqueSaver
  1. a626eb2#diff-5514d8102381f1f4b47bfb1caf0b7c06bbc3b3d2677c6844d0001eb022b64d88R109
  2. 2991a4e#diff-ba5e9bcbcabe54e23f58f9466afb49d9720373eb11b9b3a42ddc2d653b035594
  • Miscallaneous like
  1. Move symtab into ctx (df0864e#diff-9e4503a72c1e0c0a2743852386d5e9a99574f6e6a25be24160269e729fb1e433)
  2. Pass ctx to InputFiles (4986510_
  3. etc
  • Finally we can get rid of reset and the ctx global variable . Also let Ctx inherit from CommonLinkerContext
  1. 73bb022#diff-5514d8102381f1f4b47bfb1caf0b7c06bbc3b3d2677c6844d0001eb022b64d88R115
  2. 8f238f6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions