Casio Compiler Explorer Setup Tutorial!
Posté le 04/09/2022 16:08
Today I will show you how to run a local instance of compiler explorer (
https://godbolt.org) with a compiler option for Casio calculators! Please note I have only tried this on Linux although it probably also works on MacOS.
#Step 0: Install basic build tools for your operating system
On Linux it is often “build-essential” if you are on a debian based distro or “base-devel” if you are on an Arch based distro. On MacOS it is “xcode-select --install”. If that doesn’t work you may need to install XCode from the AppStore first (please note I am not a Mac expert).
#Step 1: Install nodejs and npm
If you already have them installed make sure you are using node version 16 LTS release and skip to step 2. It is not recommended to install nodejs and npm from your Linux distro’s repository! You should install them with a version manager like nvm or fnm. I will show you how to use fnm which is written in rust.
If you are using MacOS you should install fnm with homebrew. Then go to (
https://github.com/Schniz/fnm#shell-setup) and use the instructions for your shell and go to step 2. If you are unsure which one you have, type "echo $0" into the terminal and it will tell you. To install nodejs and npm type “fnm install 16” followed by “fnm use 16”.
If you are on Linux do not install rustup or cargo from your Linux distro’s repository! Instead, go to the rust website (
https://www.rust-lang.org/tools/install) and use the script to install rustup. Press 1 and hit enter to proceed with the default installation. Once it is finished you must close and reopen your terminal. Now type “cargo install fnm”. Once it is installed go to (
https://github.com/Schniz/fnm#shell-setup) and use the instructions for your shell and go to step 2. If you are unsure which one you have, type "echo $0" into the terminal and it will tell you. To install nodejs and npm type “fnm install 16” followed by “fnm use 16”.
#Step 2: Install Compiler Explorer
Go to (
https://github.com/compiler-explorer/compiler-explorer) and clone the repository to the directory of your choice. Then go into the directory and type “make”. If all has gone according to plan after a while (it can take quite some time) it should compile and you can access compiler explorer at
http://localhost:10240. For now, just Ctrl+C to stop it and proceed to step 3.
#Step 3: Install the Casio calculator compiler and build tools
Go to (
https://gitea.planet-casio.com/Lephenixnoir/GiteaPC) and install giteapc. If you are using MacOS make sure to also look at (
https://www.planet-casio.com/Fr/forums/topic16614-8-giteapc-installer-et-mettre-a-jour-automatiquement-des-projets-gitea.html#186763). You may need to restart your terminal after you are done installing giteapc. Now we need to install gint and the compiler. Type “giteapc install Lephenixnoir/gint”. Please note that this will compile a lot of stuff including gcc and binutils so it will take quite some time. After that restart your terminal once more. Once that is done continue to step 4.
#Step 4: Configure compiler explorer to add an option for a casio compiler
If you want to download the config files instead I will attach them (
https://gitea.planet-casio.com/Atrt7/Compiler-Explorer-Casio-Config). For additional information read (
https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/AddingACompiler.md). Please note in the provided config files you must put your username in the fields that require them, search for username and you fill find two in each config file. In the directory for compiler explorer go into the “etc” directory and then go into the “config” directory. Copy the file “c.defaults.properties” and paste it into the same directory with the name “c.local.properties”. Open “c.local.properties” and change the second line from “compilers=:&gcc:&clang” to “compilers=:&gcc:&clang:&casio”. By doing this we will add a Casio compiler group. Go to the bottom of the file and copy the following after an empty line.
group.casio.compilers=ccasiodefault
compiler.ccasiodefault.exe=/home/ChangeToYourUsername/.local/bin/sh-elf-gcc
compiler.ccasiodefault.supportsExecute=false
compiler.ccasiodefault.needsMulti=false
compiler.ccasiodefault.objdumper=/home/ChangeToYourUsername/.local/bin/sh-elf-objdump
compiler.ccasiodefault.name=casio default
Make sure you put your username where ChangeToYourUsername is, there are two spots. Also where it says “defaultCompiler=gdefault” change "gdefault" to “ccasiodefault”. Now we must do the same for c++. Copy “c++.defaults.properties” and name the copy “c++.local.properties”. Open “c++.local.properties” and change the second line from “compilers=:&gcc:&clang” to “compilers=:&gcc:&clang:&casio”. You will notice a block of continuous lines that starts with
group.gcc.compilers=g44:g45:g46:g47:g48:g5:g6:g7:g8:g9:g10:g11:gdefault
and ends with
compiler.gdefault.name=g++ default
After this continuous block of configurations add a blank line followed by
group.casio.compilers=cppcasiodefault
compiler.cppcasiodefault.exe=/home/ChangeToYourUsername/.local/bin/sh-elf-g++
compiler.cppcasiodefault.supportsExecute=false
compiler.cppcasiodefault.needsMulti=false
compiler.cppcasiodefault.objdumper=/home/ChangeToYourUsername/.local/bin/sh-elf-objdump
compiler.cppcasiodefault.name=casioc++ default
Please note that you must put your username where ChangeToYourUsername is, there are two spots. Now go to the bottom of the file. Finally around the bottom of the file there should be a line that says “defaultCompiler=gdefault”. Change “gdefault” to “cppcasiodefault”.
#Step 5
Now everything should be set up, you can go to the top of the compiler explorer directory and type “make” again and everything should work. Because we don’t have a fully set up cmake project in compiler explorer, you must put “#define FX9860G” or “#define FXCG50” for the respective platform you are using if you want to use gint headers in compiler explorer. Don’t put that #define in your actual project code however, only use it for compiler explorer. Also if you want many more languages and architectures for your local compiler explorer instance read (
https://github.com/compiler-explorer/infra). Note that these are the ones you find on godbolt not anything related to casio calculators.
If you get a makefile error after running “make” try “make clean” and then “make” again.
Please let me know if everything works and if there are any mistakes or any improvements I can make. I hope my work proves helpful to you all!