all: add -output= flag for setting print/panic output #1440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This flag allows setting the standard output to a few different values:
-output=none: do not produce output. This is useful for some systems that lack a native output (e.g. Digispark) or for WebAssembly where the additional wasi output dependency may be a problem.-output=native: use native output for the target, for example stdout on an OS or the native output of QEMU under emulation.-output=uart: use UART output, the default for most microcontrollers.-output=custom: allow setting a custom output with runtime.SetOutput. This provides flexibility for those who need it.It is quite an invasive change, and it might break things. I have not tested this extensively.
In particular, this includes a change to the Teensy 3.6 to be more like other targets. It now configures the UART at startup and thus no longer needs to configure it on demand when needed. It also doesn't call
runtime.Gosched()from the machine package anymore, greatly simplifying the code (this is better solved with #1172 anyway).Even though there are some more calls, I compared code size before and after and it doesn't change, except for atmega where it is two bytes (one instruction) reduced for some reason. But examples/serial still works on my Uno so I don't think this is something to worry about.