Skip to content

consolidate libc and libssp into compiler-rt #7265

@andrewrk

Description

@andrewrk

Right now, zig generates a "c" library that has functions such as memcpy and sqrt because LLVM generates code that on those symbols. I propose to make zig's compiler-rt have all the symbols that codegen depends on, regardless of what library will typically provide them. Then our existing trick of using weak exports (which can be overridden by e.g. linking against libc) will make sure we don't provide too many functions. We already use function-sections to omit unused symbols.

The benefits of this are simplicity, which will become even more clear when we have 2 competing backends: the LLVM one and the self-hosted zig one, which will each require a different set of compiler-rt symbols. We may even want to expose a build option to compiler-rt.zig (or maybe a different entry point?) so that compiler-rt source can know which backend it needs to provide symbols for.

The simplicity is not only for zig compiler developers, but for users as well. For example, this would simplify the usage of #7264 - we would not need equivalent CLI flags for these other 2 libs, and users would not need to deal with all 3 things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions