Git Product home page Git Product logo

rust-linux-darwin-builder's Introduction

Rust Linux / Darwin Builder

Use the same Docker image to cross-compile Rust programs for Linux (musl libc) and macOS (osxcross)

Build Status Docker Image Version (tag latest semver) Docker Image Size (tag) Docker Image

Overview

This is a Linux Docker image based on ekidd/rust-musl-builder but using the latest Debian 12-slim (Bookworm).

It contains essential tools for cross-compile Rust projects such as Linux static binaries via musl-libc / musl-gcc (x86_64-unknown-linux-musl) and macOS binaries (x86_64-apple-darwin) via osxcross just using the same Linux image.

The Docker image is multi-arch (amd64 and arm64) so you can use them in native environments. Also, it is possible to cross-compile arm64 Linux or Darwin apps from the x86_64 Docker image variant.

Usage

Compiling an application inside a Docker container

By default, the working directory is /root/src.

x86_64 (amd64)

Below are the default toolchains included in the Docker image.

x86_64-unknown-linux-musl

docker run --rm \
    --volume "${PWD}/sample":/root/src \
    --workdir /root/src \
      joseluisq/rust-linux-darwin-builder:1.77.1 \
        sh -c "cargo build --release --target x86_64-unknown-linux-musl"

x86_64-unknown-linux-gnu

docker run --rm \
    --volume "${PWD}/sample":/root/src \
    --workdir /root/src \
      joseluisq/rust-linux-darwin-builder:1.77.1 \
        sh -c "cargo build --release --target x86_64-unknown-linux-gnu"

x86_64-apple-darwin

docker run --rm \
    --volume "${PWD}/sample":/root/src \
    --workdir /root/src \
      joseluisq/rust-linux-darwin-builder:1.77.1 \
        sh -c "cargo build --release --target x86_64-apple-darwin"

aarch64 (arm64)

aarch64-unknown-linux-gnu

docker run --rm \
    --volume "${PWD}/sample":/root/src \
    --workdir /root/src \
      joseluisq/rust-linux-darwin-builder:1.77.1 \
        sh -c "cargo build --release --target aarch64-unknown-linux-gnu"

aarch64-unknown-linux-musl

docker run --rm \
    --volume "${PWD}/sample":/root/src \
    --workdir /root/src \
      joseluisq/rust-linux-darwin-builder:1.77.1 \
        sh -c "cargo build --release --target aarch64-unknown-linux-musl"

aarch64-apple-darwin

docker run --rm \
    --volume "${PWD}/sample":/root/src \
    --workdir /root/src \
      joseluisq/rust-linux-darwin-builder:1.77.1 \
        sh -c "cargo build --release --target aarch64-apple-darwin"

Cargo Home advice

It's known that the CARGO_HOME points to $HOME/.cargo by default (/root/.cargo in this case). However, if you want to use a custom Cargo home directory then make sure to copy the Cargo config file to the particular directory like cp "$HOME/.cargo/config" "$CARGO_HOME/" before to cross-compile your program. Otherwise, you could face a linking error when for example you want to cross-compile to an x86_64-apple-darwin target.

Dockerfile

You can also use the image as a base for your Dockerfile:

FROM joseluisq/rust-linux-darwin-builder:1.77.1

OSXCross

You can also use o32-clang(++) and o64-clang(++) as a normal compiler.

Notes:

  • The current 11.3 SDK does not support i386 anymore. Use <= 10.13 SDK if you rely on i386 support.
  • The current 11.3 SDK does not support libstdc++ anymore. Use <= 10.13 SDK if you rely on libstdc++ support.

Examples:

Example usage:

Example 1: CC=o32-clang ./configure --host=i386-apple-darwin22.4
Example 2: CC=i386-apple-darwin22.4-clang ./configure --host=i386-apple-darwin22.4
Example 3: o64-clang -Wall test.c -o test
Example 4: x86_64-apple-darwin22.4-strip -x test

!!! Use aarch64-apple-darwin22.4-* instead of arm64-* when dealing with Automake !!!
!!! CC=aarch64-apple-darwin22.4-clang ./configure --host=aarch64-apple-darwin22.4 !!!
!!! CC="aarch64-apple-darwin22.4-clang -arch arm64e" ./configure --host=aarch64-apple-darwin22.4 !!!

Cross-compilation example

Below is a simple example of using a Makefile to cross-compile a Rust app.

Notes:

  • A hello world app is used.
  • A custom directory is used below as a working directory instead of /root/src.

Create a Makefile:

compile:
	@docker run --rm -it \
		-v $(PWD):/drone/src \
		-w /drone/src \
			joseluisq/rust-linux-darwin-builder:1.77.1 \
				make cross-compile
.PHONY: compile

