Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Actually use our linker as the linker for sample/fastLinkJS. #47

Merged
merged 10 commits into from
Apr 1, 2024

Commits on Mar 31, 2024

  1. Downgrade to Scala 2.12.19.

    We will need the Wasm backend to be built for 2.12.x in order to
    load it as a true linker from the sbt build.
    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    ae074fb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0def8eb View commit details
    Browse the repository at this point in the history
  3. Use an OutputDirectory in Compiler to write the output.

    This way, we do not depend on Scala.js-specific APIs.
    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    8eab4df View commit details
    Browse the repository at this point in the history
  4. Cross-compile the wasm project.

    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    f50253a View commit details
    Browse the repository at this point in the history
  5. Write the output of each linking in a separate directory.

    An `OutputDirectory` is not supposed to be shared.
    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    81b1ec2 View commit details
    Browse the repository at this point in the history
  6. Derive the name of the output files from the module IDs.

    And delete stray files in the output directories, as is mandated by
    the contract of a linker backend.
    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    28f7c8b View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    df81d57 View commit details
    Browse the repository at this point in the history
  8. Replace the Compiler entry point by a real LinkerBackend.

    This follows the architecture of the Scala.js linker.
    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    44b5cb7 View commit details
    Browse the repository at this point in the history
  9. Make the linker backend actually produce the specified output shape.

    In addition to emitting the `.wasm` and `.wat` files in the output
    directory, we now also emit emit the internal `__loader.js` file,
    and the public module specified by the `ModuleSet`, such as
    `main.js`.
    
    We embed the content of the loader as a constant string in the
    backend, so that it works both on the JVM and on JS. Eventually, we
    will probably generate it more dynamically from
    `backend.javascript.Trees` anyway, so this not really a big deal.
    
    This change requires to adapt the loading mechanism to force URL
    resolution against the base directory of the `loader.js` file,
    rather than the working directly. We do this thanks to
    `import.meta.url`, which is also available in browsers.
    
    As is, this change destroys the semantics of top-level exported
    `var`s. Mutations performed after the module initializers have
    completed will not be reflected in the exports of `main.js`. We
    will need to revisit this later on, with a technique similar to the
    one used by the JS backend.
    
    With these changes, our linker backend actually abides by the
    specification of a `LinkerBackend`, which means we will be able to
    directly use it from sbt.
    sjrd committed Mar 31, 2024
    Configuration menu
    Copy the full SHA
    1e0f2e2 View commit details
    Browse the repository at this point in the history

Commits on Apr 1, 2024

  1. Actually use our linker as the linker for sample/fastLinkJS.

    Now, `sample/fastLinkJS` uses our WebAssembly linker, and
    `sample/run` actually executes the `main` method of the sample
    project, linked to WebAssembly.
    sjrd committed Apr 1, 2024
    Configuration menu
    Copy the full SHA
    b1b51ed View commit details
    Browse the repository at this point in the history