# Install utop on mac m1 failed with assembly compilation error

**URL:** <https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484>\
**Category:** Learning\
**Tags:** utop\
**Created:** [November 23, 2023, 1:27am UTC](https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484 "2023-11-23T01:27:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoobean1996](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hoobean1996/32/4878_2.png) [@hoobean1996](https://discuss.ocaml.org/u/hoobean1996)\
**Post date:** [November 23, 2023, 1:27am UTC](https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484/1 "2023-11-23T01:27:41Z")

</div>

hi masters, previously on my mac with m1 chip, I installed utop successfully, and I tried many times.  
for some reasons, I maybe done brew update & upgrade, then utop can’t work any more.  
When I type “utop”, it will be stuck with a “utop orgrange header”, can’t input any expressions.  
So I tried to re-install utop again, but I can’t install it for below error, do you have any ideas? thank you so much

```auto
Constructing initial basis...
Number of 0-1 knapsack inequalities = 14977
Constructing conflict graph...
Conflict graph has 2534 + 605 = 3139 vertices
The following actions will be performed:
  - install utop 2.13.1
  - install lwt_log 1.1.2
===== 2 to install =====
Do you want to continue? [Y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/6: [lwt_log.1.1.2: dl]
-> retrieved utop.2.13.1 (cached)
-> retrieved lwt_log.1.1.2 (https://opam.ocaml.org/cache)
[ERROR] The compilation of lwt_log.1.1.2 failed at "dune build -p lwt_log -j 7".
[ERROR] The compilation of utop.2.13.1 failed at "dune build -p utop -j 7 @install".

#=== ERROR while compiling utop.2.13.1 ========================================#
# context 2.1.5 | macos/x86_64 | ocaml.5.1.0 | https://opam.ocaml.org#2dcd8684
# path ~/.opam/default/.opam-switch/build/utop.2.13.1
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p utop -j 7 @install
# exit-code 1
# env-file ~/.opam/log/utop-80315-144998.env
# output-file ~/.opam/log/utop-80315-144998.out
### output ###
# /tmp/build_16c292_dune/camlasm438898.s:913:2: error: invalid instruction mnemonic 'bl'
# [...]
# /tmp/build_16c292_dune/camlasm438898.s:916:15: error: unknown token in expression
# orr x0, xzr, #1
# ^
# /tmp/build_16c292_dune/camlasm438898.s:917:11: error: brackets expression not supported on this target
# ldr x30, [sp, #8]
# ^
# /tmp/build_16c292_dune/camlasm438898.s:918:14: error: unknown token in expression
# add sp, sp, #16
# ^
# File "src/top/expunge/modules.ml", line 1:
# Error: Assembler error, input left in file /tmp/build_16c292_dune/camlasm438898.s

#=== ERROR while compiling lwt_log.1.1.2 ======================================#
# context 2.1.5 | macos/x86_64 | ocaml.5.1.0 | https://opam.ocaml.org#2dcd8684
# path ~/.opam/default/.opam-switch/build/lwt_log.1.1.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p lwt_log -j 7
# exit-code 1
# env-file ~/.opam/log/lwt_log-80315-4377b1.env
# output-file ~/.opam/log/lwt_log-80315-4377b1.out
### output ###
# /tmp/build_735af4_dune/camlasm81f813.s:849:2: error: unknown use of instruction mnemonic without a size suffix
# [...]
# /tmp/build_735af4_dune/camlasm81f813.s:851:15: error: unknown token in expression
# orr x0, xzr, #1
# ^
# /tmp/build_735af4_dune/camlasm81f813.s:852:11: error: brackets expression not supported on this target
# ldr x30, [sp, #8]
# ^
# /tmp/build_735af4_dune/camlasm81f813.s:853:14: error: unknown token in expression
# add sp, sp, #16
# ^
# File "src/core/lwt_log_rules.ml", line 1:
# Error: Assembler error, input left in file /tmp/build_735af4_dune/camlasm81f813.s

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build lwt_log 1.1.2
| - build utop 2.13.1
+-
- No changes have been performed
# Run eval $(opam env) to update the current shell environment

```

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [November 23, 2023, 11:02am UTC](https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484/2 "2023-11-23T11:02:23Z")

</div>

> [@hoobean1996](#):
>
> `context 2.1.5 | macos/x86_64 | ocaml.5.1.0 `

If you are on an `m1` you have a problem here, this should be macos/arm64.

I don’t exactly remember what you should do but try [this discussion](https://github.com/ocaml/opam/issues/4798).

---

<div class="post-metadata">

**Author:** ![emillon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emillon/32/1206_2.png) [@emillon](https://discuss.ocaml.org/u/emillon)\
**Post date:** [November 23, 2023, 11:07am UTC](https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484/3 "2023-11-23T11:07:59Z")

</div>

I agree with @dbuenzli, it looks like this is executing the wrong toolchain under the hood (possibly through rosetta).

---

<div class="post-metadata">

**Author:** ![hoobean1996](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hoobean1996/32/4878_2.png) [@hoobean1996](https://discuss.ocaml.org/u/hoobean1996)\
**Post date:** [November 23, 2023, 11:36am UTC](https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484/4 "2023-11-23T11:36:52Z")

</div>

thanks for your reply.

```auto
➜ ~ arch
arm64
➜ ~ opam config report
# opam config report
# opam-version 2.1.5
# self-upgrade no
# system arch=arm64 os=macos os-distribution=homebrew os-version=14.1
# solver builtin-mccs+glpk
# install-criteria -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs 7
# repositories 1 (http) (default repo at 2dcd8684)
# pinned 0
# current-switch default
# ocaml:native true
# ocaml:native-tools true
# ocaml:native-dynlink true
# ocaml:stubsdir /Users/binhe/.opam/default/lib/ocaml/stublibs:/Users/binhe/.opam/default/lib/ocaml
# ocaml:preinstalled false
# ocaml:compiler 5.0.0

seems I installed utop successfully. 
But when I use `utop`, it looks like this

➜ ~ utop
────────────────────────────────┬─────────────────────────────────────────────────────────────┬─────────────────────────────────
                                │ Welcome to utop version 2.10.0 (using OCaml version 5.0.0)! │
                                └─────────────────────────────────────────────────────────────┘
^CFatal error: exception Stdlib.Sys.Break

If I don't use ctrl+c to stop it, it will stay here forever, by right it should have a > ____ for me to type ocaml expressions.

```

---

<div class="post-metadata">

**Author:** ![xavierleroy](https://avatars.discourse-cdn.com/v4/letter/x/a9adbd/32.png) [@xavierleroy](https://discuss.ocaml.org/u/xavierleroy)\
**Post date:** [November 25, 2023, 11:17am UTC](https://discuss.ocaml.org/t/install-utop-on-mac-m1-failed-with-assembly-compilation-error/13484/5 "2023-11-25T11:17:03Z")

</div>

Possibly related to [macOS: ocamlopt compiled for arm64 causes asm errors when running in a x86\_64 environment · Issue #10374 · ocaml/ocaml · GitHub](https://github.com/ocaml/ocaml/issues/10374) as well.
