A new experimental package for Odin

Hello,

I started to build a Guix definition package for ODIN programming language. You can find it here.

This package provides two executables:

  • odin: the compiler
  • demo-odin: the demo from the examples directory

Odin relies on clang for the linker, you´ll need to add the clang-toolchain to build an executable.

It’s really a first draft but for me, it’s already enough to start learning and exploring the language.

Third party libraries are available as pre-compiled static libraries for different architectures. For linux platform, most of them need to be compiled. For safety reasons and overall size, those libraries have been removed. If dynamic libraries are available, they will be used by the linker (glfw, sdl2, opengl).
Execution of compiled application can lead to failure due to a library missing at runtime. Some work around based on the usage of patchelf or prepend the execution by using an environment variable like LD_LIBRARY_PATH or LD_PRELOAD can fix the issue.

Current limitations:

  • x86_64 only
  • some third party vendor libraries are not available (Raylib, box2d, …)
    • Raylib was working but I removed the provided libraries since …
    • Find a way to provide extra packages for ODIN and bind them to an immutable folder called vendor.
    • or if feasible use the additional -collection:shared=path/to/shared/libs to the compiler.
  • some tests leads to segmentation fault (tests/core and tests/benchmark),
    whereas other works: odin test tests/internal

To experiment with this package, one can use this basic manifest.scm:

(specifications->manifest
 (list "odin"
       "clang-toolchain@18"
       ;; "raylib"
       "glfw@3.4"
       "sdl2"
       "coreutils"
       ;; "patchelf"
       ;; "libtree"
       ;; "strace"
       ))

There are more examples to play with available here.

Examples based on glfw, opengl or sdl2 should run out of the box.

guix shell -m manifest.scm -- odin run more-examples/glfw/window
guix shell -m manifest.scm -- odin run more-examples/sdl2/chase_in_space

I’m currently building and running this package on this laptop:

~/projects/odin/src [env]$ odin report
Where to find more information and get into contact when you encounter a bug:

Website: https://odin-lang.org
GitHub:  https://github.com/odin-lang/Odin/issues


Useful information to add to a bug report:

Odin:    dev-2025-02
OS:      Guix System, Linux 5.15.167.4-microsoft-standard-WSL2
CPU:     11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
RAM:     3826 MiB
Backend: LLVM 18.1.8

Feel free to give me feedback or advices of some sort.
To be continued and Happy coding, Arnaud.

3 Likes

I dug a little deeper into the raylib vendor part. Odin seems to have a preference for static libraries:

~/projects/odin/src [env]$ odin build more-examples/raylib/game_of_life
ld: cannot find -l:/gnu/store/hkjs78119h6kzxyjry2jfrkrhvqwdxch-odin-0.0-dev-2025-01.2aae4cf/vendor/raylib//linux/libraylib.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When you look at the code, it clearly says.
RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)

But you can easily force dynamic libraries to compile with:
odin build more-examples/raylib/game_of_life -define:RAYLIB_SHARED=true

From a guix shell, assuming you have defined a manifest.scm with the expected libraries, you need to prepend the execution with the path of the required library:
LD_LIBRARY_PATH=$LIBRARY_PATH ./game_of_life

Finally it also works for Raylib.

Hey Arnaud, this is cool! Do you think you’ll try to submit the package to Guix at some point?

Good morning @daviwil,

This is a good question and a long answer to disgress.
Firstly, but you already know this, it’s a long process to commit patches.
It takes times to prepare them and depending on the reviewer, it can be processed quickly for a small fix or sunk into the depth of the existing list of patches. My previous official patch to add guile-raylib is one of them.
Secondly, I’m missing some enthousiasm at the moment.
Currently, it’s quite experimental. I need to provide a replacement for the existing static libraries from the odin’s vendor path. I passed the previous week to create static library packages for raylib, box2d and glfw.
I added this morning a dedicated phase to compile the stb libraries.
When I’ve finished to build all the samples from there , maybe I’ll reconsider and formalize this work.

Eventually, it has been a great challenge to grasp all of the potential of Guix to provide functional and reproducible packages and I learnt a lot.