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

I build prisma-engines for armv7 but failed #3881

Open
ImBIOS opened this issue Apr 16, 2023 · 11 comments
Open

I build prisma-engines for armv7 but failed #3881

ImBIOS opened this issue Apr 16, 2023 · 11 comments

Comments

@ImBIOS
Copy link

ImBIOS commented Apr 16, 2023

https://github.com/ImBIOS/prisma-armv7-builds
I made the build here but failed with no clue. Can anyone help me?

@janpio
Copy link
Member

janpio commented Apr 20, 2023

Error: failed to run custom build command for `openssl-sys v0.9.83`
Caused by:
  process didn't exit successfully: `/target/release/build/openssl-sys-a6b5060a7eab6043/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR
  ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR
  ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_DIR
  ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/:" "pkg-config" "--libs" "--cflags" "openssl"` did not exit successfully: exit status: 1
  error: could not find system library 'openssl' required by the 'openssl-sys' crate

  --- stderr
  Package openssl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `openssl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'openssl' found


  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = armv7-unknown-linux-gnueabihf
  openssl-sys = 0.9.83

  ', /cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.83/build/find_normal.rs:190:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Error: The process 'cross' failed with exit code 101

This is not a problem with Prisma itself, but one of the dependencies can not be built during this step:

      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --target armv7-unknown-linux-gnueabihf --release

Seems to me this is more a case for https://github.com/actions-rs/cargo/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc

@janpio
Copy link
Member

janpio commented Apr 20, 2023

@ImBIOS
Copy link
Author

ImBIOS commented Apr 21, 2023

Thanks @janpio
I'm currently trying to implement your finding.

@janpio
Copy link
Member

janpio commented May 31, 2023

Did you have success @ImBIOS?

@musantro
Copy link

musantro commented May 31, 2023

Hi,

I am trying to get a build too for armv7. I saw that @ImBIOS try in github actions failed (see more)

I tried by hardcoding $CROSS_DEB_ARCH: musantro/prisma-armv7-builds@b9fe54c

So that I managed to continue (see build), but it fails at compilation of schema-engine-cli with an error:

Compiling query-engine-tests v0.1.0 (/home/runner/work/prisma-armv7-builds/prisma-armv7-builds/query-engine/connector-test-kit-rs/query-engine-tests)
error: Undefined temporary symbol .LBB16_2
Error: Undefined temporary symbol .LBB16_2
error: could not compile `schema-engine-cli` due to previous error

maybe @janpio you could throw some light on what could be the issue? Right now I am out of ideas as the error is not so much descriptive to me.

@janpio
Copy link
Member

janpio commented Jun 1, 2023

As a product manager I am probably the wrong person for that question.
Quick google for LBB16_2 gave me this: https://bitshifter.github.io/2017/12/04/rust-bench-simd/ So some low level instruction?

@musantro
Copy link

musantro commented Jun 1, 2023

It's okay, I will try to cross build with more --verbose and i will let you know if I find something.

@ImBIOS
Copy link
Author

ImBIOS commented Jun 6, 2023

@janpio still failing, using a workaround rn. I'm using vanilla code and writing only ORM that I'll need in my project. Basically, I'm writing my own ORM rn, it's painful but worth the time, because eI need it fast.

@musantro
Copy link

musantro commented Jun 14, 2023

I have been trying to make it work but no success. There are some code evidences somewhere on Github that indicates that they are facing the same issue and they disabled armhf.

My question is: knowing that connector-test-kit-rs is a kit of regressive tests, is it a crazy idea to just exclude them for release compilation for armhf? (at least as a workaround)

@alyssadev
Copy link

alyssadev commented Sep 11, 2023

I've been struggling with this today and finally got it working after four hours. Sources for this solution are here, here and here. I tried building this on my Pi 4 but it didn't have enough ram (4GB); so here's how I got it cross-compiling from debian x64 (I spun up a clean VPS for this test, to replicate a CI build and also to not pollute my existing servers. this is not tested as a single script, it's mostly adapted from .bash_history, please run it line by line)

# install dependencies
sudo apt update
sudo apt install -y wget git vim curl build-essential libssl-dev docker.io unzip
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
bash rustup.sh -y
source "$HOME/.cargo/env"
cargo install cross

# get source
wget https://github.com/prisma/prisma-engines/archive/refs/heads/main.zip
unzip main.zip
cd prisma-engines-main

# set up configuration files
mkdir .cargo
cat <<EOF > .cargo/config.toml
[build]
target = "armv7-unknown-linux-gnueabihf"
EOF
cat <<EOF > Dockerfile
FROM rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.1

RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe" > /etc/apt/sources.list && \
    echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal main universe" >> /etc/apt/sources.list
RUN dpkg --add-architecture armhf && apt-get update
RUN apt-get install --assume-yes libssl-dev:armhf

ENV PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf=/usr/lib/arm-linux-gnueabihf/pkgconfig
EOF
cat <<EOF > Cross.toml
[target.armv7-unknown-linux-gnueabihf]
image = "crossbuild:local"
EOF

# create new build container, referenced by Cross.toml, then build for target arch
docker build -t crossbuild:local .
cross build --target armv7-unknown-linux-gnueabihf --release
ls target/armv7-unknown-linux-gnueabihf/release/libquery_engine.so # PRISMA_QUERY_ENGINE_LIBRARY
ls target/armv7-unknown-linux-gnueabihf/release/query-engine # PRISMA_QUERY_ENGINE_BINARY
ls target/armv7-unknown-linux-gnueabihf/release/schema-engine # PRISMA_SCHEMA_ENGINE_BINARY

edit: updated dockerfile to use focal repo's libssl, as cross armv7 image is based on xenial and that version of openssl is 1.0

@MulverineX
Copy link

MulverineX commented Nov 27, 2023

@alyssadev any progress on getting this running in CI? Also, since it is successfully building for armv7, would binaries for Android & iOS be possible? Currently there is work being done to implement Prisma in Dart, and it would be amazing if this could be expanded to provide client-side DB management on Flutter.

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

No branches or pull requests

5 participants