Esterel is a language to design control-dominated systems (basically Mealy machines). ECL (Esterel C Language) is an extension for Esterel that implements a C-like syntax, so it’s supposedly easier to write and less verbose. Never heard of these? Well, me neither, until I had to study them for an exam. I got curious in what they are and I spent some time installing the compilers. Because it looks like a relatively obscure technology, I also documented my experience.
Keep in mind that this is all pretty old stuff (the ECL document is dated October 24, 2001), the installation requires digging through unmaintained dependencies and decades-old unsupported software which can be quite frustrating, but equally rewarding and fun.
Installing Esterel
Installing Esterel is relatively straight-forward. The first step is to download the latest version from the official website.
Once downloaded, extract in a directory of your choice and run the setup
script with root priviledges. The nice (although appreciably old-school) graphical interface will take care of correctly setting up the paths and create symbolic links for you (if you enable them). Alternatively, a Makefile
is provided for non-interactive installation, just set the variables manually.
An uninstall
script will be created to undo the installation (I trust it will work, I have not tested it).
Installing ECL
Installing ECL is a little big more tricky. You can download the source code from the ECL SourceForge page but you have to compile it yourself. Download the code and extract it where you want.
Then, you will need a Java Runtime Environment and a Java Development Kit, as the compiler is written in Java.
After some testing, because the compiler uses ancient syntax, Java 1.4 seems to be the latest usable version. Finding such a version for Linux is surprisingly unintuitive (download here), as versions newer than 1.4.2_19 are only available for Solaris; also Oracle requires a login to donwload them. So, one burner account later, I am the proud owner of the ancient j2re-1_4_2_19-linux-i586.bin
and j2sdk-1_4_2_19-linux-i586.bin
for linux (I didn’t even know i586 was a thing). These files will self-extract and you can just move the folders anywhere you want (/opt
in my case).
Java acquired, we are almost ready to compile ECL, we first need to set the following environmental variables. I have added these lines to my .bashrc
file, following the manual (these variables are not only needed to compile ECL, but also to execute ECL code, so they need to always be defined):
export ECL_CC="gcc -m32"
export ECL_JAVAC="/opt/j2sdk1.4.2_19/bin/javac"
export ECL_JAVAVM="/opt/j2re1.4.2_19/bin/java"
export ECL_HOME="/opt/ecl-3.1.0"
export ESTERELHOME="/opt/esterel-5.92"
export CLASSPATH="$ECL_HOME/src:$ECL_HOME/util/JavaCup:$ECL_HOME/util:$ECL_HOME/xecl"
This is the script I used to compile ECL, just save it in the $ECL_HOME
directory and run it:
# variables redefined in a way that ECL expects
export CC=${ECL_CC}
export JAVAC=${ECL_JAVAC}
export JAVAVM=${ECL_JAVAVM}
export ECL=${ECL_HOME}
# utils
make -C "util"
# ECL compiler
make -C "src"
# xecl
make -C "xecl"
The file $ECL_HOME/script/ecl
will run the java class. I did some modifications to it, in order to use the variables as I’ve set them, this is my modified version (it’s mostly the same, I just changed the variable names and added quotes for compiler flags, see next section for that):
#!/bin/bash
${ECL_JAVAVM} -DESTEREL="${ESTERELHOME}" -DCC="${ECL_CC}" ecl $*
Remember to set a symlink to ecl
inside your $PATH
.
xecl
is a graphical script to run ECL and Esterel, you will need to install the package libxtst6:i386
for it to work, and also modify a little the file $ECL_HOME/script/xecl
#!/bin/bash
${ECL_JAVAVM} -DESTEREL="${ESTERELHOME}" -DESTERELV6="${ESTERELHOME}" -DCC="${ECL_CC}" xecl $*
Compiling ECL files
Compiling the files is a little tricky because ECL expects a 32bit system. After a couple of hours of testing and some bruteforcing, only two steps are really required:
- add the
-m32
flag togcc
(which is why I had to add quotes to the$ECL_CC
variable), this is required sold
emulated the formatelf_i386
, otherwise it would throw all kind of errors about incompatibility with x86_64 - install the packages
gcc-9-multilib libc6-dev:i386
. This is the most delicate step. For some reason, installing old version of libc and libgcc risks messing up your packages. After some tries, this is the combination of packages that includes all the needed dependencies and don’t uninstall half of my system (it only required to uninstallgcc-7
and some components ofgcc-9
, but it left untouchedgcc-8
andgcc-10
, I stopped looking for a logic in this). Of cource, your mileage might vary, based on your specific system setup. Whatever you do, do not blindly accept whatever your package manager proposes you, you seriously risk messing up your system and corrupting your packages. But that should always be a common practive.
Verify that all is working by compiling and running the test files
make
cd abro
./abro.exe < abro.in
If you see the output signals, congratulations! You successfully installed ECL on your system. What can you do with it? A lot of things, basically emulating a Mealy state machine and test you logic with a C-like syntax; but as far as I can tell, no public project uses it, but feel free to mess with it for fun, that’s what I’ll be doing for sure.
Conclusions
My journey through exotic and ancient hardware design language brought me another intersting adventure. I will surely consider what I learnt when designing new projects.
I have also added ECL support to my sces (SCript-Executing Script) project, so check it out if you didn’t already!
If you use Esterel or ECL professionaly, please get in touch and consider sharing your experience, I am really curios to know how these technologies are used for in the real world!