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

x86_64-pc-windows-gnu gitlab #1153

Closed
4 of 11 tasks
nilgoyette opened this issue Nov 23, 2022 · 5 comments
Closed
4 of 11 tasks

x86_64-pc-windows-gnu gitlab #1153

nilgoyette opened this issue Nov 23, 2022 · 5 comments

Comments

@nilgoyette
Copy link

Checklist

Describe your issue

I'm trying to create a Window build on a Linux host. I found this issue and I read the README.

Yes, I use -v /var/run/docker.sock:/var/run/docker.sock. My .gitlab-ci.yml looks like:

build:windows:
    image: "docker:latest"
    before_script:
        - apk update && apk add g++ tar wget
        - *install_rust
        - export CROSS_CONTAINER_IN_CONTAINER=true
        - cargo install cross
    script:
        - cross build --release -v

And my Cross.toml is

[build]
default-target = "x86_64-pc-windows-gnu"
pre-build = [
    "apt update",
    "apt install -y gfortran-mingw-w64-x86-64",
    "export FC=x86_64-w64-mingw32-gfortran",
    "ln -s /usr/bin/x86_64-w64-mingw32-gfortran /usr/bin/f77",
]

[build.env]
passthrough = [
    "FC"
]

When I use export CROSS_CONTAINER_IN_CONTAINER=true, I get this error

+ /usr/local/bin/docker
Error: 
   0: `docker inspect runner-sgxzu8b5-project-153-concurrent-2` failed with exit status: 1
Stderr:
   Error: No such object: runner-sgxzu8b5-project-153-concurrent-2
Stdout:
   []

When I don't use it, I get this error

+ /usr/local/bin/docker run --userns host -e FC -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e 'USER=root' --rm --user 0:0 -v /root/.xargo:/xargo:Z -v /root/.cargo:/cargo:Z -v /cargo/bin -v /builds/dmri/diffima:/project:Z -v /root/.rustup/toolchains/1.63.0-x86_64-unknown-linux-gnu:/rust:Z,ro -v /builds/dmri/diffima/target:/target:Z -w /project cross-custom-diffima:x86_64-pc-windows-gnu-6e9d4-pre-build sh -c 'PATH=$PATH:/rust/bin cargo build --release -v --target x86_64-pc-windows-gnu'
sh: 1: cargo: not found

This is better. At least the docker image is found so it goes further.

In both cases, I get this warning

error: DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain as the default.
warning: toolchain '1.63.0-x86_64-unknown-linux-gnu' may not be able to run on this system.
warning: If you meant to build software to target that platform, perhaps try `rustup target add x86_64-unknown-linux-gnu` instead?
verbose: installing toolchain '1.63.0-x86_64-unknown-linux-gnu'

The problem is, I don't know if this should work or not. Am I forgetting something?

What target(s) are you cross-compiling for?

x86_64-pc-windows-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.4

Example

No response

Additional information / notes

No response

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Nov 23, 2022

You need to use CROSS_REMOTE=1 which was implemented in #785. See the section on Gitlab CI Workflows on the wiki. There is currently a bug copying remote binaries to the host. This functionality was added in v0.2.2.

This is because remote building does not mount the local filesystem, so you need to use data volumes to have access to those files.

@nilgoyette
Copy link
Author

Sorry, I didn't check that part of the wiki.

I confirm that CROSS_REMOTE=1 fixes the problem I had. I ignored the other variables and the "services" line.

Thank you.

@Alexhuszagh
Copy link
Contributor

No worries, I'm glad everything works now.

@shandak
Copy link

shandak commented Oct 17, 2023

For some reason similar issue appeared recently(it worked without problems ~6 months) and can't figure out how to solve it

cross build -v --target x86_64-unknown-linux-musl --release
+ cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-musl
+ rustc --print sysroot
+ /usr/bin/docker
+ /usr/bin/docker version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup target add x86_64-unknown-linux-musl --toolchain stable-x86_64-unknown-linux-gnu
info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl'
info: installing component 'rust-std' for 'x86_64-unknown-linux-musl'
+ /usr/bin/docker inspect runner-xqkuh56d-project-43-concurrent-0
Error: 
   0: `/usr/bin/docker inspect runner-xqkuh56d-project-43-concurrent-0` failed with exit status: 1
Location:
   /rustc/90c54[180](https://git.slab.pp.ua/root/analytics-cli/-/jobs/591#L180)6f23a127002de5b4038be731ba1458ca/library/core/src/convert/mod.rs:727
Stderr:
   Error: No such object: runner-xqkuh56d-project-43-concurrent-0

This is the dind config with CROSS_REMOTE = 1:

  image: vshandak/cross:builder
  services:
    - name: docker:20.10.9-dind
      alias: docker
      command: ["--tls=false"]
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
    GIT_SSL_NO_VERIFY: "1"
    CROSS_REMOTE: 1
    CROSS_REMOTE_COPY_REGISTRY: 1

Dockefile

FROM debian:buster-20230502-slim

RUN apt-get update && apt-get install -y curl build-essential

# Install rustup
ENV RUSTUP_HOME=/opt/rustup
ENV CARGO_HOME=/opt/cargo
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="${PATH}:/opt/cargo/bin"

ENV RUST_TOOLCHAIN="stable"

RUN rustup toolchain install "${RUST_TOOLCHAIN}"
RUN rustup default "${RUST_TOOLCHAIN}"

RUN rustup component add clippy
RUN rustup component add rustfmt

RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-get install -y software-properties-common apt-transport-https ca-certificates curl gnupg2
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
RUN apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io libssl-dev pkg-config

# set CROSS_CONTAINER_IN_CONTAINER to inform `cross` that it is executed from within a container
ENV CROSS_CONTAINER_IN_CONTAINER=true

RUN cargo install cross --git https://github.com/cross-rs/cross

@Emilgardis
Copy link
Member

@shandak can you open a new issue please? Thanks!

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

No branches or pull requests

4 participants