Skip to content

Large types cause linker failure #130729

Open
@benwis

Description

@benwis

So I'm one of the maintainers of Leptos, and we're experimenting with a new static type system for our next release. The issue we're having is that for people porting existing websites/apps to the beta, experience a linker issue with link.exe, lld, mold, and ld. Our theory is that once the types reach a certain size, it will crash the linker.

In this version we're encoding the HTML tree into the type system by constructing View<> types that contain a tuple of it's descendants.
You can see what that looks like in the below code, which does not crash.

#Cargo.toml
[package]
name = "linker_issue"
version = "0.1.0"
edition = "2021"

[dependencies]
leptos = { git = "https://github.com/leptos-rs/leptos", features = ["ssr"] }
// main.rs
use leptos::html::{div, p, HtmlElement};
use leptos::prelude::*;

fn main() {
    let view: HtmlElement<_, _, _, Dom> = div().child((
        div().child((div(),)),
        p().child((div(), div())),
        div().child((div(), div(), div())),
        p().child((div(), div(), div(), div())),
        div().child((div(), div(), div(), div())),
        p().child((div(), p(), div(), div())),
        div().child((div(), div(), p(), div())),
        p().child((div(), p(), div(), p())),
    ));
    println!("type: {:?}", std::any::type_name_of_val(&view));
    println!("\n\nsize: {:?}", std::mem::size_of_val(&view));
    let html = view.to_html();
    println!("\n\noutput: {html}");
}

So far we haven't nailed down a reasonable reproduction I can post, but I can reproduce the issue while trying to build one of our user's private projects. Running cargo leptos build, which runs cargo build --no-default-features --features=ssr, generates this error. I've put it in a gist because it is huge: https://gist.github.com/benwis/fe3a8010243c0f6b338f6aef0b0e7ad2

I'm not quite sure how to debug this, we'd love to use this system as it offers a number of benefits, but if it's going to break compilation at larger app sizes we'll have to defer. Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.E-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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