Odin on CentOS 6

Odin requires relatively (to long-EOL distributions of Linux) recent versions of clang, so building Odin programs with odin probably minimally requires building a modern LLVM toolchain on CentOS 6.

linking with zig

zig's c++ support doesn't seem to be good enough to build the odin compiler, but for at least applications as complex as odinfmt, it works to

  1. compile to an object file with odin: odin build tools/odinfmt/main.odin -file -show-timings -collection:shared=src -out:odinfmt.o -o:speed -build-mode:obj
  2. link with zig: zig cc --target=native-linux-gnu.2.12 -o odinfmt odinfmt.o

horrible idea: deploying assembly

Here's an alternative that at least works for 'hello world':

  1. (CentOS 6) install devtoolset-8 from SCL or other repos (CentOS 6's native gcc definitely won't work for this)
  2. (CentOS 6) enable it, f.e. with . /opt/rh/devtoolset-8/enable
  3. (Odin-capable Linux) compile the program with odin... to assembly: odin build hello.odin -file -build-mode:asm
  4. copy the resulting hello.S file to the CentOS 6 box
  5. (CentOS 6) gcc hello.S -o hello

This has been tested and really does work. For 'hello world'. More complex programs will likely either require more complex incantations or just will not work as intended with this method. Of course, that could also be true with a modern LLVM toolchain that you manage to get working. CentOS 6 is old.

unhelpful links

  • https://crosstool-ng.github.io/ - maybe not as unhelpful as expected! In ct-ng menuconfig enable obsolete features to get a GLIBC 2.12 option, old enough to possibly work. But then you'll need to use this toolchain to build Odin.
  • https://github.com/wheybags/glibc_version_header - compile with a magic header to get portable binaries. Seems promising, but I couldn't get this to work with a C 'hello world'.