Stream: beginners

Topic: Statically linked roc?


view this post on Zulip Johannes Hoff (Nov 09 2024 at 14:12):

Hi! Are there any statically linked builds of roc, or plans to make that? I'm in the rare position of not wanting to install homebrew on my mac. This makes the installation step brew install llvm@16 more challenging (this step is curiously missing from the x86_64 build for macos).

Of course, I have myself to thank for being unusual in this regard, but wouldn't it be helpful everyone with one less step?

Side note, I don't see a dynamic library reference to llvm, but I do see one to libzstd.

$ otool -L roc
roc:
    /usr/lib/libffi.dylib (compatibility version 1.0.0, current version 30.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    /opt/homebrew/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.6)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.23.0)
    /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 1163.100.19)
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60158.100.133)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

view this post on Zulip Anton (Nov 09 2024 at 14:19):

Hi @Johannes Hoff,

Are there any statically linked builds of roc, or plans to make that

yes, there are plans, see https://github.com/roc-lang/roc/pull/6921 and https://github.com/roc-lang/roc/issues/6083

view this post on Zulip Anton (Nov 09 2024 at 14:20):

Side note, I don't see a dynamic library reference to llvm, but I do see one to libzstd.

I think brew install llvm@16 installs several dependencies but you don't actually need most of them.

view this post on Zulip Anton (Nov 09 2024 at 14:21):

You can install libzstd through whatever means possible and move it to /opt/homebrew/opt/zstd/lib/

view this post on Zulip Anton (Nov 09 2024 at 14:22):

If you try to run roc (like roc helloWorld.roc) it'll tell you which specific dependencies you miss and you can install those one by one so you don't need to install llvm

view this post on Zulip Johannes Hoff (Nov 09 2024 at 14:31):

Oh, great that you're working on it! I'll follow that issue.

view this post on Zulip Johannes Hoff (Nov 09 2024 at 14:31):

I'll see how far I get with manual installation.

view this post on Zulip Johannes Hoff (Nov 09 2024 at 15:25):

The only dynamic library needed was zstd, so that was pretty easy. But I seems I really should have llvm, since ld is failing (in surprising ways, at least to me). Other fun things is that the repl runs, but crashes on any command. So, I'm guessing even a static build will have problems for me, unless it bundles ld and doesn't invoke it as an external command.

Anyway, I don't expect any help or sympathy here, and fully realize that there's a simpler way.

For the curious, here's the output from building:

% DYLD_LIBRARY_PATH=/Users/j/zstd/lib ./roc examples/helloWorld.roc
ld: library not found for -lSystem
examples/helloWorld: No such file or directory
thread 'main' panicked at crates/compiler/build/src/program.rs:1037:17:
not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

view this post on Zulip Brendan Hansknecht (Nov 09 2024 at 15:55):

Your Mac can't find the system library?

view this post on Zulip Johannes Hoff (Nov 09 2024 at 16:17):

Looks like it :man_shrugging: I have the latest xcode installed, which I assumed should be enough, so I blamed my llvm-version. Perhaps wrongly. I also have the latest macos version (15.0.1), but that might be a reason for it to fail, rather than work.

view this post on Zulip Anton (Nov 09 2024 at 16:33):

Building from source will probably work (if you want to install nix). Then you can do:

$ cd roc
$ nix develop
$ cargo build --release --bin roc
$ ./target/release/roc ./examples/helloWorld.roc

Last updated: Jul 06 2025 at 12:14 UTC