Skip to content

unix: stop generating sparc termbits from the generic header - #288

Open
shalseth wants to merge 1 commit into
golang:masterfrom
shalseth:sparc64-termios
Open

unix: stop generating sparc termbits from the generic header#288
shalseth wants to merge 1 commit into
golang:masterfrom
shalseth:sparc64-termios

Conversation

@shalseth

@shalseth shalseth commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

mkerrors.sh takes the generic termbits header on sparc rather than the
architecture's own:

#if defined(__sparc__)
#include <asm-generic/termbits.h>
#else
#include <asm/termbits.h>
#endif

sparc's termbits differs from the generic one, so the constants it produces
for that architecture are wrong. VMIN is the clearest case: sparc defines it
as an alias, #define VMIN VEOF with VEOF 4, where the generic header defines
a literal 6. Raw mode is termios.Cc[unix.VMIN] = 1 in moby/term,
containerd/console and x/term alike, so with 6 the assignment lands in a
slot nothing reads, the real VMIN keeps its default of 4, and reads on a
terminal block until four bytes arrive. On sparc64 that made interactive
docker run -it deliver stdin in 4-byte groups.

It is not only VMIN. Switching to the architecture's header changes 25
constants. The baud rates are the most visible: B1000000 is 0x100c on
sparc but 0x1008 is generated, and B2500000, B3000000, B3500000 and
B4000000 do not exist on sparc while B76800, B153600, B307200 and B614400
do and are absent. FLUSHO, WRAP, VDSUSP, TIOCM_LOOP, TIOCM_OUT1,
TIOCM_OUT2, TIOCSER_TEMT, VEOL and VEOL2 are also affected.

The comment justifies the workaround by a struct redefinition clashing with
glibc, but that cannot arise here: the include block is used in exactly one
place, the $CC -x c - -E -dM pass, which only preprocesses. Feeding it both
<termios.h> and <asm/termbits.h> on sparc64 emits every macro with empty
stderr.

No other architecture is affected, since they already took the #else branch.

Verified by running mkerrors.sh on an UltraSPARC T4-1: unmodified it
reproduces the checked-in VMIN=0x6, VEOL=0xb, VEOL2=0x10, and with this
change it produces 0x4, 0x5, 0x6.

zerrors_linux_sparc64.go still needs regenerating through the Docker
pipeline to pick these up; this CL only corrects the generator.

Updates golang/go#55000

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: d775441) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/sys/+/820180.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Ian Lance Taylor:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/820180.
After addressing review feedback, remember to publish your drafts!

mkerrors.sh takes the generic termbits header on sparc rather than the
architecture's own:

	#if defined(__sparc__)
	#include <asm-generic/termbits.h>
	#else
	#include <asm/termbits.h>
	#endif

sparc's termbits differs from the generic one, so the constants it produces
for that architecture are wrong. VMIN is the clearest case: sparc defines it
as an alias, #define VMIN VEOF with VEOF 4, where the generic header defines
a literal 6. Raw mode is termios.Cc[unix.VMIN] = 1 in moby/term,
containerd/console and x/term alike, so with 6 the assignment lands in a
slot nothing reads, the real VMIN keeps its default of 4, and reads on a
terminal block until four bytes arrive. On sparc64 that made interactive
docker run -it deliver stdin in 4-byte groups.

It is not only VMIN. Switching to the architecture's header changes 25
constants. The baud rates are the most visible: B1000000 is 0x100c on
sparc but 0x1008 is generated, and B2500000, B3000000, B3500000 and
B4000000 do not exist on sparc while B76800, B153600, B307200 and B614400
do and are absent. FLUSHO, WRAP, VDSUSP, TIOCM_LOOP, TIOCM_OUT1,
TIOCM_OUT2, TIOCSER_TEMT, VEOL and VEOL2 are also affected.

The comment justifies the workaround by a struct redefinition clashing with
glibc, but that cannot arise here: the include block is used in exactly one
place, the $CC -x c - -E -dM pass, which only preprocesses. Feeding it both
<termios.h> and <asm/termbits.h> on sparc64 emits every macro with empty
stderr.

No other architecture is affected, since they already took the #else branch.

Verified by running mkerrors.sh on an UltraSPARC T4-1: unmodified it
reproduces the checked-in VMIN=0x6, VEOL=0xb, VEOL2=0x10, and with this
change it produces 0x4, 0x5, 0x6.

zerrors_linux_sparc64.go still needs regenerating through the Docker
pipeline to pick these up; this CL only corrects the generator.

Updates golang/go#55000

Change-Id: I75880b535aac0b76e7ff6ab85c1db3af7c993770
@shalseth shalseth changed the title unix: fix VMIN, VEOL and VEOL2 on linux/sparc64 unix: stop generating sparc termbits from the generic header Aug 24, 2026
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 7ed5963) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/sys/+/820180.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Stian Halseth:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/820180.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Ian Lance Taylor:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/820180.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Stian Halseth:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/820180.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Ian Lance Taylor:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/820180.
After addressing review feedback, remember to publish your drafts!

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.

2 participants