Repository navigation
Make AVM_MINIMAL_OPCODES default on MCUs - #2465
Merged
Merged
Conversation
AVM_MINIMAL_OPCODES compiled out bs_test_tail2 together with bs_test_unit, assuming that only the no_bs_match and no_ssa_opt_bs_ensure compiler options emit it. Since OTP 27, no_ssa_opt also makes the compiler fall back to bs_test_tail2, and so does beam_debug_info on OTP 28 and later, which Elixir 1.21 suggests as an erlc_options value. Such modules loaded fine, then aborted with "Undecoded opcode: 121". Always compile bs_test_tail2 in, and add a test compiled with no_ssa_opt, so the opcode is covered on every OTP version, including OTP 29 where no_bs_match is gone. Signed-off-by: Davide Bettio <davide@uninstall.it>
AVM_MINIMAL_OPCODES is about to become the default on microcontrollers, but CI never builds or tests it. Add a generic UNIX job with it. On such builds, skip the three tests that force the no_bs_create_bin or no_bs_match compiler options on OTP 27 and 28: their modules use the opcodes the option leaves out, and the VM would abort the whole run. Signed-off-by: Davide Bettio <davide@uninstall.it>
petermm
approved these changes
Nov 2, 2026
Flash space is tight on microcontrollers, and the opcodes that AVM_MINIMAL_OPCODES leaves out are emitted only by the legacy no_bs_create_bin, no_bs_match and no_ssa_opt_bs_ensure compiler options. No OTP release from 27 to 29 emits them with its default options, and neither the Elixir nor the Gleam compiler passes those options. Enable it by default on ESP32 and RP2 too, like STM32 already does. This also covers ESP32-C5, which had its own special case. Generic UNIX and emscripten keep the full opcode set. Document the option and describe what it leaves out more precisely. Signed-off-by: Davide Bettio <davide@uninstall.it>
bettio
force-pushed
the
minimal-opcodes-on-mcus
branch
from
November 3, 2026 22:47
ffca1f9 to
0faafa7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
AVM_MINIMAL_OPCODES leaves out opcodes that the compiler emits only
with legacy options, saving flash on microcontrollers. It also left
out bs_test_tail2, which OTP 27+ still emits with no_ssa_opt and
beam_debug_info (OTP 28+), so such modules aborted with "Undecoded
opcode: 121". With bs_test_tail2 always compiled in, code compiled
with default options on OTP 27+ (Erlang, Elixir and Gleam) never
needs the left-out opcodes, so the option is now on by default for
ESP32, STM32 and RP2. Generic UNIX and emscripten keep it off.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later