Skip to content

Link a windowed Windows program from a subsystem line in ens.package - #340

Merged
AlexDicy merged 2 commits into
mainfrom
agent/338-windows-subsystem
Dec 1, 2026
Merged

AlexDicy merged 2 commits into
mainfrom
agent/338-windows-subsystem

Conversation

@DicyAgent

Copy link
Copy Markdown
Collaborator

Closes #338

A package can now set the subsystem of a Windows program in ens.package:

package demo.win {
    ens "0.1";
    subsystem "windows";
}
  • subsystem "windows"; links the program for the windows subsystem, so it starts with no console window. subsystem "console"; is the default and what a manifest with no line gets.
  • The entry is mainCRTStartup on both COFF link paths when the program is windowed, which fixes the undefined symbol: WinMain failure for a package that names a library the build does not carry.
  • Only the package being built is read. Other platforms ignore the line.
  • The language server's manifest reader accepts the line.

Verified:

  • Linux host, ens build --target x86_64-pc-windows-msvc: the windowed program has PE Subsystem = 2, the default program has Subsystem = 3.
  • xmake test on Linux: selfhost_frontend, selfhost_sema, selfhost_link, selfhost_build, selfhost_syntaxgen, selfhost_driver, semacheck, corpus_roundtrip, ens_lsp pass.

Not verified here:

  • Running a windowed program on Windows (no console, print output). The issue's measurements stand.
  • Linking a windowed package that names user32: this host has no Windows SDK, so only the argument line is pinned, in argv_test.

Left open, as the issue says: whether the runtime or the program re-attaches the standard output when a console opens later.

…ixes #338

Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
@DicyAgent

Copy link
Copy Markdown
Collaborator Author

Pushed 80c1796.

@DicyAgent
DicyAgent marked this pull request as ready for review November 30, 2026 11:40

@AlexDicy AlexDicy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting on CI

@AlexDicy
AlexDicy merged commit 7eeab01 into main Dec 1, 2026
23 of 24 checks passed
@AlexDicy
AlexDicy deleted the agent/338-windows-subsystem branch December 1, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ens build links every Windows program for the console subsystem, so a program meant to run unseen opens a console window

2 participants