rust-lang / docker-rust

The official Docker images for Rust
436 stars 88 forks source link

Facing issues while trying to cross compile to MacOs #76

Closed hbina closed 3 years ago

hbina commented 3 years ago

I have no idea what I am doing. Does rust:latest use a trimmed version of Ubuntu or Alpine or something? Can't I just use ubuntu:latest and mimic a common Rustup installation setup instead?

https://gitlab.com/hbina/lupinas-lullaby/-/jobs/1070042915

Running with gitlab-runner 13.9.0-rc2 (69c049fd)
  on docker-auto-scale 0277ea0f
  feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true
section_start:1614781733:resolve_secrets
Resolving secrets
section_end:1614781733:resolve_secrets
section_start:1614781733:prepare_executor
Preparing the "docker+machine" executor
Using Docker executor with image rust:latest ...
Pulling docker image rust:latest ...
Using docker image sha256:a1d85bc5818fe0f51eadf97944fa65e96339a8465b3dce7a9e3ff49a179f1899 for rust:latest with digest rust@sha256:91a70ac97ddb82978060db53b994f5edac1253f33dd417551810a4feac0b2245 ...
section_end:1614781777:prepare_executor
section_start:1614781777:prepare_script
Preparing environment
Running on runner-0277ea0f-project-24518942-concurrent-0 via runner-0277ea0f-srm-1614781685-ec81ce78...
section_end:1614781778:prepare_script
section_start:1614781778:get_sources
Getting source from Git repository
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/hbina/lupinas-lullaby/.git/
Created fresh repository.
Checking out c5c948d1 as adding-gitlab-ci...

Skipping Git submodules setup
section_end:1614781780:get_sources
section_start:1614781780:restore_cache
Restoring cache
Checking cache for default...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/24518942/default 
Successfully extracted cache
section_end:1614781799:restore_cache
section_start:1614781799:step_script
Executing "step_script" stage of the job script
Using docker image sha256:a1d85bc5818fe0f51eadf97944fa65e96339a8465b3dce7a9e3ff49a179f1899 for rust:latest with digest rust@sha256:91a70ac97ddb82978060db53b994f5edac1253f33dd417551810a4feac0b2245 ...
$ rustup target add x86_64-apple-darwin
info: downloading component 'rust-std' for 'x86_64-apple-darwin'
info: installing component 'rust-std' for 'x86_64-apple-darwin'
info: using up to 500.0 MiB of RAM to unpack components
$ git clone --recursive https://github.com/tpoechtrager/osxcross
Cloning into 'osxcross'...
$ cd osxcross
$ tools/get_dependencies.sh
Reading package lists...
Building dependency tree...
Reading state information...
Package cpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  tar

W: --force-yes is deprecated, use one of the options starting with --allow instead.
E: Unable to locate package clang
E: Unable to locate package llvm-dev
E: Package 'cpio' has no installation candidate
section_end:1614781808:step_script
section_start:1614781808:cleanup_file_variables
Cleaning up file based variables
section_end:1614781809:cleanup_file_variables
ERROR: Job failed: exit code 1

sfackler commented 3 years ago

The image is based off of Debian, not Ubuntu.

Yes, you can install Rust on to an ubuntu base image.

hbina commented 3 years ago

Do you have any idea how to fix this error?

     Running `rustc --crate-name lupinas_lullaby --edition=2018 src/bin/lupinas-lullaby.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C metadata=b0368c6058fe20e7 --out-dir /builds/project-0/target/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -C linker=x86_64-apple-darwin14-clang -L dependency=/builds/project-0/target/x86_64-apple-darwin/release/deps -L dependency=/builds/project-0/target/release/deps --extern clap=/builds/project-0/target/x86_64-apple-darwin/release/deps/libclap-dfa7ee4d5c781676.rlib --extern openapi=/builds/project-0/target/x86_64-apple-darwin/release/deps/libopenapi-3fc09eda27b5855f.rlib --extern reqwest=/builds/project-0/target/x86_64-apple-darwin/release/deps/libreqwest-68061a8d84e61abc.rlib --extern serde=/builds/project-0/target/x86_64-apple-darwin/release/deps/libserde-50a30cd900126cad.rlib --extern serde_json=/builds/project-0/target/x86_64-apple-darwin/release/deps/libserde_json-79d1234ddf2da739.rlib --extern serde_yaml=/builds/project-0/target/x86_64-apple-darwin/release/deps/libserde_yaml-d710f569916a15ed.rlib`
error: linking with `x86_64-apple-darwin14-clang` failed: exit code: 1
  |
  = note: "x86_64-apple-darwin14-clang" "-m64" "-arch" "x86_64" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/builds/project-0/target/x86_64-apple-darwin/release/deps/lupinas_lullaby.lupinas_lullaby.bn7njmnh-cgu.2.rcgu.o" "-o" "/builds/project-0/target/x86_64-apple-darwin/release/deps/lupinas_lullaby" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/builds/project-0/target/x86_64-apple-darwin/release/deps" "-L" "/builds/project-0/target/release/deps" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-57851e98e05f8123.rlib" "-framework" "Security" "-framework" "CoreFoundation" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: Undefined symbols for architecture x86_64:
            "_SecTrustEvaluateWithError", referenced from:
                security_framework::secure_transport::MidHandshakeClientBuilder$LT$S$GT$::handshake::h1e72be237be33dcd in lupinas_lullaby.lupinas_lullaby.bn7njmnh-cgu.2.rcgu.o
                security_framework::secure_transport::MidHandshakeClientBuilder$LT$S$GT$::handshake::h9af4b917b181f81a in lupinas_lullaby.lupinas_lullaby.bn7njmnh-cgu.2.rcgu.o
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
sfackler commented 3 years ago

I do not, but this repository is probably not the right place to ask for support on cross compiling from Linux to macOS.