Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Using cross with additional libraries #115

Open
2 of 3 tasks
kpcyrd opened this issue Oct 3, 2020 · 3 comments
Open
2 of 3 tasks

Using cross with additional libraries #115

kpcyrd opened this issue Oct 3, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@kpcyrd
Copy link

kpcyrd commented Oct 3, 2020

Do the checklist before filing an issue:

Motivation

I'm currently using github actions to test-build my project with for x86_64. I'd like to extend this to other architectures, and there's an example in the README on how to do that. I've tried to use that for my project, but then noticed the build fails my project depends on additional libaries that are missing in the cross build container. This is related to cross-rs/cross#149 but it's unclear how to use the hacks mentioned in the issue with github actions.

Workflow example

I don't know what's the best way to integrate this, and I assume it'd need proper support by cross.

on: [push]

name: ARMv7 build

jobs:
  linux_arm7:
    name: Linux ARMv7
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: armv7-unknown-linux-gnueabihf
          override: true
      # prepare container image somehow
      - uses: actions-rs/cargo@v1
        with:
          apt:
          - libpcap-dev
          - libseccomp-dev
      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --target armv7-unknown-linux-gnueabihf

Additional context

I wrote this script in an attempt to apply the workarounds mentioned in the cross issue tracker, but couldn't get it to work because I need to have the cross binary in advance to detect the version for the image I'm preparing (therefore this is all untested):

#!/bin/sh
set -xe

case "$1" in
    arm-*)
        ARCH=arm64
        ;;
    armv7-*)
        ARCH=arm64
        ;;
    aarch64-*)
        ARCH=arm64
        ;;
    i686-*)
        ARCH=i386
        ;;
    *)
        echo 'ERROR: unknown arch'
        exit 1
        ;;
esac

CROSS=`cross -V | sed -nr 's/cross (.*)/\1/p'`

cat > Dockerfile.cross <<EOF
FROM rustembedded/cross:$1-$CROSS
RUN dpkg --add-architecture $ARCH && \
    apt-get update && \
    apt-get install libpcap-dev:$ARCH libseccomp-dev:$ARCH
EOF

docker build -t "rustembedded/cross:$1-$CROSS" Dockerfile.cross
@kpcyrd kpcyrd added the enhancement New feature or request label Oct 3, 2020
@Animeshz
Copy link

Animeshz commented Oct 9, 2021

Any updates? 👀 (Also: is there a way to run a few startup shell commands in the docker image before we proceed to the compilation? instead of creating and maintaining a new docker image?)

@wcampbell0x2a
Copy link

I would also like this feature for the same use case as above of needing an external library to compile my code.

@Emilgardis
Copy link

cc cross-rs/cross#635

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Development

No branches or pull requests

4 participants