roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.14k stars 291 forks source link

support running roc nightly on android termux #6050

Open Anton-4 opened 10 months ago

Anton-4 commented 10 months ago

No details but a lobsters user failed to make this work.

xigoi commented 10 months ago

That's me. When I tried to compile it now, I got this error:

error: failed to run custom build command for `llvm-sys v160.1.3`
                                                           Caused by:
  process didn't exit successfully: `/data/data/com.termux/files/home/downloads/roc/target/debug/build/llvm-sys-2c0e60e4119ecf9b/build-script-build` (exit status: 101)            --- stdout
  cargo:rerun-if-env-changed=LLVM_SYS_160_PREFIX             cargo:rerun-if-env-changed=LLVM_SYS_160_IGNORE_BLOCKLIST
  cargo:rerun-if-env-changed=LLVM_SYS_160_STRICT_VERSIONING  cargo:rerun-if-env-changed=LLVM_SYS_160_NO_CLEAN_CFLAGS
  cargo:rerun-if-env-changed=LLVM_SYS_160_USE_DEBUG_MSVCRT   cargo:rerun-if-env-changed=LLVM_SYS_160_FFI_WORKAROUND
  TARGET = Some("aarch64-linux-android")                     OPT_LEVEL = Some("0")
  HOST = Some("aarch64-linux-android")                       cargo:rerun-if-env-changed=CC_aarch64-linux-android
  CC_aarch64-linux-android = None                            cargo:rerun-if-env-changed=CC_aarch64_linux_android
  CC_aarch64_linux_android = None                            cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None                                             cargo:rerun-if-env-changed=CC
  CC = None                                                  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None                                DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("neon")                    cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android
  CFLAGS_aarch64-linux-android = None                        cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android
  CFLAGS_aarch64_linux_android = None                        cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None                                         cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some("-I/data/data/com.termux/files/usr/include  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS ")                                               running: "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I/data/data/com.termux/files/usr/include" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/data/data/com.termux/files/home/downloads/roc/target/debug/build/llvm-sys-61afdc7c7178229e/out/wrappers/target.o" "-c" "wrappers/target.c"                   exit status: 0
  cargo:rerun-if-env-changed=AR_aarch64-linux-android        AR_aarch64-linux-android = None                            cargo:rerun-if-env-changed=AR_aarch64_linux_android        AR_aarch64_linux_android = None                            cargo:rerun-if-env-changed=HOST_AR                         HOST_AR = None                                             cargo:rerun-if-env-changed=AR                              AR = None
  cargo:rerun-if-env-changed=ARFLAGS_aarch64-linux-android   ARFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=ARFLAGS_aarch64_linux_android   ARFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=HOST_ARFLAGS                    HOST_ARFLAGS = None                                        cargo:rerun-if-env-changed=ARFLAGS                         ARFLAGS = None                                             running: ZERO_AR_DATE="1" "aarch64-linux-android-ar" "cq" "/data/data/com.termux/files/home/downloads/roc/target/debug/build/llvm-sys-61afdc7c7178229e/out/libtargetwrappers.a" "/data/data/com.termux/files/home/downloads/roc/target/debug/build/llvm-sys-61afdc7c7178229e/out/wrappers/target.o"    exit status: 0                                             running: "aarch64-linux-android-ar" "s" "/data/data/com.termux/files/home/downloads/roc/target/debug/build/llvm-sys-61afdc7c7178229e/out/libtargetwrappers.a"                    exit status: 0                                             cargo:rustc-link-lib=static=targetwrappers                 cargo:rustc-link-search=native=/data/data/com.termux/files/home/downloads/roc/target/debug/build/llvm-sys-61afdc7c7178229e/out                                                   cargo:config_path=llvm-config                              cargo:libdir=/data/data/com.termux/files/usr/lib
                                                             cargo:rustc-link-search=native=/data/data/com.termux/files/usr/lib                                                  
                                                             --- stderr
  thread 'main' panicked at /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llvm-sys-160.1.3/build.rs:473:5:                                 failed to get linking libraries from llvm-config.
  linking static library error: llvm-config failed with error code Some(1)                                              note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Also, Termux doesn't have the X window system so it's not possible to install libxkb-common.

Anton-4 commented 10 months ago

Hi @xigoi, thanks for providing the details!

Where you experiencing issues with the roc_nightly-linux_arm64-latest.tar.gz release as well?

libxkb-common is only necessary if you want to run the roc gui examples, I've put up a PR that removes this install suggestion.

I'm not sure what's causing the problem with llvm-sys, Can you try the following workaround:

# install nix from https://nixos.org/download.html
# cd to the roc repo
cargo clean
nix-build
./result/bin/roc examples/helloWorld.roc
xigoi commented 10 months ago

Where you experiencing issues with the roc_nightly-linux_arm64-latest.tar.gz release as well?

~/downloads/roc_nightly-linux_arm64-2023-11-22-31b62e9
❯ ./roc
bash: ./roc: cannot execute: required file not found

install nix from https://nixos.org/download.html

How much storage space is that going to take up, including the installation of all necessary packages? I'm cautious about installing an entire operating system just to try out a language.

Anton-4 commented 10 months ago

For the nightly I think a dynamic dependency is missing. Can you post the output of ldd ./roc?

How much storage space is that going to take up

Pessimistically I'd say the whole procedure will take up 10GB.

[...] installing an entire operating system

From that download page you would be downloading the nix package manager, not nixOS, although I can definitely understand the confusion.

You don't have to go through the building from source procedure if you don't like, I think we'll be able to solve the issues with the nightly.

xigoi commented 10 months ago

Can you post the output of ldd ./roc?

  librt.so.1 => not found
  libdl.so.2 => not found                                    libpthread.so.0 => not found
  libm.so.6 => not found                                     libz.so.1 => not found                                     libzstd.so.1 => not found                                  libtinfo.so.6 => not found                                 libstdc++.so.6 => not found                                libgcc_s.so.1 => not found
  libc.so.6 => not found                                     ld-linux-aarch64.so.1 => not found

Not found on everything. Are the dependencies supposed to be bundled in the archive?

Pessimistically I'd say the whole procedure will take up 10GB.

In that case, I'm not going to try that. Hopefully we can get the nightly working.

Anton-4 commented 10 months ago

Are the dependencies supposed to be bundled in the archive?

No, these are dynamic dependencies typically present by default on linux operating systems.

I've installed termux myself and will try some stuff and report back.

Anton-4 commented 10 months ago

Given how much termux differs from a typical linux OS, I expect getting roc to work now will be very difficult and time consuming. Unless you are actually willing to install an operating system, going with Ubuntu (22.04) as described here.

[...] very difficult and time consuming.

This should however be easier once https://github.com/roc-lang/roc/issues/6083 is done. But that is a time consuming project in itself.