Stream: beginners

Topic: ✔ Can't run basic-cli platform on MacOS 13


view this post on Zulip Artur Domurad (Jul 20 2023 at 08:27):

Hi, I'm new here - just getting started with ROC <3

I can't get ROC running on my MacOS 13.4.1 :/
I'm using "roc nightly pre-release, built from commit ecf728a on Tue Jul 18 09:08:46 UTC 2023"
And I'm trying to run examples from https://github.com/roc-lang/basic-cli

basic-cli on  main
❯ roc run examples/form.roc
🔨 Rebuilding platform...
0  0x100154e8a  __assert_rtn + 64
1  0x1000a9922  ___ZN2ld4pass3tlvERKNS_7OptionsERNS_20AtomFileConsolidatorE_block_invoke_2 + 2178
2  0x1000a9bc2  void mapReduce<ld::Atom const*, ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&)::CollectedAtoms>(std::__1::span<ld::Atom const*, 18446744073709551615ul>, unsigned long, void (unsigned long, ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&)::CollectedAtoms&, std::__1::span<ld::Atom const*, 18446744073709551615ul>) block_pointer, void (std::__1::span<ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&)::CollectedAtoms, 18446744073709551615ul>) block_pointer) + 482
3  0x1000a905f  ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&) + 527
4  0x100138664  ld::AtomFileConsolidator::resolve() + 18628
5  0x1000a32ec  main + 12348
ld: Assertion failed: (fixups().size() == 2), function initFixup, file Atom.cpp, line 2005.
thread 'main' panicked at 'not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)', crates/compiler/build/src/program.rs:1048:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Not sure if I'm doing something wrong or if this even supposed to work.
I have rust:

rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.71.0 (8ede3aae2 2023-07-12)`

view this post on Zulip Artur Domurad (Jul 20 2023 at 16:41):

I have an Intel based Mac.
I was able to build the ROC compiler from source - but I'm still getting the same error with it...
I get the same error when trying to run with the pre-built platform:

app "hello"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" }
    imports [pf.Stdout]
    provides [main] to pf

main =
    Stdout.line "I'm a Roc application!"

I was able to run some examples from "platform-switching", like rocLovesRust.roc, rocLovesSwift.roc and rocLovesC.roc .
And I was able to run the "gui" example, and the "webserver" example...
So it seems that I can't run the "basic-cli" platform... (or any cli platform).

view this post on Zulip Notification Bot (Jul 20 2023 at 16:41):

Artur Domurad has marked this topic as resolved.

view this post on Zulip Notification Bot (Jul 20 2023 at 16:42):

Artur Domurad has marked this topic as unresolved.

view this post on Zulip Notification Bot (Jul 20 2023 at 16:42):

Artur Domurad has marked this topic as resolved.

view this post on Zulip Anton (Jul 22 2023 at 11:20):

Hi @Artur Domurad, can you share what fixed your problem?

view this post on Zulip Artur Domurad (Jul 22 2023 at 11:55):

Actually all the examples that use any rust-based "cli" platform still don't work.
For now I'm happy that I can use other platforms (like the webserver) to play with the language :)
I do plan to debug the issue with the "basic-cli" platform after the weekend - maybe I will be able to figure it out.

view this post on Zulip Artur Domurad (Aug 16 2023 at 09:52):

For anyone with the same problem:

This is an issue with the linker - macos 13 + Intel + xcode 15.
If I want to be able to run any roc app using the basic-cli platform (precompiled or not) - I had to add the "-ld64" flag to the "ld" command.

How to fix if you have the same problem:
Go to crates/compiler/build/src/link.rs
And in the function link_macos in the ld_command.args you need to add "-ld", like so:

   ld_command
        // NOTE: order of arguments to `ld` matters here!
        // The `-l` flags should go after the `.o` arguments
        // Don't allow LD_ env vars to affect this
        .env_clear()
        .args(&link_type_args)
        .args([
            "-ld64",  // <------------------ HERE ----------------------------------------------------
            // NOTE: we don't do --gc-sections on macOS because the default
            // macOS linker doesn't support it, but it's a performance
            // optimization, so if we ever switch to a different linker,
            // we'd like to re-enable it on macOS!
            // "--gc-sections",
            "-arch",

view this post on Zulip Anton (Aug 16 2023 at 10:20):

Thanks for reporting this @Artur Domurad!
Can you share the original error message? That way I can write up an issue that is more search friendly.
Github recently added support for CI on macos 13, I'll look into setting that up.

view this post on Zulip Artur Domurad (Aug 16 2023 at 10:24):

Example program:

app "helloWorld"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" }
    imports [pf.Stdout]
    provides [main] to pf

main =
    Stdout.line "Hello, World!"

I run:

roc dev ./helloWorld.roc

Output:

 roc dev ./helloWorld.roc
0  0x10298ae8a  __assert_rtn + 64
1  0x1028dfad2  ___ZN2ld4pass3tlvERKNS_7OptionsERNS_20AtomFileConsolidatorE_block_invoke_2 + 2178
2  0x1028dfd72  void mapReduce<ld::Atom const*, ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&)::CollectedAtoms>(std::__1::span<ld::Atom const*, 18446744073709551615ul>, unsigned long, void (unsigned long, ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&)::CollectedAtoms&, std::__1::span<ld::Atom const*, 18446744073709551615ul>) block_pointer, void (std::__1::span<ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&)::CollectedAtoms, 18446744073709551615ul>) block_pointer) + 482
3  0x1028df20f  ld::pass::tlv(ld::Options const&, ld::AtomFileConsolidator&) + 527
4  0x10296e664  ld::AtomFileConsolidator::resolve() + 18628
5  0x1028d949c  main + 12348
ld: Assertion failed: (fixups().size() == 2), function initFixup, file Atom.cpp, line 2005.
thread 'main' panicked at 'not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)', crates/compiler/build/src/program.rs:1048:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

view this post on Zulip Anton (Aug 16 2023 at 10:27):

Lovely, thanks @Artur Domurad :)

view this post on Zulip Anton (Aug 16 2023 at 11:26):

I've logged this as issue #5765. I'll try to fix it this week.

view this post on Zulip Anton (Aug 18 2023 at 16:25):

I was not able to reproduce this issue on the github ci machine with macos 13, can someone else on macos 13 try the above example?

view this post on Zulip Artur Domurad (Aug 19 2023 at 15:36):

Not sure, but it might be related to the xcode/ld version.
I have the xcode and ld in version 15:

❯ ld -v
@(#)PROGRAM:ld-classic  PROJECT:ld64-906.2
BUILD 20:09:28 Jul  7 2023
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.0.12.2)

When I was looking for a solution to my problem, I have found couple of threads on sites like "stackoverflow" that suggest that there is an issue with the new linker which is used by default when you migrate xcode from 14 to 15. (atleast it is how I understood it)

In the link below people have the same error while linking a GO program, and there is suggestion that golang did add the "-ld64" flag as the default option:
https://github.com/golang/go/issues/61229#issuecomment-1669673723

I will try to find someone with xcode/clang in version 14.x and will test ROC, and then upgrade and test again.
And I will try to upgrade macos and xcode to the newest version - it seems that there was a fix to address this issue.

view this post on Zulip Anton (Aug 19 2023 at 16:28):

Thanks for looking into this @Artur Domurad.
I've checked the github CI macos 13 image and it is on xcode 14.3.1

view this post on Zulip Artur Domurad (Aug 19 2023 at 16:30):

UPDATE:
after upgrading macos to 13.5.1 and the newest xcode/ld (BUILD 17:43:49 Jul 30 2023)
when running roc compiler with the -ld64 flag I get a warning:

❯ roc dev ./main.roc
ld: warning: -ld64 is deprecated, use -ld_classic instead
I'm a Roc application!

And now I am able to run the previous basic-cli example without the "-ld64" flag :)
It seems that this was just a bug in "ld" 15 and now it is fixed.
So there is no real need to add the "-ld64" flag to roc.

view this post on Zulip Anton (Aug 19 2023 at 16:31):

Awesome :tada:
I'll update the issue

view this post on Zulip Brendan Hansknecht (Jul 13 2024 at 01:25):

A note, on my list refcounting branch, I hit this a lot more, no idea why. Maybe the more complex generation creates more cases where the new macos ld fails. So it requires -ld_classic for me. That said, -ld_classic breaks ci (I assume it is on an older version?).

view this post on Zulip Anton (Jul 13 2024 at 09:18):

I'll check it out


Last updated: Jul 06 2025 at 12:14 UTC