cross-compile:
	@echo
	@echo "1. Cross compiling example..."
	@rustc -vV
	@echo
	@echo "2. Compiling application (linux-musl x86_64)..."
	@cargo build --manifest-path=tests/hello-world/Cargo.toml --release --target x86_64-unknown-linux-musl
	@du -sh tests/hello-world/target/x86_64-unknown-linux-musl/release/helloworld
	@echo
	@echo "3. Compiling application (apple-darwin x86_64)..."
	@cargo build --manifest-path=tests/hello-world/Cargo.toml --release --target x86_64-apple-darwin
	@du -sh tests/hello-world/target/x86_64-apple-darwin/release/helloworld
.PHONY: cross-compile

Just run the makefile compile target, then you will see two release binaries x86_64-unknown-linux-musl and x86_64-apple-darwin.

make compile
# 1. Cross compiling example...

rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-unknown-linux-gnu
release: 1.77.1
LLVM version: 17.0.6

# 2. Compiling application (linux-musl x86_64)...
#     Finished release [optimized] target(s) in 0.01s
# 1.2M	tests/hello-world/target/x86_64-unknown-linux-musl/release/helloworld

# 3. Compiling application (apple-darwin x86_64)...
#     Finished release [optimized] target(s) in 0.01s
# 240K	tests/hello-world/target/x86_64-apple-darwin/release/helloworld

For more details take a look at Cross-compiling Rust from Linux to macOS by James Waples.

Macos ARM64

See joseluisq/rust-linux-darwin-builder#7

Building *-sys crates

If some of your crates require C bindings and you run into a compilation or linking error, try to use Clang for C/C++ builds.

For example to cross-compile to Macos:

CC=o64-clang \
CXX=o64-clang++ \
	cargo build --target x86_64-apple-darwin
  # Or
	cargo build --target aarch64-apple-darwin

OpenSSL release advice

Until v1.42.0 of this project, one old OpenSSL release v1.0.2 was used.
Now, since v1.43.x or greater, OpenSSL v1.1.1 (LTS) is used which is supported until 2023-09-11.
View more at https://www.openssl.org/policies/releasestrat.html.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in current work by you, as defined in the Apache-2.0 license, shall be dual licensed as described below, without any additional terms or conditions.

Feel free to send some Pull request or file an issue.

License

This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

© 2019-present Jose Quintana

rust-linux-darwin-builder's People

Contributors

joseluisq avatar markmandel avatar ovr avatar rjkroege avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rust-linux-darwin-builder's Issues

Image for 1.71.1 (CVE-2023-38497 in cargo)

This is literally just so I can track the release and also make sure you are aware of the security issue 😃.

I definitely don't expect a sub-hour turnaround 😄 !

1.71.1 released today because of CVE-2023-38497 in cargo, and because of the security issue, we're updating fast to 1.71.1, so if there was a new release in the pipeline, that would be awesome! 😃

Context:

Mac Arm64 Support & Example?

Thanks for the awesome tool.

I was wondering if it is possible to cross compile to aarch64-apple-darwin rust target (arm64 darwin) since this is using https://github.com/tpoechtrager/osxcross? If so can an example be given and update the read me with it? I know the Readme talks about it but it is not clear and it doesn't work.

Example of how I am trying to compile the project:

docker run --rm \
    --volume "${PWD}/":/root/src:z \
    --workdir /root/src \
    joseluisq/rust-linux-darwin-builder:1.57.0 \
    sh -c "rustup target add aarch64-apple-darwin && CC=oa64-clang CXX=oa64-clang++ LIBZ_SYS_STATIC=1 cargo build --release --target aarch64-apple-darwin"

Building crates needing C++ fails

When I use the builder, crates that contain Rust-compiled C++ code fail to link. Example:

...much spew...
  = note: ld: archive has no table of contents file '/root/src/difft/target/aarch64-apple-darwin/release/build/difftastic-abae5b1432a24d5f/out/libtree-sitter-ada.a' for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
...much spew...

AFAIK: lib tree-sitter-ada.a is built from C++ code by the difftastic crate.

This is working as intended? Or am I being an idiot?

Native linux/arm64 image?

Working on a Debian arm64 machine, and want to be able to cross compile to macOS.

I'm currently running this image under linux/amd64 emulation (Qemu) to work on my machine, but it's sloooow 😥, and ultimately fails for reasons I've yet to determine.

Having a native linux/arm64 image would make things a lot faster, and I'm guessing less error prone! So figured I would ask to see if it was possible.

Thank you very much!

This is just an issue to say 🎆 thank you for this project 🎆 - I thought cross compilation from linux to macOS was going to be a nightmare, but this made it super easy.

image

Compiling A Project That Uses Tao

I am trying to compile this.

Running this:

env CC="o64-clang" CXX="o64-clang++" cargo build --locked --target x86_64-apple-darwin

yields this error:

error: could not find native static library `carbon_hotkey_binding.a`, perhaps an -L flag is missing?

error: could not compile `tao` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

The relevant C files are here.

I also tried to build that file directly with o64-clang carbon_hotkey_binding.c -o carbon_hotkey_binding.a -v:

Debian clang version 11.0.1-2
Target: x86_64-apple-darwin21.1
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-11/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name carbon_hotkey_binding.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-rounding-math -munwind-tables -target-sdk-version=12.0 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -debugger-tuning=lldb -target-linker-version 609 -v -resource-dir /usr/lib/llvm-11/lib/clang/11.0.1 -isystem /usr/lib/llvm-11/bin/../lib/clang/11.0.1/include -isysroot /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk -cxx-isystem /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/usr/include/c++/v1 -internal-isystem /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/usr/local/include -internal-isystem /usr/lib/llvm-11/lib/clang/11.0.1/include -internal-externc-isystem /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/usr/include -Wno-liblto -fdebug-compilation-dir /root/src/tao-tao-v0.8.3/src/platform_impl/macos/carbon_hotkey -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcolor-diagnostics -o /tmp/carbon_hotkey_binding-873a40.o -x c carbon_hotkey_binding.c
clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/usr/local/include"
ignoring nonexistent directory "/usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/Library/Frameworks"
ignoring duplicate directory "/usr/lib/llvm-11/bin/../lib/clang/11.0.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/llvm-11/bin/../lib/clang/11.0.1/include
 /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/usr/include
 /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/usr/local/osxcross/target/bin/x86_64-apple-darwin21.1-ld" -demangle -lto_library /usr/lib/llvm-11/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.14.0 12.0 -syslibroot /usr/local/osxcross/target/bin/../SDK/MacOSX12.0.sdk -o carbon_hotkey_binding.a /tmp/carbon_hotkey_binding-873a40.o -lSystem
Undefined symbols for architecture x86_64:
  "_GetApplicationEventTarget", referenced from:
      _install_event_handler in carbon_hotkey_binding-873a40.o
      _register_hotkey in carbon_hotkey_binding-873a40.o
  "_GetEventParameter", referenced from:
      _hotkey_handler in carbon_hotkey_binding-873a40.o
  "_InstallEventHandler", referenced from:
      _install_event_handler in carbon_hotkey_binding-873a40.o
  "_RegisterEventHotKey", referenced from:
      _register_hotkey in carbon_hotkey_binding-873a40.o
  "_RemoveEventHandler", referenced from:
      _uninstall_event_handler in carbon_hotkey_binding-873a40.o
  "_UnregisterEventHotKey", referenced from:
      _unregister_hotkey in carbon_hotkey_binding-873a40.o
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there something really simple I am missing here?

no musl clang/gcc breaks compiling some crates for armv7-unknown-linux-musleabihf target

Some of the crates that I've tried (e.g. libz-sys) need this kind of construct:

CC=musl-gcc \
CXX=musl-g++ \
cargo build \
	--manifest-path <path>/Cargo.toml \
	--release \
	--target x86_64-unknown-linux-musl

All fine and good. This works for x86_64-unknown-linux-musl but not for armv7-unknown-linux-musleabihf. My intuition from inspecting musl-gcc is that this would work if there were similar wrappers pointing at /usr/lib/arm-linux-musl that is the arm version of /usr/lib/x86_64-linux-musl

Does this seem right? If so, I'll try to write up another PR. Any hints on how to most easily do this would be welcome.

Compilation fails in GitLab CI

I wanted to use this image to automatically build macOS binaries but it's not working out for some reason.

When I ran the image using podman on the same server it does work, though.

$ podman run -it joseluisq/rust-linux-darwin-builder
$ git clone https://gitgud.io/nixx/inquirs/ 
$ cd inquirs
$ cargo build --release --target=x86_64-apple-darwin
# works!

in CI:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.0.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.1.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.10.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.11.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.12.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.13.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.14.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.15.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.2.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.3.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.4.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.5.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.6.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.7.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.8.rcgu.o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.inquirs.46q463ij-cgu.9.rcgu.o" "-o" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/inquirs.sbos325t37vyccn.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps" "-L" "/home/user/nixx/inquirs/target/release/deps" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libcrossterm-013f4c15523506cc.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libsignal_hook-90e3c3f4ba572f80.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libsignal_hook_registry-93104b4940893217.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libmio-8598f6ef521bd038.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/liblog-e50ed45a6ece6c8e.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/liblazy_static-a598c89f717ca744.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libbitflags-5714a0ef175ceec8.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libparking_lot-ff41adc08c71d02a.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libparking_lot_core-9c85518863cb4dfe.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/liblibc-71390682de1c85c2.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libsmallvec-4c513aa56c8b7b2c.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/liblock_api-181162683a0d1810.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libscopeguard-e6fc67cd518d4401.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libinstant-f2e0f75766132e58.rlib" "/home/user/nixx/inquirs/target/x86_64-apple-darwin/release/deps/libcfg_if-3786c029dcae5619.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libstd-9225b8e469c32698.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-2fe2b8cd4fa63c34.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libobject-80083cf4ee7ee3ff.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-ddf3832e718029e6.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libgimli-ba92c986e8ef2ca8.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-acd0bd456d8da820.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-55608c4156e4ecbb.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-4be618026614fdc7.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libunwind-fee25922260aa100.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-38ba3c5cc408e14d.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/liblibc-899852a009fbe35f.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/liballoc-5687564a0ccea916.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-9ed2c58b16cff4ee.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcore-244bf5611f93ff45.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-70df686e6b4ebf5b.rlib" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv"
  = note: cc: error: x86_64: No such file or directory
          cc: error: unrecognized command line option '-arch'; did you mean '-march='?
          
error: aborting due to previous error

https://gitgud.io/nixx/inquirs/-/jobs/155135

# ci configuration

x86_64-apple-darwin:
  stage: build
  image: joseluisq/rust-linux-darwin-builder
  artifacts:
    paths:
      - target/x86_64-apple-darwin/release/$CI_PROJECT_NAME
  script:
    - cargo build --release --target=x86_64-apple-darwin

I hope you can at least give me some advice on why this may be happening.

Fails to compile protobuf-src = "1.1.0+21.5"

Not 100% sure if this is an issue with rust-linux-darwin-builder, but I also figure now that https://github.com/tokio-rs/prost 0.11 requires a local protoc, this is likely going to come up in the near future for a few people.

So we're attempting to use https://crates.io/crates/protobuf-src to vendor protoc locally as a build-dependency in our Cargo.toml, which generally works fine, except when we're trying to cross compile to a mac build, the following happens when it tries to compile:

➜  build git:(pr/update-deps) make build-macos-binary
docker run --rm -v /home/mark/workspace/quilkin:/workspace -w /workspace \
        -v ~/.cargo/registry:/root/.cargo/registry \
        -e "CARGO_TARGET_DIR=/workspace/target/build-image" \
        -e "CC=o64-clang" -e "CXX=o64-clang++" \
        us-docker.pkg.dev/quilkin/ci/rust-linux-darwin-builder:"1.65.0" \
                sh -c "rustup target add x86_64-apple-darwin && cargo build --release --target x86_64-apple-darwin"
info: syncing channel updates for '1.65.0-x86_64-unknown-linux-gnu'
info: latest update on 2022-11-03, rust version 1.65.0 (897e37553 2022-11-02)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
info: downloading component 'rust-std' for 'x86_64-apple-darwin'
info: installing component 'rust-std' for 'x86_64-apple-darwin'
   Compiling libgit2-sys v0.12.26+1.3.0
   Compiling libz-sys v1.1.8
   Compiling protobuf-src v1.1.0+21.5
   Compiling rustix v0.36.4
   Compiling axum-core v0.3.0
   Compiling addr2line v0.17.0
   Compiling serde_json v1.0.89
   Compiling miniz_oxide v0.5.4
   Compiling eyre v0.6.8
   Compiling kube-client v0.76.0
   Compiling backtrace v0.3.66
   Compiling regex v1.7.0
   Compiling stacker v0.1.15
   Compiling axum v0.6.1
   Compiling proc-macro-error v1.0.4
   Compiling psm v0.1.21
   Compiling darling v0.14.1
   Compiling darling v0.13.4
   Compiling crossbeam-utils v0.8.11
   Compiling ahash v0.8.0
   Compiling ahash v0.7.6
   Compiling tonic-build v0.8.4
   Compiling backoff v0.4.0
   Compiling regex-automata v0.1.10
   Compiling prost v0.11.3
   Compiling async-stream-impl v0.3.3
   Compiling derivative v2.2.0
   Compiling object v0.29.0
   Compiling snap v1.0.5
   Compiling os_str_bytes v6.3.0
   Compiling prometheus v0.13.3
   Compiling cached_proc_macro_types v0.1.0
   Compiling matchit v0.7.0
   Compiling same-file v1.0.6
   Compiling sync_wrapper v0.1.1
error: failed to run custom build command for `protobuf-src v1.1.0+21.5`

Caused by:
  process didn't exit successfully: `/workspace/target/build-image/release/build/protobuf-src-d5aea2da6cc4b31d/build-script-build` (exit status: 101)
  --- stdout
  running: "sh" "-c" "exec \"$0\" \"$@\"" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/protobuf-src-1.1.0+21.5/protobuf/configure" "--prefix=/workspace/target/build-image/release/build/protobuf-src-a2a5be1d214dd3cd/out/install" "--disable-shared" "--enable-static" "--disable-maintainer-mode"
  checking whether to enable maintainer-specific portions of Makefiles... no
  checking build system type... x86_64-pc-linux-gnu
  checking host system type... x86_64-pc-linux-gnu
  checking target system type... x86_64-pc-linux-gnu
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  checking for a race-free mkdir -p... /bin/mkdir -p
  checking for gawk... no
  checking for mawk... mawk
  checking whether make sets $(MAKE)... yes
  checking whether make supports nested variables... yes
  checking whether UID '0' is supported by ustar format... yes
  checking whether GID '0' is supported by ustar format... yes
  checking how to create a ustar tar archive... gnutar
  checking whether make supports nested variables... (cached) yes
  checking for gcc... o64-clang
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables...
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether the compiler supports GNU C... yes
  checking whether o64-clang accepts -g... yes
  checking for o64-clang option to enable C11 features... none needed
  checking whether o64-clang understands -c and -o together... yes
  checking whether make supports the include directive... yes (GNU style)
  checking dependency style of o64-clang... gcc3
  checking whether the compiler supports GNU C++... yes
  checking whether o64-clang++ accepts -g... yes
  checking for o64-clang++ option to enable C++11 features... none needed
  checking dependency style of o64-clang++... gcc3
  checking how to run the C preprocessor... o64-clang -E
  checking for gcc... gcc
  checking whether the compiler supports GNU C... (cached) yes
  checking whether gcc accepts -g... yes
  checking for gcc option to enable C11 features... (cached) none needed
  checking whether gcc understands -c and -o together... (cached) yes
  checking dependency style of gcc... (cached) gcc3
  checking how to run the C preprocessor... gcc -E
  checking how to run the C++ preprocessor... o64-clang++ -E
  checking for g++... g++
  checking whether the compiler supports GNU C++... (cached) yes
  checking whether g++ accepts -g... yes
  checking for g++ option to enable C++11 features... (cached) none needed
  checking dependency style of g++... (cached) gcc3
  checking how to run the C++ preprocessor... g++ -E
  checking for stdio.h... yes
  checking for stdlib.h... yes
  checking for string.h... yes
  checking for inttypes.h... yes
  checking for stdint.h... yes
  checking for strings.h... yes
  checking for sys/stat.h... yes
  checking for sys/types.h... yes
  checking for unistd.h... yes
  checking for wchar.h... yes
  checking for minix/config.h... no
  checking whether it is safe to define __EXTENSIONS__... yes
  checking whether _XOPEN_SOURCE should be defined... no
  checking for ar... ar
  checking the archiver (ar) interface... ar
  checking C++ compiler flags...... use user-supplied: -O0 -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-gnu
  checking for o64-clang++ options needed to detect all undeclared functions... cannot detect

  --- stderr
  configure: error: in `/workspace/target/build-image/release/build/protobuf-src-a2a5be1d214dd3cd/out/install/build':
  configure: error: cannot make o64-clang++ report undeclared builtins
  See `config.log' for more details
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/autotools-0.2.5/src/lib.rs:715:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
make: *** [Makefile:150: build-macos-binary] Error 101

I'm sorta at a loss, so figured I'd ask here, since I'm figuring other people might have also run into the same thing? Or I can also take this over to the protobuf github? not sure. Help? 😞

Compile error on Mac M1

I am trying to build https://github.com/starship/starship on my Mac Air M1 with:

docker run --rm  --volume "${PWD}":/root/src --workdir /root/src joseluisq/rust-linux-darwin-builder:1.67.1 sh -c "cargo build --release --target aarch64-apple-darwin"

but it fails with below

warning: cc: error: arm64: No such file or directory
warning: cc: error: unrecognized command-line option '-arch'; did you mean '-march='?
error: failed to run custom build command for `sha1-asm v0.5.1`

Caused by:
  process didn't exit successfully: `/root/src/target/release/build/sha1-asm-2010612ad33992cd/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-unknown-linux-gnu")
  CC_aarch64-apple-darwin = None
  CC_aarch64_apple_darwin = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_aarch64-apple-darwin = None
  CFLAGS_aarch64_apple_darwin = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-Wall" "-Wextra" "-march=armv8-a+crypto" "-c" "-o" "/root/src/target/aarch64-apple-darwin/release/build/sha1-asm-9f091d7d0969abf5/out/src/aarch64_apple.o" "-c" "src/aarch64_apple.S"
  cargo:warning=cc: error: arm64: No such file or directory
  cargo:warning=cc: error: unrecognized command-line option '-arch'; did you mean '-march='?
  exit status: 1
  --- stderr
 error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-Wall" "-Wextra" "-march=armv8-a+crypto" "-c" "-o" "/root/src/target/aarch64-apple-darwin/release/build/sha1-asm-9f091d7d0969abf5/out/src/aarch64_apple.o" "-c" "src/aarch64_apple.S" with args "cc" did not execute successfully (status code exit status: 1)

On my Linux machine I don't have that problem, I can build the cmd tool and run it fine on my Mac.

glibc error

  Downloaded 280 crates (33.0 MB) in 34.15s (largest was `tui-logger` at 8.1 MB)
   Compiling libc v0.2.147
   Compiling memchr v2.5.0
   Compiling parking_lot_core v0.9.8
   Compiling futures-core v0.3.28
   Compiling tracing-core v0.1.31
error: failed to run custom build command for `memchr v2.5.0`

Caused by:
  process didn't exit successfully: `/src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build` (exit status: 1)
  --- stderr
  /src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build)
  /src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build)
  /src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /src/target/release/build/memchr-7334ea422cd9b5ca/build-script-build)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `futures-core v0.3.28`

Caused by:
  process didn't exit successfully: `/src/target/release/build/futures-core-17a064b09420e2b4/build-script-build` (exit status: 1)
  --- stderr
  /src/target/release/build/futures-core-17a064b09420e2b4/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /src/target/release/build/futures-core-17a064b09420e2b4/build-script-build)
  /src/target/release/build/futures-core-17a064b09420e2b4/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /src/target/release/build/futures-core-17a064b09420e2b4/build-script-build)
  /src/target/release/build/futures-core-17a064b09420e2b4/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /src/target/release/build/futures-core-17a064b09420e2b4/build-script-build)
error: failed to run custom build command for `parking_lot_core v0.9.8`

Caused by:
  process didn't exit successfully: `/src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build` (exit status: 1)
  --- stderr
  /src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build)
  /src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build)
  /src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /src/target/release/build/parking_lot_core-9db2d863f5bd676d/build-script-build)
root@5b16153af4c7:/src# ls /lib/x86_64-linux-gnu/libc.so.6
/lib/x86_64-linux-gnu/libc.so.6
root@5b16153af4c7:/src# uname -a
Linux 5b16153af4c7 5.15.49-linuxkit-pr #1 SMP Thu May 25 07:17:40 UTC 2023 x86_64 GNU/Linux

Compiling for MacOS error: `x86_64-apple-darwin21.4-pkg-config`

Hi. So I've inherited a bunch of cross-compiling scripts and dockerfiles for a piece of software, which recently broke without any changes. The start of this looks similar to the other open issue, but I think it's slightly different. I've highlighted what I think are the important lines in the build log.

The Dockerfile adds some context to the error. It's actually recorded in some docs that this exact error happened before and how to 'solve' it, which is also written in the Dockerfile above the ENV PKG_CONFIG declaration. The darwin version doesn't appear to have been updated, but I tried all the later darwin version numbers anyway for the sake of it. I'm not sure where to go from here so any help would be appreciated.

error: failed to run custom build command for `compress-tools v0.12.2 (/root/src/vendor/compress-tools)`

Caused by:
  process didn't exit successfully: `/root/src/target/release/build/compress-tools-6c5ade467fb885c6/build-script-build` (exit status: 101)

  --- stdout
  cargo:rerun-if-env-changed=LIBARCHIVE_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_apple_darwin
  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_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBARCHIVE_STATIC
  cargo:rerun-if-env-changed=LIBARCHIVE_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
  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_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
  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_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr

-  thread 'main' panicked at 'Unable to find libarchive: `"x86_64-apple-darwin21.4-pkg-config" "--static" "--libs" "--cflags" "libarchive" "libarchive >= 3.2.0"` did not exit successfully: exit status: 1

-  error: could not find system library 'libarchive' required by the 'compress-tools' crate

  --- stderr

  osxcross: warning: x86_64-apple-darwin21.4-pkg-config: ignoring environment variable 'PKG_CONFIG' - please see [README.PKG-CONFIG.md](http://readme.pkg-config.md/) for more
  osxcross: warning: x86_64-apple-darwin21.4-pkg-config: ignoring environment variable 'PKG_CONFIG_ALLOW_CROSS' - please see [README.PKG-CONFIG.md](http://readme.pkg-config.md/) for more
  osxcross: warning: x86_64-apple-darwin21.4-pkg-config: ignoring environment variable 'PKG_CONFIG_ALLOW_SYSTEM_CFLAGS' - please see [README.PKG-CONFIG.md](http://readme.pkg-config.md/) for more
  osxcross: warning: x86_64-apple-darwin21.4-pkg-config: ignoring environment variable 'PKG_CONFIG_ALLOW_SYSTEM_LIBS' - please see [README.PKG-CONFIG.md](http://readme.pkg-config.md/) for more
  osxcross: warning: x86_64-apple-darwin21.4-pkg-config: ignoring environment variable 'PKG_CONFIG_ALL_STATIC' - please see [README.PKG-CONFIG.md](http://readme.pkg-config.md/) for more
  osxcross: warning: x86_64-apple-darwin21.4-pkg-config: ignoring environment variable 'PKG_CONFIG_PATH' - please see [README.PKG-CONFIG.md](http://readme.pkg-config.md/) for more
  Package iconv was not found in the pkg-config search path.

  Perhaps you should add the directory containing `iconv.pc'  to the PKG_CONFIG_PATH environment variable

  Package 'iconv', required by 'libarchive', not found
  Package 'iconv', required by 'libarchive', not found
  ', vendor/compress-tools/src/build.rs:14:10

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish...

The command "nvm install 16 && ./config/build-mac.sh x86_64" exited with 101.
ARG RUST_VERSION=latest

FROM joseluisq/rust-linux-darwin-builder:${RUST_VERSION}

# Or aarch64
ARG ARCH=x86_64

WORKDIR /root/src

ENV CC=/usr/local/osxcross/target/bin/o64-clang

ENV CXX=/usr/local/osxcross/target/bin/o64-clang++

ENV MACOSX_DEPLOYMENT_TARGET=12.0

ENV OSXCROSS_MACPORTS_MIRROR=http://packages.macports.org/

RUN osxcross-macports install libarchive macports-libcxx

# If pkg_config wasn't found in the build, check if the 21.4 still is accurate 
# I spent days trying to figure out what was wrong and all I had to change was a 21.1 to 21.4
ENV PKG_CONFIG=${ARCH}-apple-darwin21.4-pkg-config

# We need to add some additional libraries to be linked for a successful build, I think
# libxml2 may be misconfigured in macports which causes this
ENV RUSTFLAGS="-C target-feature=+crt-static -L /usr/local/osxcross/target/macports/pkgs/opt/local/lib -l icuuc -l icudata -L /usr/local/osxcross/target/macports/pkgs/opt/local/lib/libcxx/ -l c++ -l c++abi"
ENV PKG_CONFIG_ALL_STATIC=true

# There might be a better way of doing this, but removing the dylibs forces static linking
RUN bash -c "rm /usr/local/osxcross/target/macports/pkgs/opt/local/lib/{*.dylib,**/*.dylib}"

# Rust does not currently support universal static libraries, so we convert them to the appropriate architecture here

ADD mac/fix-mac-libs.sh /tmp

RUN bash /tmp/fix-mac-libs.sh ${ARCH}

ncurses support?

Is it possible to use your image for cross-compilig a project that uses ncurses?

I tried issuing apt-get install libncurses5-dev libncursesw5-dev (in my CI @ GitLab) but it failed with: the following:

$ apt-get install libncurses5 libncurses5-dev libncursesw5-dev
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libncurses5
E: Unable to locate package libncurses5-dev
E: Unable to locate package libncursesw5-dev

Would be grateful for some advice :)

Unable to compile for macos

Hi, I'm trying to compile my rust project from Ubuntu 20.04 to MacOS. When I'm trying to follow the instruction in the Readme.md and it gives me the following error.

Caused by: process didn't exit successfully: /app/target/release/build/openssl-sys-5fe4cd3754acf404/build-script-main` (exit status: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=X86_64_APPLE_DARWIN_OPENSSL_LIB_DIR
X86_64_APPLE_DARWIN_OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=X86_64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR
X86_64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=X86_64_APPLE_DARWIN_OPENSSL_DIR
X86_64_APPLE_DARWIN_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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
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_PATH_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=SYSROOT
cargo:rerun-if-env-changed=OPENSSL_STATIC
cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rustc-link-lib=ssl
cargo:rustc-link-lib=dl
cargo:rustc-link-lib=crypto
cargo:rustc-link-lib=dl
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
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_PATH_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-changed=build/expando.c
OPT_LEVEL = Some("3")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c"
cargo:warning=cc: error: x86_64: No such file or directory
cargo:warning=cc: error: unrecognized command-line option '-arch'
exit status: 1

--- stderr
thread 'main' panicked at '
Header expansion error:
Error { kind: ToolExecError, message: "Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c" with args "cc" did not execute successfully (status code exit status: 1)." }

Failed to find OpenSSL development headers.

You can try fixing this setting the OPENSSL_DIR environment variable
pointing to your OpenSSL installation or installing OpenSSL headers package
specific to your distribution:

  # On Ubuntu
  sudo apt-get install libssl-dev
  # On Arch Linux
  sudo pacman -S openssl
  # On Fedora
  sudo dnf install openssl-devel
  # On Alpine Linux
  apk add openssl-dev

See rust-openssl README for more information:

  https://github.com/sfackler/rust-openssl#linux

', /.cargo/config/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.75/build/main.rs:173:13
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:

�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: x86_64: No such file or directory
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: unrecognized command-line option '-arch'
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: x86_64: No such file or directory
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: unrecognized command-line option '-arch'

�[0m�[0m�[1m�[31merror�[0m�[1m:�[0m failed to run custom build command for zstd-sys v1.6.3+zstd.1.5.2

Caused by:
process didn't exit successfully: /app/target/release/build/zstd-sys-2c8dc93e5e58689c/build-script-build (exit status: 1)
--- stdout
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/app/target/x86_64-apple-darwin/release/build/zstd-sys-f44111bc4bb7bc85/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c"
cargo:warning=cc: error: x86_64: No such file or directory
cargo:warning=cc: error: unrecognized command-line option '-arch'
exit status: 1
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/app/target/x86_64-apple-darwin/release/build/zstd-sys-f44111bc4bb7bc85/out/zstd/lib/common/pool.o" "-c" "zstd/lib/common/pool.c"
cargo:warning=cc: error: x86_64: No such file or directory
cargo:warning=cc: error: unrecognized command-line option '-arch'
exit status: 1

--- stderr

error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/app/target/x86_64-apple-darwin/release/build/zstd-sys-f44111bc4bb7bc85/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c" with args "cc" did not execute successfully (status code exit status: 1).

The following warnings were emitted during compilation:

�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: x86_64: No such file or directory
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: unrecognized command-line option '-arch'
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: x86_64: No such file or directory
�[0m�[0m�[1m�[33mwarning�[0m�[1m:�[0m cc: error: unrecognized command-line option '-arch'

�[0m�[0m�[1m�[31merror�[0m�[1m:�[0m failed to run custom build command for bzip2-sys v0.1.11+1.0.8

Caused by:
process didn't exit successfully: /app/target/release/build/bzip2-sys-235dbcf39348906b/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=BZIP2_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=BZIP2_STATIC
cargo:rerun-if-env-changed=BZIP2_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
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_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "bzip2-1.0.8" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/app/target/x86_64-apple-darwin/release/build/bzip2-sys-a6f1e00fddd3b885/out/lib/bzip2-1.0.8/blocksort.o" "-c" "bzip2-1.0.8/blocksort.c"
cargo:warning=cc: error: x86_64: No such file or directory
cargo:warning=cc: error: unrecognized command-line option '-arch'
exit status: 1
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "bzip2-1.0.8" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/app/target/x86_64-apple-darwin/release/build/bzip2-sys-a6f1e00fddd3b885/out/lib/bzip2-1.0.8/huffman.o" "-c" "bzip2-1.0.8/huffman.c"
cargo:warning=cc: error: x86_64: No such file or directory
cargo:warning=cc: error: unrecognized command-line option '-arch'
exit status: 1

--- stderr

error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "bzip2-1.0.8" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/app/target/x86_64-apple-darwin/release/build/bzip2-sys-a6f1e00fddd3b885/out/lib/bzip2-1.0.8/blocksort.o" "-c" "bzip2-1.0.8/blocksort.c" with args "cc" did not execute successfully (status code exit status: 1).

`

Can someone help me with this issue or let me know what I'm doing wrong?

My Dockerfile
FROM joseluisq/rust-linux-darwin-builder:1.63.0 WORKDIR /app ENV CARGO_HOME="${HOME}/.cargo/config" COPY . . CMD ["cargo", "build", "--release", "--target", "x86_64-apple-darwin"]

I also tried the docker run command that is in the readme but that too gave me the same error.

Unable to build project depending on ring v0.16.20

Hello,

When trying to build a project depending on ring v0.16.20 using this image I get the following error:

   Compiling unicode-normalization v0.1.19
   Compiling pest_meta v2.1.3
error: failed to run custom build command for `ring v0.16.20`
Caused by:
  process didn't exit successfully: `/builds/data-ingestion/legacy-feed-migration-cli/target/release/build/ring-c841cf9ea95b2f18/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-apple-darwin")
  HOST = Some("x86_64-unknown-linux-musl")
  CC_x86_64-apple-darwin = None
  CC_x86_64_apple_darwin = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_x86_64-apple-darwin = None
  CFLAGS_x86_64_apple_darwin = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
  --- stderr
  running "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-gfull" "-DNDEBUG" "-c" "-o/builds/data-ingestion/legacy-feed-migration-cli/target/x86_64-apple-darwin/release/build/ring-06af2bf6acdc998b/out/aesni-x86_64-macosx.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-macosx.S"
  cc: error: x86_64: No such file or directory
  cc: error: unrecognized debug output level 'full'
  cc: error: unrecognized command-line option '-arch'
  thread 'main' panicked at 'execution failed', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:656:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

I am using this via cross-rs inside gitlab ci the following way:

#cross.toml
[target.x86_64-apple-darwin]
image = "joseluisq/rust-linux-darwin-builder:1.60.0"

#.gitlab.ci.yml
cross build --release --target x86_64-apple-darwin

Perhaps the error is related to this issue or I'm using the image wrong (I'm not too familiar with darwin builds)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.