Skip to content

Bootstrap stage1 resolves bare write to the libc extern (fd, buf, n), release binary to std.builtins.write — enum_discriminant_flags red on stage1 only #1320

Closed

Description

@ehartford

Found while running the enum test set on a fresh :dev stage1 for #1313/#1310 (base cffb1cb).

test/behavior/enum_discriminant_flags.w has use std.builtins.write and calls write(int_to_string(Flags.X)). Under the installed release compiler (with v0.15.2.1-g478b26481) it passes (012124). Under a bootstrap stage1 — both ~/with/out/bootstrap/bin/with-stage1 built from main at cffb1cb and a fresh one in a worktree at the same base — the check fails:

error: function 'write' expects 3 argument(s), found 1
 --> test/behavior/enum_discriminant_flags.w:17:5
error: wrong argument type in call to 'write'
  = note: parameter 'fd' expects i32

i.e. the explicit use std.builtins.write loses to the libc write(fd, buf, n) extern on stage1, while the release binary resolves the explicit import. Same class as the known stage1-only reds (spec_ss16, -e, hash_engines): the two binaries embed/resolve the std surface differently, and a D29-global extern outranks an explicit symbol import (#1153 noted builtins need explicit precedence). An explicit use std.builtins.write must win everywhere, and stage1 and the release binary must agree.

Repro: with build :dev && out/bootstrap/bin/with-stage1 test test/behavior/enum_discriminant_flags.w.

Activity

  1. ehartford commented on Oct 2, 2026

    @ehartford
    ContributorAuthor

    Fixed on main 1688728. Seed-built bootstrap stage1 (with build :dev, with v0.15.3.0-g168872857):

    darwin-aarch64:

    $ out/bootstrap/bin/with-stage1 test test/behavior/enum_discriminant_flags.w
    012124ok: 1 test passed in test/behavior/enum_discriminant_flags.w
    

    linux-x86_64 (eric-5090, fresh clone ~/with-ladder/verify, pinned seed, dev rc=0): same output, rc=0.

    The explicit use std.builtins.write wins over the libc extern on stage1.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions