Skip to content

runtime: allow compile-time synctest checks on bare metal - #5974

Open
davecheney wants to merge 1 commit into
tinygo-org:devfrom
davecheney:davecheney-synctest-compile-time-evaluation
Open

davecheney wants to merge 1 commit into
tinygo-org:devfrom
davecheney:davecheney-synctest-compile-time-evaluation

Conversation

@davecheney

Copy link
Copy Markdown
Contributor

Initialization in the time package and channel initialization call synctestIsEnabled even when the program does not use testing/synctest. The interpreter cannot evaluate its atomic load. On unicore targets, earlier runtime calls can also cause the ordinary load to be deferred because the state is marked as externally written.

Disable synctest on bare-metal targets so that the enabled check can be evaluated at compile time. Hosted synctest support is unchanged. Attempts to start a synctest bubble on bare metal fail explicitly.

For the time/channel/context fixture at -opt=1, linked firmware saves 128 bytes of flash and 8 bytes of static RAM on RP2040 unicore, and 80 bytes of flash and 8 bytes of static RAM on RP2350 cores.

LLVM already removed the inactive remainder of the synctest logic later in the optimization pipeline. This change removes the earlier interpretation barrier, not an otherwise retained synctest engine.

@davecheney
davecheney requested a review from jakebailey October 21, 2026 00:23
@davecheney

Copy link
Copy Markdown
Contributor Author

@jakebailey mia culpa, this is another example of you adding stdlib support and me going back and trying to compile it out on bare metal. Maybe once #5903 lands the same magic can be applied for the synctest flag.

@davecheney
davecheney force-pushed the davecheney-synctest-compile-time-evaluation branch from 0b4f9c8 to 7539f48 Compare October 21, 2026 03:26
@davecheney davecheney added this to the 0.45 milestone Oct 21, 2026
@davecheney
davecheney force-pushed the davecheney-synctest-compile-time-evaluation branch from 7539f48 to 1b0e5d6 Compare October 22, 2026 13:34

@jakebailey jakebailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems okay I guess, just not sure how one would ever be in this situation

@davecheney
davecheney force-pushed the davecheney-synctest-compile-time-evaluation branch from 1b0e5d6 to 65a3c95 Compare October 23, 2026 13:57
Initialization in the time package and channel initialization call
synctestIsEnabled even when the program does not use testing/synctest.
The interpreter cannot evaluate its atomic load. On unicore targets,
earlier runtime calls can also cause the ordinary load to be deferred
because the state is marked as externally written.

Disable synctest on bare-metal targets so that the enabled check can
be evaluated at compile time. Hosted synctest support is unchanged.
Attempts to start a synctest bubble on bare metal fail explicitly.

For the time/channel/context fixture at -opt=1, linked firmware saves
128 bytes of flash and 8 bytes of static RAM on RP2040 unicore, and
80 bytes of flash and 8 bytes of static RAM on RP2350 cores.

LLVM already removed the inactive remainder of the synctest logic
later in the optimization pipeline. This change removes the earlier
interpretation barrier, not an otherwise retained synctest engine.
@davecheney
davecheney force-pushed the davecheney-synctest-compile-time-evaluation branch from 65a3c95 to e29b812 Compare October 23, 2026 22:35
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