You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
After looking at Burrito for a bit, I can confirm it is taking the same approach, plus using zig instead of C, which allows it to have an easier time at cross-compiling.
Just sharing my workaround for getting a bakeware executable that's compiled on Linux to run on Windows (for me it has CI benefits, doing it this way). I've also cached the otp_win64_24.3.4.5.exe binary (added to my git repo via LFS). Basically it just replaces the ERTS and other erlang libraries to the Windows one in the release.
Also of course, I have CC ="/path/to/x86_64-w64-mingw32-gcc" to compile the bakeware executable to .exe
I didn't know where best to put it, this is a workaround rather than a full solution, but I think it is a good enough workaround that it's worth sharing.
defpotp_full_version()dootp_major=:erlang.system_info(:otp_release)File.read!(Path.join([:code.root_dir(),"releases",otp_major,"OTP_VERSION"]))|>String.trim()enddefpextract_cross_erlang()docached_version="24.3.4.5"erts_version=:erlang.system_info(:version)otp_version=otp_full_version()ifotp_version!=cached_versiondoraise""" Wrong erlang version, download the one matching your version: OTP: #{otp_version}, ERTS: #{erts_version} from e.g. this was from https://www.erlang.org/patches/otp-#{cached_version}, so for you it's probably https://www.erlang.org/patches/otp-#{otp_version} """endifnotFile.exists?("cross-erlang")docaseSystem.get_env("MIX_TARGET")do"win64"->System.cmd("7z",["x","otp_win64_#{cached_version}.exe","-ocross-erlang"])endendenddefppatch_for_cross_compile(release)doifSystem.get_env("MIX_TARGET")doextract_cross_erlang()cross_release=%{release|erts_source: './cross-erlang/erts-12.3.2.5',applications:for{app,cfg}<-release.applications,into: %{}dopath=cfg[:path]|>to_stringroot_dir=:code.root_dir()|>to_string()ifString.starts_with?(path,root_dir)do{app,put_in(cfg[:path],String.replace(path,root_dir,"./cross-erlang")|>to_charlist)}else{app,cfg}endend}ifSystem.get_env("MIX_RELEASE_DEBUG")doFile.write!("release",inspect(release,pretty: true,limit: :infinity))File.write!("cross_release",inspect(cross_release,pretty: true,limit: :infinity))endcross_releaseelsereleaseendenddefpreleasedo[overwrite: true,cookie: "#{@app}_cookie",quiet: true,steps: [&patch_for_cross_compile/1,:assemble,&Bakeware.assemble/1],strip_beams: Mix.env()==:prod]end
And a small patch on top of Elixir I use as a workaround to not having got a matching Elixir 1.12.3 that works with OTP 24 (Elixir doesn't have any DLLs anyway, just BEAM files, it was just missing the Windows .bat files)
Hi,
EDIT:
Just sharing my workaround for getting a bakeware executable that's compiled on Linux to run on Windows (for me it has CI benefits, doing it this way). I've also cached the
otp_win64_24.3.4.5.exe
binary (added to my git repo via LFS). Basically it just replaces the ERTS and other erlang libraries to the Windows one in the release.Also of course, I have
CC ="/path/to/x86_64-w64-mingw32-gcc"
to compile the bakeware executable to .exeI didn't know where best to put it, this is a workaround rather than a full solution, but I think it is a good enough workaround that it's worth sharing.
And a small patch on top of Elixir I use as a workaround to not having got a matching Elixir 1.12.3 that works with OTP 24 (Elixir doesn't have any DLLs anyway, just BEAM files, it was just missing the Windows
.bat
files)The text was updated successfully, but these errors were encountered: