jeffmvr

jeffmvr

Cross compiling a release with Apple M1 and Docker

I am trying to cross-compile an Elixir release within a Docker container for amd64 on a M1 Macbook and I receive the following error when calling mix deps.compile:

The Docker image I am building from is elixir:latest with the --platform=amd64 flag set.

#0 3.446 Error while loading project :decimal at /app/deps/decimal                                                      
#0 3.480 ** (FunctionClauseError) no function clause matching in Keyword.merge/2                                        
#0 3.480                                                                                                                
#0 3.480     The following arguments were given to Keyword.merge/2:
#0 3.480     
#0 3.480         # 1
#0 3.480         [app: nil, aliases: [], build_embedded: false, build_per_environment: true, build_scm: Mix.SCM.Path, config_path: "config/config.exs", consolidate_protocols: true, default_task: "run", deps: [], deps_path: "deps", elixirc_paths: ["lib"], erlc_paths: ["src"], erlc_include_path: "include", erlc_options: [], lockfile: "mix.lock", preferred_cli_env: [], start_permanent: false]
#0 3.480     
#0 3.480         # 2
#0 3.480         Decimal.Mixfile
#0 3.480     
#0 3.480     Attempted function clauses (showing 3 out of 3):
#0 3.480     
#0 3.480         def merge(+keywords1+, -[]-) when +is_list(keywords1)+
#0 3.480         def merge(-[]-, +keywords2+) when -is_list(keywords2)-
#0 3.480         def merge(+keywords1+, +keywords2+) when +is_list(keywords1)+ and -is_list(keywords2)-
#0 3.480     
#0 3.480     (elixir 1.14.4) lib/keyword.ex:979: Keyword.merge/2
#0 3.480     (mix 1.14.4) lib/mix/project.ex:141: Mix.Project.push/3
#0 3.480     (stdlib 4.3.1) lists.erl:1350: :lists.foldl/3

Any suggestions on how to solve this? It builds fine when trying on the same arm64 Docker image so I assume I am missing something.

Most Liked

cschmatzler

cschmatzler

Cross-/multiplatform images of OTP languages is unsupported since the introduction of the JIT compiler in OTP24.
Docker uses QEMU for that under the hood, which doesn’t support some of the memory magic that happens for JIT, see: Erlang/OTP 25 JIT on AArch64 fails in user mode emulation (#1034) · Issues · QEMU / QEMU · GitLab

josevalim

josevalim

Creator of Elixir

For posterity: you can set ERL_AFLAGS=“+JMsingle true” and make the JIT more amenable to emulation. Or compile it on a matching machine.

As a last resort, you can try compiling the Erlang VM without JIT and using the emulator, but that’s not recommend (it is slower too).

Where Next?

Popular in Questions Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement