Skip to content

v2: self-compilation with -v2 uses excessive memory #27309

@GGRei

Description

@GGRei

Describe the bug

When trying to compile the V2 compiler by invoking V with -v2 directly on cmd/v2/v2.v, memory usage grows very high.

Reproduction Steps

From a fresh V checkout, run:

./v -v2 -o /tmp/v2_bootstrap cmd/v2/v2.v

If needed, also try the low-parallelism variants:

VJOBS=1 ./v -v2 -o /tmp/v2_bootstrap cmd/v2/v2.v
./v -v2 -no-parallel -o /tmp/v2_bootstrap cmd/v2/v2.v
VJOBS=1 ./v -v2 -no-parallel -o /tmp/v2_bootstrap cmd/v2/v2.v

For comparison, this command works and stays bounded:

./v -o /tmp/v2_bootstrap cmd/v2/v2.v

Expected Behavior

The command should either compile successfully with bounded memory usage or fail cleanly with an explicit compiler error.

It should not consume excessive memory, swap heavily or make the OS session unstable.

Current Behavior

The direct -v2 self-compilation path consumes excessive RAM.

Possible Solution

No response

Additional Information/Context

The memory blow-up happens inside the delegated V2 compiler during Transform and Mark Used and CleanC generation.

V version

V 0.5.1 10a27a3

Environment details (OS name and version, etc.)

Ubuntu 26.04 LTS

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions