Skip to content

Add in memory object files support to CompiledModule and ArchiveBuilder #69946

Description

@bjorn3

https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/struct.CompiledModule.html

https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/back/archive/trait.ArchiveBuilder.html

rustc_codegen_cranelift can emit object files to memory without writing them to the disk. With the current setup they need to be written to the disk before an rlib can be created. This doubles the amount of data written to the disk compared to emitting the object files to memory and then creating an rlib file from that. Linking a dylib or executable will still need to write the object files to the disk, but at least rlibs don't have to anymore.

Activity

  1. added
    A-codegenArea: Code generation
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    I-compiletimeIssue: Problems and improvements with respect to compile times.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 12, 2020
  2. added
    A-craneliftThings relevant to the [future] cranelift backend
    on Mar 12, 2020
  3. hanna-kruppe commented on Mar 15, 2020

    @hanna-kruppe
    Contributor

    Aside: LLVM also supports emitting object files into memory (just pass a raw_string_ostream instead of a raw_fd_ostream), so if this feature gets implemented for cranelift codegen and helps there, it might help LLVM codegen too.

  4. bjorn3 commented on Mar 15, 2020

    @bjorn3
    MemberAuthor

    We may want to only do this when the total size of all codegen units is below a certain threshold to reduce max-rss for big crates like script and rustc. (Assuming that LLVM performs the archive building in a streaming way like cg_clif.)

  5. bjorn3 commented on Dec 15, 2022

    @bjorn3
    MemberAuthor

    cc #104191 for the archive builder part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-craneliftThings relevant to the [future] cranelift backendC-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions