Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for building standalone executable with warp #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

seanhinde
Copy link

This PR was sponsored by the ACF

@hanssv
Copy link
Member

hanssv commented Mar 23, 2023

Looks good! It needs to be rebased (and the version in the relx configy should be 7.1.0)


Warp also supports windows x86, but this is not tested.

Warp currently does not support arm64.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sad

Copy link
Member

@davidyuk davidyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[sasl, aesophia_cli, aesophia, aeserialization, eblake2]},

{dev_mode, false},
{include_erts, true}, % To include Erlang runtime system
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is possible to include Erlang runtime into executable, why do we need warp in macOS and Linux?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a single executable like a C program. It creates a self extracting tar file with the command


{dev_mode, false},
{include_erts, true}, % To include Erlang runtime system
{extended_start_script, true}, % Should be true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why it should be true

hanssv
hanssv previously approved these changes Sep 7, 2023
Copy link
Member

@davidyuk davidyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is warp-packer maintained? I see the last release was in 2018, and the last commit was in 2019.

I've built it for different platforms according to the readme, but it is not working well for me.

The packed size for all architectures is 37M, aesophia_cli by itself is only 1.4M.

Ubuntu

$ ./aesophia_cli-linux 
/root/.local/share/warp/packages/aesophia_cli-linux/erts-13.2.2.1/bin/erl: 1: /root/.local/share/warp/packages/aesophia_cli-linux/erts-13.2.2.1/bin/dyn_erl: Exec format error
/root/.local/share/warp/packages/aesophia_cli-linux/erts-13.2.2.1/bin/erl: 57: exec: ./erts-13.2.2.1/bin/erlexec: not found
$ uname -a
Linux denis-VirtualBox 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

macOS

$ ./aesophia_cli-macos
/Users/denis/Library/Application Support/warp/packages/aesophia_cli-macos/launch: line 6: /Users/denis/Library/Application: No such file or directory
/Users/denis/Library/Application Support/warp/packages/aesophia_cli-macos/launch: line 6: exec: /Users/denis/Library/Application: cannot execute: No such file or directory
$ uname -a
Darwin adsl-172-10-0-56.dsl.sndg02.sbcglobal.net 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64

It looks like the path needs to be escaped or quoted, it fails because of space in "Application Support".

Windows

.\aesophia_cli-windows.exe
Error: Os { code: 193, kind: Other, message: "%1 is not a valid Win32 application." }

OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19044 N/A Build 19044
System Type: x64-based PC

@seanhinde
Copy link
Author

warp-packer seems to work, although I agree not much activity for a few years. Worst case if it stops working eventually we find something else, or this all ends up re-written in Rust.

linux works fine for me.

macOS indeed needs some quotes in the script. I have a fix. It works but still creates a warning on each run.

windows I don't plan to support at all in this PR

Regarding the size, 37M is larger than the simple escript, but it does include all the parts of the erlang system including the beam runtime and libraries.

@davidyuk
Copy link
Member

davidyuk commented Nov 3, 2023

Reproduction of error on Ubuntu

#!/bin/bash
set -e

./rebar3 escriptize
./rebar3 release

wget -O warp-packer https://github.com/dgiagio/warp/releases/download/v0.3.0/macos-x64.warp-packer
chmod +x ./warp-packer
./warp-packer -a linux-x64 -i _build/default/rel/aesophia_cli -e launch -o warp/aesophia_cli

echo "
FROM ubuntu:22.04

ADD ./warp/aesophia_cli ./

RUN ./aesophia_cli --help
" > Dockerfile

docker build -t compiler-ubuntu-test .
Its output
$ ./reproduction.sh
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling aesophia_cli
===> Building escript for aesophia_cli...
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling aesophia_cli
===> Assembling release aesophia_cli-7.4.0...
===> Warnings generating release:
*WARNING* stdlib: Object code (filename) out of date
===> Release successfully assembled: _build/default/rel/aesophia_cli
--2023-11-03 09:54:53--  https://github.com/dgiagio/warp/releases/download/v0.3.0/macos-x64.warp-packer
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/152104196/7c984c80-dbcb-11e8-9923-02332894c0e7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231103T042453Z&X-Amz-Expires=300&X-Amz-Signature=b1be508a040c7ec9766c97f7d8e18e2842fd20748ad3210e7cb87894acdd557f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=152104196&response-content-disposition=attachment%3B%20filename%3Dmacos-x64.warp-packer&response-content-type=application%2Foctet-stream [following]
--2023-11-03 09:54:53--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/152104196/7c984c80-dbcb-11e8-9923-02332894c0e7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231103T042453Z&X-Amz-Expires=300&X-Amz-Signature=b1be508a040c7ec9766c97f7d8e18e2842fd20748ad3210e7cb87894acdd557f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=152104196&response-content-disposition=attachment%3B%20filename%3Dmacos-x64.warp-packer&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3493504 (3.3M) [application/octet-stream]
Saving to: ‘warp-packer’

warp-packer                              100%[================================================================================>]   3.33M  --.-KB/s    in 0.1s    

2023-11-03 09:54:54 (24.5 MB/s) - ‘warp-packer’ saved [3493504/3493504]

Compressing input directory "_build/default/rel/aesophia_cli"...
Creating self-contained application binary "warp/aesophia_cli"...
All done
[+] Building 3.1s (7/7) FINISHED                                                                                                             docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                         0.0s
 => => transferring dockerfile: 149B                                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/ubuntu:22.04                                                                                              1.3s
 => [internal] load build context                                                                                                                            0.8s
 => => transferring context: 38.59MB                                                                                                                         0.8s
 => CACHED [1/3] FROM docker.io/library/ubuntu:22.04@sha256:2b7412e6465c3c7fc5bb21d3e6f1917c167358449fecac8176c6e496e5c1f05f                                 0.0s
 => [2/3] ADD ./warp/aesophia_cli ./                                                                                                                         0.1s
 => ERROR [3/3] RUN ./aesophia_cli --help                                                                                                                    0.7s
------
 > [3/3] RUN ./aesophia_cli --help:
0.644 /root/.local/share/warp/packages/aesophia_cli/erts-13.2.2.1/bin/erl: 1: /root/.local/share/warp/packages/aesophia_cli/erts-13.2.2.1/bin/dyn_erl: Exec format error
0.646 /root/.local/share/warp/packages/aesophia_cli/erts-13.2.2.1/bin/erl: 57: exec: ./erts-13.2.2.1/bin/erlexec: not found
------
Dockerfile:6
--------------------
   4 |     ADD ./warp/aesophia_cli ./
   5 |     
   6 | >>> RUN ./aesophia_cli --help
   7 |     
   8 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c ./aesophia_cli --help" did not complete successfully: exit code: 127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants