How-To: LM32 Soft-CPU - Compiler
This how-to describes the status and how-to build the compiler for the lm32 soft-cpu.
Info on Mailing List white-rabbit-dev (8 Feb 2019)
Recently I worked with GSI on a rebuild of the lm32 compiler. What
most of us is using is an old 32-bit build of mine (Nov 2011), that
Wesley uploaded to ohwr (http://www.ohwr.org/attachments/1301/ or
https://www.ohwr.org/attachments/1133/lm32.tar.xz) and for which no
rebuild instructions are available.
So I rebuilt that one on a 64-bit host, but I had to work around some
errors, because newer versions (the host ones) are more picky.
I also built all newer versions, but the lm32 binaries they
generate are bigger. I documented the whole process.
[while trying to upload, I found Greg already put a 64-bit build
into ohwr, but I never heard about it before]
I pushed this lm32-toolchain repository (documentation and scripts) to
gitlab. The "pdf" branch includes the pdf for documentation, for your
convenience. Being unable to push binaries to ohwr.org (for unknown
reasons), I created a different gitlab repository with the binaries; I
pushed out the known-good 4.5.3 and the latest one: 8.2.0. If they
are of any interest I can try to push to the new ohwr later on. In any
case don't count on the gitlab.com links as a long-time resource. The
The latter can be reduced for sure, because binaries include full
debugging symbols, but this is what I have now. The archives
uncompress to a directory with the same name (lm32-gcc-4.5.3/ etc), it
can go into /opt or wherever you prefer. The executable file is
bin/lm32-elf-gcc, as usual; you can modify $PATH or set $CROSS_COMPILE
as common practice.
Things to do in the next days:
- run the compilers under common linux distributions and look for
library incompatibilities; try to fix them
- try llvm/clang for lm32
- make sure gcc-4.5.3 can be built with newer host compilers.
I hope this work can be useful; any feedback is welcome.
git clone https://gitlab.com/rubini/lm32-toolchain.git
pdf of the document:
Building the Compiler
See the pdf (link above) for detailed instructions. It is recommended to build the compiler on a standard linux (citation form the pdf: "Currently, I only run the build on Debian-8, using a 64-bit installation. The host compiler is
gcc-4.9.2. This matches what lx-pool.gsi.de is, so it’s a good first step.").
Let's go to lx-pool using configuration
// clone the repo
# git clone https://github.com/GSI-CS-CO/lm32-toolchain.git
# cd lm32-toolchain/
# git checkout < tagname > // use a dedicated tag
// build the compiler
# ./tools/build-generic configs/gcc-4.5.3-updated
// create tar file
# cd install
# D=lm32-gcc-YYMMDD-CONFIG_HASH-REPO_HASH // consider auto-completion
# mv $D lm32-elf-gcc
# tar cJf lm32-elf-gcc.tar.xz lm32-elf-gcc
# mv lm32-elf-gcc $D
// here it is
# lm32-elf-gcc.tar.xz lm32-gcc-YYMMDD-CONFIG_HASH-REPO_HASH
// finally, upload the tar.gz to github -> GSI-CS_CO -> lm32-toolchain -> tag -> release
- 02 September 2020