[Gambas-user] Possibility to compile old bytecode

Tobias Boege taboege at gmail.com
Thu Jan 23 19:00:43 CET 2020


On Thu, 23 Jan 2020, Benoît Minisini wrote:
> Le 23/01/2020 à 16:52, Christof Thalhofer a écrit :
> > Hi,
> > 
> > as I do a lot programming of production code for computers with older
> > Gambas versions (3.9, 3.11) I now have a big problem with "Bytecode too
> > recent" errors, as soon as I use the current dev version and later
> > version 3.15 and so on.
> > 
> > Would it be possible to create a compiler flag to let gbc3 compile to
> > older bytecode?
> > 
> > This would help me a lot because otherwise I had to keep up an older
> > Gambas version.
> > 
> > If it is not possible or if it is a pain I would have to work with
> > virtual machines. This is not a big problem, but a bigger one would be
> > if I'd like to realize automatic deployment later on.
> > 
> > 
> > Alles Gute
> > 
> > Christof Thalhofer
> > 
> 
> If you know that you don't use new language feature, you can force the
> compiler to save a specific bytecode version with the GB_PCODE_VERSION
> environment variable. For example GB_PCODE_VERSION=3.8.
> 
> Beware that it "does not compile to older bytecode". You need an older
> compiler for that. So if you use it incorrectly, the interpreter will
> segfault, abort or have an undefined behaviour.
> 
> The better being not to use a development version for production code!
> 

The easiest proper fix -- I'm not sure if you're aware of it -- is to
upload the source archive of the project to the production machine,
force a recompilation of it with the old compiler (`gbx3 -a`) there
and then run it. This will politely tell you if your Gambas code uses
features that are too new for the old runtime (no undefined behaviour),
even if the bytecode version is compatible.

There is only a problem if you must distribute a .gambas file without
the source code to the target.

Regards,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list