I sometimes run multiple versions of Emacs from the same home directory. I have a number of byte-compiled files. Bytecode is not compatible across all Emacs versions, so I maintain separate directories for
.elc files for each version range.
What are the version ranges for which the bytecode is compatible? I currently have
gnu-19.29 gnu-20 gnu-21 gnu-22 gnu-23 gnu-24 source x-19 x-20 x-21
i.e. directories for each major release, with an additional separation at 19.29 (I've never used an older version on this machine, otherwise there'd be
gnu-19), and separate directories for GNU Emacs and XEmacs. I'm probably overly cautious, though.
What is the official policy regarding bytecode compatibility across Emacs versions? Can I confidently keep using the major version? Can I merge some versions? Is there a bytecode version indication or checksum that I could query when compiling to create the directory name instead of relying on the Emacs version?
Note that I'm primarily interested in full compatibility, not just backward compatibility. I might run Emacs 27.3 and byte-compile some files, and then later Emacs 27.2 with the same home directory.