Git Product home page Git Product logo

cross-toolchains's People

Contributors

0xdeafbeef avatar alexhuszagh avatar benjaminschaaf avatar cavivie avatar emilgardis avatar lschmelzeisen avatar wilfred avatar wmmc88 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cross-toolchains's Issues

Rust now requires MacOS > 10.12

See
https://blog.rust-lang.org/2023/09/25/Increasing-Apple-Version-Requirements.html

This:

TARGET_DIR=/opt/osxcross UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh

needs to be upped to 10.12 in at least some targets, otherwise error looking like this:

          ld: warning: object file (/target/x86_64-apple-darwin/release/deps/libidna-9e0bb8c28bf4f03d.rlib(idna-9e0bb8c28bf4f03d.idna.3875f9ff72356008-cgu.7.rcgu.o)) was built for newer macOS version (10.12) than being linked (10.7)
          Undefined symbols for architecture x86_64:
            "_clock_gettime", referenced from:
                std::sys::unix::time::Timespec::now::h0ebd2e38935918ca in libstd-4b3c9502f998a9c9.rlib(std-4b3c9502f998a9c9.std.ccb858c55971878c-cgu.0.rcgu.o)
            "_getentropy", referenced from:
                std::sys::unix::rand::hashmap_random_keys::ha92d0a2687c22b7a in libstd-4b3c9502f998a9c9.rlib(std-4b3c9502f998a9c9.std.ccb858c55971878c-cgu.0.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)

would be happening (this is from build for x86_64).

Simply upping the value to 10.12 would be more strict than what Rust seems to require now though.
There was no issue for me on aarch64-apple-darwin, and that is in alignment with blog post linked above, as that target is not mentioned as affected by change (aarch64-apple-ios is mentioned, but not darwin).

x86_64-apple-darwin-cross manifest unknown

Checklist

Describe your issue

I'm seeing this when I try to build the darwin image:

$ cargo build-docker-image x86_64-apple-darwin-cross --build-arg='MACOS_SDK_DIR=MacOSX-SDKs' --build-arg 'MACOS_SDK_FILE=MacOSX11.3.sdk.tar.xz' --tag local
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/xtask build-docker-image x86_64-apple-darwin-cross --build-arg=MACOS_SDK_DIR=MacOSX-SDKs --build-arg MACOS_SDK_FILE=MacOSX11.3.sdk.tar.xz --tag local`
[cross] note: Build x86_64-apple-darwin-cross for x86_64-unknown-linux-gnu
[+] Building 2.9s (14/19)                                                                                                                                                                                                                           docker-container:xenodochial_wilson
 => [internal] load build definition from Dockerfile.x86_64-apple-darwin-cross                                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 1.17kB                                                                                                                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                                                                    0.3s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                  0.0s
 => => transferring context: 223B                                                                                                                                                                                                                                                  0.0s
 => ERROR importing cache manifest from ghcr.io/cross-rs/x86_64-apple-darwin-cross:main                                                                                                                                                                                            0.6s
 => [internal] load build context                                                                                                                                                                                                                                                  1.8s
 => => transferring context: 365B                                                                                                                                                                                                                                                  1.8s
 => [ 1/13] FROM docker.io/library/ubuntu:20.04@sha256:f2034e7195f61334e6caff6ecf2e965f92d11e888309065da85ff50c617732b8                                                                                                                                                            0.0s
 => => resolve docker.io/library/ubuntu:20.04@sha256:f2034e7195f61334e6caff6ecf2e965f92d11e888309065da85ff50c617732b8                                                                                                                                                              0.0s
 => [auth] cross-rs/x86_64-apple-darwin-cross:pull token for ghcr.io                                                                                                                                                                                                               0.0s
 => CACHED [ 2/13] COPY common.sh lib.sh /                                                                                                                                                                                                                                         0.0s
 => CACHED [ 3/13] RUN /common.sh                                                                                                                                                                                                                                                  0.0s
 => CACHED [ 4/13] COPY cmake.sh /                                                                                                                                                                                                                                                 0.0s
 => CACHED [ 5/13] RUN /cmake.sh                                                                                                                                                                                                                                                   0.0s
 => CACHED [ 6/13] COPY xargo.sh /                                                                                                                                                                                                                                                 0.0s
 => CACHED [ 7/13] RUN /xargo.sh                                                                                                                                                                                                                                                   0.0s
 => ERROR [ 8/13] COPY MacOSX-SDKs/MacOSX11.3.sdk.tar.xz* /                                                                                                                                                                                                                        0.0s
------
 > importing cache manifest from ghcr.io/cross-rs/x86_64-apple-darwin-cross:main:
------
------
 > [ 8/13] COPY MacOSX-SDKs/MacOSX11.3.sdk.tar.xz* /:
------
Dockerfile.x86_64-apple-darwin-cross:21
--------------------
  19 |     ARG MACOS_SDK_URL
  20 |     # wildcard workaround so we can copy the file only if it exists
  21 | >>> COPY $MACOS_SDK_DIR/$MACOS_SDK_FILE* /
  22 |     COPY cross-toolchains/docker/darwin.sh /
  23 |     RUN /darwin.sh
--------------------
ERROR: failed to solve: lstat /tmp/buildkit-mount2628248203/MacOSX-SDKs: no such file or directory
Error: 
   0: `docker buildx build --platform linux/amd64 --build-arg 'CROSS_TARGET_TRIPLE=X86_64_APPLE_DARWIN_CROSS' --load --pull --cache-from 'type=registry,ref=ghcr.io/cross-rs/x86_64-apple-darwin-cross:main' --tag ghcr.io/cross-rs/x86_64-apple-darwin-cross:local --label 'org.cross-rs.for-cross-target=x86_64-apple-darwin-cross' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' --file /home/fr3ncht0ast/cross/docker/cross-toolchains/docker/Dockerfile.x86_64-apple-darwin-cross --progress auto --build-arg 'MACOS_SDK_DIR=MacOSX-SDKs' --build-arg 'MACOS_SDK_FILE=MacOSX11.3.sdk.tar.xz' .` failed with exit status: 1

Location:
   xtask/src/build_docker_image.rs:309

Warning: call to docker failed
Suggestion: is `buildx` available for the container engine?
Note: disable the `buildkit` dependency optionally with `CROSS_CONTAINER_ENGINE_NO_BUILDKIT=1`

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

I was surprised to see ERROR importing cache manifest from ghcr.io/cross-rs/x86_64-apple-darwin-cross:main and then attempted to check the manifest to see what the issue was:

$ docker manifest inspect ghcr.io/cross-rs/x86_64-apple-darwin-cross
manifest unknown

I believe I will be unable to build the docker image with the requisite SDKs and am unsure how I could proceed.

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

other (specify in description)

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.5 (ade8dbe 2024-01-02)

Example

$ docker login
Authenticating with existing credentials...
Login Succeeded
$ echo "###" | docker login ghcr.io -u "####" --password-stdin
Login Succeeded
$ git clone https://github.com/cross-rs/cross
$ cd cross
$ git submodule update --init --remote
  grabbed the SDK dir and file, downloaded to: 
   ./docker/cross-toolchains/docker/MacOSX-SDKs and 
   ./docker/cross-toolchains/docker/MacOSX11.3.sdk.tar.xz
$ MACOS_SDK_DIR=MacOSX-SDKs
$ MACOS_SDK_FILE=MacOSX11.3.sdk.tar.xz
$ cargo build-docker-image x86_64-apple-darwin-cross \
   --build-arg 'MACOS_SDK_DIR=$DIR' \
   --build-arg 'MACOS_SDK_FILE=$FILE'  \
   --tag local

Additional information / notes

I'm not 100% certain that this isn't still my fault somehow.

Add Support for Strawberry Perl

Currently, some complex builds (like OpenSSL) for the MSVC toolchains fail because the default perl does not output Windows paths. Installing and setting Strawberry Perl to be the default perl fixes this.

Request: Support for binary stripping

When I enable binary stripping in a Cargo.toml release profile, then the cross build emits a warning about how it doesn't know how to strip symbols. Presumably because the binary is targeting a different operating system than the container guest operating system.

Perhaps we need the Docker images to install an additional tool for this?

libatomic.a included in arm-unknown-linux-gnueabihf:0.2.5 contains armv7 instructions

Hello.

When cross compiling for a 2011 Raspberry Pi 1 (armv6) using docker, if the program includes libatomic.a then when the program is run on the target architecture it outputs "Illegal Instructions" and stops.

Looking through the past issues, there are a number that have similar symptoms, but in this case the root cause seems to be this library. Only libatomic.a and libatomic.so seem to include armv7 instructions. My work-around is to replace libatomic.a from the Raspberry Pi distribution: https://downloads.raspberrypi.org/raspios_lite_armhf/root.tar.xz

Perhaps, the docker file could include a check of the sysroot contents.

$ docker run --rm -it ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:0.2.5 bash
root@e1eb3b13927c:/# readelf -A /x-tools/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/lib/libatomic.a | grep 'Tag_CPU_arch: v7' | head -1
  Tag_CPU_arch: v7
root@e1eb3b13927c:/# readelf -A /x-tools/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/lib/libatomic.so | grep 'Tag_CPU_arch: v7' | head -1
  Tag_CPU_arch: v7

Failed to build for apple darwin targets jemalloc-sys

Try to build jemalloc-sys (0.5.4, 0.3.2), always get a ld linker error:

/usr/bin/ld: unrecognized option '-dynamic'

Follow issues:

Make sure /usr/local/osxcross/bin is in PATH.

Our cross image already sets osxcross path (/opt/osxcross/bin) in PATH.

Furthermore, we can find that the tools generated under the osxcross bin path all have the darwin version suffix (such as x86_64-apple-darwin20.04-clang), which will cause clang to be unable to find the correct ld (x86_64-apple-darwin-clang) when linking, and fallback to the default ld (/usr/bin/ld).
Why generated targets with darwin version suffix, becasue osxcross build.sh does that by default:

How to solve these problems:
First we need to remove the darwin version suffix from the tool chain of the compiled target to make some cctools work correctly, so the most intuitive way we use is to generate new cctool symlinks without darwin version for cctools.
Then we need put symlink in bin path such /usr/bin, if we won't do that, we need to ensure that osxcross bin path takes precedence over other bin path which containing ld searches. Since cross put the osxcross bin path at the end of PATH, we can put symlinks in /usr/bin, which will not conflict with other bin toolchains. Fixed by:

# file darwin.sh
create_arch_symlinks()
{
  local arch=$1 # support target arch
  local src_path=$2 # cctools bin source path
  local dst_path=$3 # cctools bin destination path
  local cctools=($(find $src_path -name "$arch-apple-darwin*-*"))
  local src_cctool
  local dst_cctool
  for src_cctool in ${cctools[@]}; do
    dst_cctool=$(echo "$src_cctool" | sed "s/$src_path/$dst_path/g")
    dst_cctool=$(echo "$dst_cctool" | sed -E "s/-darwin(.*)-/-darwin-/g")
    ln -sf $src_cctool $dst_cctool
  done
}

main() {
    local target_cpu="${1}"
    ...
    
    create_arch_symlinks $target_cpu /opt/osxcross/bin /usr/bin

    purge_packages
    ...
}
# file darwin-entry.sh
...
# should use first ar when existing mutilpe ar bins (head -n 1)
version=$(echo "${tools}" | grep 'ar$' | head -n 1 |  sed 's/'"${CROSS_TARGET}"'//' | sed 's/-ar//')
...
# file such as Docker.aarch64-apple-darwin-cross
...
ARG TARGET_CPU=aarch64
...
RUN /darwin.sh $TARGET_CPU
...

Add riscv64gc-unknown-linux-musl support

Checklist

Describe your request

rustup target add riscv64gc-unknown-linux-musl

error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rust-std' for target 'riscv64gc-unknown-linux-musl'

How to build 'rust-std' for target 'riscv64gc-unknown-linux-musl'?

Describe why this would be a good inclusion for cross

more Risc-V linux enabled SoC.

Unable to build docker image: invalid flag is passed to docker

Shell output:

$ sudo cargo build-docker-image x86_64-pc-windows-msvc-cross --tag local
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/xtask build-docker-image x86_64-pc-windows-msvc-cross --tag local`
[cross] note: Build x86_64-pc-windows-msvc-cross for x86_64-unknown-linux-gnu
unknown flag: --platform
See 'docker --help'.

Usage:  docker [OPTIONS] COMMAND

[Docker help page follows]

Docker version (most recent stable at the time of making this issue):

Client:
 Version:           20.10.19
 API version:       1.41
 Go version:        go1.19.2
 Git commit:        d85ef84533
 Built:             Sat Oct 15 20:20:02 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Rust version (most recent stable at the time of making this issue):

stable-x86_64-unknown-linux-gnu (default) @ rustc 1.64.0 (a55dd71d5 2022-09-19)

Error:
0: docker buildx build --platform linux/amd64 --build-arg 'CROSS_TARGET_TRIPLE=X86_64_PC_WINDOWS_MSVC_CROSS' --load --pull --cache-from 'type=registry,ref=ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:main' --tag ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local --label 'org.cross-rs.for-cross-target=x86_64-pc-windows-msvc-cross' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' -f /run/media/tudbut/a5187034-7bde-48cd-b51f-9957d531c89a/cross/docker/cross-toolchains/docker/Dockerfile.x86_64-pc-windows-msvc-cross --progress auto . failed with exit status: 125

build-docker-image aarch64-apple-darwin-cross fails with illegal instruction on M2

building on an mbp M2 (aarch64)

% cargo build-docker-image aarch64-apple-darwin-cross --build-arg 'MACOS_SDK_FILE=MacOSX11.1.sdk.tar.xz'
...
402.5 clang++ -DPACKAGE_NAME="cctools" -DPACKAGE_TARNAME="cctools" -DPACKAGE_VERSION="973.0.1" -DPACKAGE_STRING="cctools\ 973.0.1" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DEMULATED_HOST_CPU_TYPE=16777223 -DEMULATED_HOST_CPU_SUBTYPE=3 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_EXECINFO_H=1 -DHAVE_UTIMENSAT=1 -DHAVE_BCOPY=1 -DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1 -DHAVE_STAT_ST_MTIM=1 -DHAVE_CLOCK_GETTIME=1 -I. -isystem /opt/osxcross/include -D__DARWIN_UNIX03 -Wall -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value -Wno-misleading-indentation -Wno-gnu-folding-constant -DTAPI_SUPPORT -D__LITTLE_ENDIAN__=1 -I../../../include -I../../../include/foreign -I../../../ld64/src -I../../../ld64/src/abstraction -I../../../ld64/src/3rd -I../../../ld64/src/3rd/BlocksRuntime -I../../../ld64/src/3rd/include -I../../../ld64/src/ld -I../../../ld64/src/ld/parsers -I../../../ld64/src/ld/passes -DPROGRAM_PREFIX=""x86_64-apple-darwin20.2-"" -O3 -std=c++1z -isystem /usr/local/include -isystem /usr/pkg/include -DLD64_VERSION_NUM=609 -fblocks -isystem /opt/osxcross/include -c -o ld-SymbolTable.o test -f 'SymbolTable.cpp' || echo './'SymbolTable.cpp
...
402.6 make[4]: *** [Makefile:632: ld-SymbolTable.o] Illegal instruction
402.6 make[4]: *** Waiting for unfinished jobs....
418.8 make[4]: Leaving directory '/tmp/tmp.GHpTQdYf0G/osxcross/build/cctools-port/cctools/ld64/src/ld'
418.8 make[3]: *** [Makefile:668: all-recursive] Error 1
418.8 make[3]: Leaving directory '/tmp/tmp.GHpTQdYf0G/osxcross/build/cctools-port/cctools/ld64/src/ld'
418.8 make[2]: *** [Makefile:385: all-recursive] Error 1
418.8 make[2]: Leaving directory '/tmp/tmp.GHpTQdYf0G/osxcross/build/cctools-port/cctools/ld64/src'
418.8 make[1]: *** [Makefile:386: all-recursive] Error 1
418.8 make[1]: Leaving directory '/tmp/tmp.GHpTQdYf0G/osxcross/build/cctools-port/cctools/ld64'
418.8 make: *** [Makefile:421: all-recursive] Error 1
418.8
418.8 exiting with abnormal exit code (2)
418.8 run 'OCDEBUG=1 ./build.sh' to enable debug messages

NetBSD support

Hi,

I appreciate the value of the cross-toolchains project. This really helps me develop more cross-platform apps!

Can we please get targets for more of the BSD variants? For example, the Rust compiler provides targets for NetBSD of various architectures.

Provision more target triples

Some of the available target triples in rustup target list lack corresponding entries in cross-toolchains. Can we get more of these targets going for cross?

Issue configuring the glibc version

I'd like to create a custom x86_64 image with a specific version of glibc, 2.26. I'm running this command, following these steps from the readme:

cargo xtask configure-crosstool x86_64-unknown-linux-gnu --glibc-version 2.26

And I get this error:

unable to find config for target "x86_64-unknown-linux-gnu"

I understand that this is happening because there is no file named x86_64-unknown-linux-gnu.config.in in the docker/cross-toolchains/crosstool-ng directory. How do I create one? is there a template that I can use? I've looked at the two files that already exist, but I don't think I can just copy them given that they are for different architectures.

Where is `cargo build-docker-image`?

In several of the examples, commands beginning with cargo build-docker-image are run. Where can this cargo tool build-docker-image be found? I've googled up a couple of close-named relatives, but not this specific one.

Add bors and minimal CI

We only ensure these images build and pass the test suite once, however, it would be nice to add bors support and ensure any modified Dockerfiles that don't require proprietary SDKS are tested in the CI process. This would also involve adding a targets.toml to ensure we document C++, runner, std, and more support.

OpenSSL not working with cross-installed Perl version

When I attempt to build dfinity/sdk for Windows using x86_64-pc-windows-msvc-cross:local, I get

running "perl" "./Configure" "--prefix=/target/debug/build/openssl-sys-e1e37cc94a2d53ef/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64"
  Configuring OpenSSL version 1.1.1q (0x1010111fL) for linux-x86_64
  Using os-specific seed configuration

  --- stderr

  ******************************************************************************
  This perl implementation doesn't produce Unix like paths (with forward slash
  directory separators).  Please use an implementation that matches your
  building platform.

  This Perl version: 5.32.1 for MSWin32-x64-multi-thread
  ******************************************************************************
  thread 'main' panicked at '


  Error configuring OpenSSL build:
      Command: "perl" "./Configure" "--prefix=/target/debug/build/openssl-sys-e1e37cc94a2d53ef/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64"
      Exit status: exit status: 255

This appears to be the correct version of Perl, but OpenSSL is still not detecting it.

(Is this even a problem with cross-toolchains? Should I post this on the OpenSSL repo instead?)

Support more uclibc Targets

The PR in #16 adds support for a uclibc target, however, there are numerous other supported uclibc targets, including:

  • armv5te-unknown-linux-uclibceabi
  • armv7-unknown-linux-uclibceabi
  • armv7-unknown-linux-uclibceabihf
  • mips-unknown-linux-uclibc

It shouldn't be too hard to support mips-unknown-linux-uclibc, and the ARM targets might only require a little extra work. Tracking for the status can be found here.

Update: The ARM targets are currently having significant issues due to configuration differences. I'm assuming it's using SOFTFP versus SOFTW, but I'm unsure.

aarch64-apple-ios image build failed due to libdispatch/libblocksruntime

The error log:

...
271.5 checking for __cxa_demangle in -lc++abi... no
271.6 checking for __cxa_demangle in -lc++... no
271.6 checking for __cxa_demangle in -lsupc++... yes
271.7 checking for __gcc_personality_v0 in -lgcc... yes
271.8 checking whether clang supports -Wno-shift-negative-value... yes
271.8 checking whether clang supports -Wno-misleading-indentation... yes
271.8 checking whether clang supports -Wno-gnu-folding-constant... yes
271.9 checking whether clang supports -Wno-unused-but-set-variable... no
271.9 checking whether clang supports -Wno-deprecated-non-prototype... no
271.9 checking whether ld supports -rpath,<path>,--enable-new-dtags... yes
272.0 checking for llvm-config... /usr/bin/llvm-config
272.0 checking for lto_get_version in -lLTO... yes
272.3 checking for _Block_release in -lBlocksRuntime... no
272.4 checking for _Block_release in -lc... no
272.4 Required library libblocksruntime not installed (install libdispatch!)
------
Dockerfile.aarch64-apple-ios-cross:26
--------------------
  24 |     COPY cross-toolchains/docker/ios.sh /
  25 |     COPY cross-toolchains/docker/ios-wrapper.c /
  26 | >>> RUN /ios.sh $CROSS_TARGET $TARGET_CPU
  27 |
  28 |     COPY cross-toolchains/docker/ios-symlink.sh /
--------------------
ERROR: failed to solve: process "/bin/sh -c /ios.sh $CROSS_TARGET $TARGET_CPU" did not complete successfully: exit code: 1
Error:
   0: `docker buildx build --platform linux/amd64 --build-arg 'CROSS_TARGET_TRIPLE=AARCH64_APPLE_IOS_CROSS' --load --pull --cache-from 'type=registry,ref=.../cross-rs/aarch64-apple-ios-cross:main' --tag .../cross-rs/aarch64-apple-ios-cross:latest --label 'org.cross-rs.for-cross-target=aarch64-apple-ios-cross' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' --file .../cross-rs/docker/cross-toolchains/docker/Dockerfile.aarch64-apple-ios-cross --progress auto --build-arg 'IOS_SDK_DIR=/ios-sdks' --build-arg 'IOS_SDK_FILE=iPhoneOS16.2.sdk.tar.xz' .` failed with exit status: 1

Location:
   /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/convert/mod.rs:716

Warning: call to docker failed
Suggestion: is `buildx` available for the container engine?
Note: disable the `buildkit` dependency optionally with `CROSS_CONTAINER_ENGINE_NO_BUILDKIT=1`

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Next, try to replace libdispatch0 with libdispatch-dev, but still fails, and the error log will be:

264.2 libtool: compile:  clang++ -DPACKAGE_NAME=\"cctools\" -DPACKAGE_TARNAME=\"cctools\" -DPACKAGE_VERSION=\"1009.2\" "-DPACKAGE_STRING=\"cctools 1009.2\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DEMULATED_HOST_CPU_TYPE=16777228 -DEMULATED_HOST_CPU_SUBTYPE=0 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_EXECINFO_H=1 -DHAVE_UUID_UUID_H=1 -DHAVE_UTIMENSAT=1 -DHAVE_BCOPY=1 -DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1 -DHAVE_STAT_ST_MTIM=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_DISPATCH_DISPATCH_H=1 -I. -isystem /opt/cctools/include -D__DARWIN_UNIX03 -Wall -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value -Wno-misleading-indentation -Wno-gnu-folding-constant -DLTO_SUPPORT -DTAPI_SUPPORT -D__LITTLE_ENDIAN__=1 -I../../../include -I../../../include/foreign -I../../../ld64/src -I../../../ld64/src/abstraction -I../../../ld64/src/3rd -I../../../ld64/src/3rd/include -I../../../ld64/src/ld -I../../../ld64/src/ld/parsers -I../../../ld64/src/ld/passes -I../../../ld64/src/mach_o -DPROGRAM_PREFIX=\"aarch64-apple-ios-\" -O3 -std=c++2a -isystem /usr/local/include -isystem /usr/pkg/include -DLD64_VERSION_NUM=907 -fblocks -isystem /opt/cctools/include -c Error.cpp  -fPIC -DPIC -o .libs/libmacho_la-Error.o
264.2 libtool: compile:  clang++ -DPACKAGE_NAME=\"cctools\" -DPACKAGE_TARNAME=\"cctools\" -DPACKAGE_VERSION=\"1009.2\" "-DPACKAGE_STRING=\"cctools 1009.2\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DEMULATED_HOST_CPU_TYPE=16777228 -DEMULATED_HOST_CPU_SUBTYPE=0 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_EXECINFO_H=1 -DHAVE_UUID_UUID_H=1 -DHAVE_UTIMENSAT=1 -DHAVE_BCOPY=1 -DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1 -DHAVE_STAT_ST_MTIM=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_DISPATCH_DISPATCH_H=1 -I. -isystem /opt/cctools/include -D__DARWIN_UNIX03 -Wall -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value -Wno-misleading-indentation -Wno-gnu-folding-constant -DLTO_SUPPORT -DTAPI_SUPPORT -D__LITTLE_ENDIAN__=1 -I../../../include -I../../../include/foreign -I../../../ld64/src -I../../../ld64/src/abstraction -I../../../ld64/src/3rd -I../../../ld64/src/3rd/include -I../../../ld64/src/ld -I../../../ld64/src/ld/parsers -I../../../ld64/src/ld/passes -I../../../ld64/src/mach_o -DPROGRAM_PREFIX=\"aarch64-apple-ios-\" -O3 -std=c++2a -isystem /usr/local/include -isystem /usr/pkg/include -DLD64_VERSION_NUM=907 -fblocks -isystem /opt/cctools/include -c ExportsTrie.cpp  -fPIC -DPIC -o .libs/libmacho_la-ExportsTrie.o
264.3 In file included from ExportsTrie.cpp:31:
264.3 ./ExportsTrie.h:29:10: fatal error: 'span' file not found
264.3 #include <span>
264.3          ^~~~~~
264.4 1 error generated.
264.4 make[4]: *** [Makefile:464: libmacho_la-ExportsTrie.lo] Error 1
264.4 make[4]: Leaving directory '/tmp/tmp.geoD45gBZz/cctools-port/cctools/ld64/src/mach_o'
264.4 make[3]: *** [Makefile:479: all-recursive] Error 1
264.4 make[3]: Leaving directory '/tmp/tmp.geoD45gBZz/cctools-port/cctools/ld64/src/mach_o'
264.4 make[2]: *** [Makefile:384: all-recursive] Error 1
264.4 make[2]: Leaving directory '/tmp/tmp.geoD45gBZz/cctools-port/cctools/ld64/src'
264.4 make[1]: Leaving directory '/tmp/tmp.geoD45gBZz/cctools-port/cctools/ld64'
264.4 make[1]: *** [Makefile:385: all-recursive] Error 1
264.4 make: *** [Makefile:417: all-recursive] Error 1
------
Dockerfile.aarch64-apple-ios-cross:26
--------------------
  24 |     COPY cross-toolchains/docker/ios.sh /
  25 |     COPY cross-toolchains/docker/ios-wrapper.c /
  26 | >>> RUN /ios.sh $CROSS_TARGET $TARGET_CPU
  27 |
  28 |     COPY cross-toolchains/docker/ios-symlink.sh /
--------------------
ERROR: failed to solve: process "/bin/sh -c /ios.sh $CROSS_TARGET $TARGET_CPU" did not complete successfully: exit code: 2

Next, try to install libstdc++-10-dev, but still fails, and the error log will be:

277.7 libtool: compile:  clang++ -DPACKAGE_NAME=\"cctools\" -DPACKAGE_TARNAME=\"cctools\" -DPACKAGE_VERSION=\"1009.2\" "-DPACKAGE_STRING=\"cctools 1009.2\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DEMULATED_HOST_CPU_TYPE=16777228 -DEMULATED_HOST_CPU_SUBTYPE=0 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_EXECINFO_H=1 -DHAVE_UUID_UUID_H=1 -DHAVE_UTIMENSAT=1 -DHAVE_BCOPY=1 -DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1 -DHAVE_STAT_ST_MTIM=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_DISPATCH_DISPATCH_H=1 -I. -isystem /opt/cctools/include -D__DARWIN_UNIX03 -Wall -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value -Wno-misleading-indentation -Wno-gnu-folding-constant -DLTO_SUPPORT -D__LITTLE_ENDIAN__=1 -I../../../../include -I../../../../include/foreign -I../../../../ld64/src/abstraction -I../../../../ld64/src/ld -I../../../../ld64/src/ld/parsers -I../../../../ld64/src/3rd -I../../../../ld64/src -O3 -std=c++2a -isystem /usr/local/include -isystem /usr/pkg/include -DLD64_VERSION_NUM=907 -fblocks -isystem /opt/cctools/include -c huge.cpp  -fPIC -DPIC -o .libs/libPasses_la-huge.o
279.4 order.cpp:658:41: error: use of undeclared identifier 'DISPATCH_APPLY_AUTO'
279.4         dispatch_apply(_state.sections.size(), DISPATCH_APPLY_AUTO, ^(size_t index) {
279.4                                                ^
279.5 code_dedup.cpp:349:43: error: use of undeclared identifier 'DISPATCH_APPLY_AUTO'
279.5     dispatch_apply(state.sections.size(), DISPATCH_APPLY_AUTO, ^(size_t index) {
279.5                                           ^
279.7 1 error generated.
279.7 make[4]: *** [Makefile:479: libPasses_la-order.lo] Error 1
279.7 make[4]: *** Waiting for unfinished jobs....
279.8 1 error generated.
279.8 make[4]: *** [Makefile:491: libPasses_la-code_dedup.lo] Error 1
293.9 make[4]: Leaving directory '/tmp/tmp.anxFM5V5pn/cctools-port/cctools/ld64/src/ld/passes'
293.9 make[3]: *** [Makefile:682: all-recursive] Error 1
293.9 make[3]: Leaving directory '/tmp/tmp.anxFM5V5pn/cctools-port/cctools/ld64/src/ld'
293.9 make[2]: *** [Makefile:384: all-recursive] Error 1
293.9 make[2]: Leaving directory '/tmp/tmp.anxFM5V5pn/cctools-port/cctools/ld64/src'
293.9 make[1]: *** [Makefile:385: all-recursive] Error 1
293.9 make[1]: Leaving directory '/tmp/tmp.anxFM5V5pn/cctools-port/cctools/ld64'
293.9 make: *** [Makefile:417: all-recursive] Error 1
------
Dockerfile.aarch64-apple-ios-cross:26
--------------------
  24 |     COPY cross-toolchains/docker/ios.sh /
  25 |     COPY cross-toolchains/docker/ios-wrapper.c /
  26 | >>> RUN /ios.sh $CROSS_TARGET $TARGET_CPU
  27 |
  28 |     COPY cross-toolchains/docker/ios-symlink.sh /
--------------------
ERROR: failed to solve: process "/bin/sh -c /ios.sh $CROSS_TARGET $TARGET_CPU" did not complete successfully: exit code: 2

Next, try to use latest cctools-port(1009.2-ld64-907 - a98286d8), but still fails, and the error log will be:

286.9 libtool: compile:  clang++ -DPACKAGE_NAME=\"cctools\" -DPACKAGE_TARNAME=\"cctools\" -DPACKAGE_VERSION=\"1009.2\" "-DPACKAGE_STRING=\"cctools 1009.2\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DEMULATED_HOST_CPU_TYPE=16777228 -DEMULATED_HOST_CPU_SUBTYPE=0 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_EXECINFO_H=1 -DHAVE_UUID_UUID_H=1 -DHAVE_UTIMENSAT=1 -DHAVE_BCOPY=1 -DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1 -DHAVE_STAT_ST_MTIM=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_DISPATCH_DISPATCH_H=1 -I. -isystem /opt/cctools/include -D__DARWIN_UNIX03 -Wall -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value -Wno-misleading-indentation -Wno-gnu-folding-constant -DLTO_SUPPORT -D__LITTLE_ENDIAN__=1 -I../../../../include -I../../../../include/foreign -I../../../../ld64/src/abstraction -I../../../../ld64/src/ld -I../../../../ld64/src/ld/parsers -I../../../../ld64/src/3rd -I../../../../ld64/src -O3 -std=c++2a -isystem /usr/local/include -isystem /usr/pkg/include -DLD64_VERSION_NUM=907 -fblocks -isystem /opt/cctools/include -c objc.cpp  -fPIC -DPIC -o .libs/libPasses_la-objc.o
288.4 order.cpp:658:41: error: use of undeclared identifier 'DISPATCH_APPLY_AUTO'
288.4         dispatch_apply(_state.sections.size(), DISPATCH_APPLY_AUTO, ^(size_t index) {
288.4                                                ^
288.5 code_dedup.cpp:349:43: error: use of undeclared identifier 'DISPATCH_APPLY_AUTO'
288.5     dispatch_apply(state.sections.size(), DISPATCH_APPLY_AUTO, ^(size_t index) {
288.5                                           ^
288.7 1 error generated.
288.7 make[4]: *** [Makefile:479: libPasses_la-order.lo] Error 1
288.7 make[4]: *** Waiting for unfinished jobs....
288.8 1 error generated.
288.8 make[4]: *** [Makefile:491: libPasses_la-code_dedup.lo] Error 1
302.5 make[4]: Leaving directory '/tmp/tmp.6eXNtxF8lL/cctools-port/cctools/ld64/src/ld/passes'
302.5 make[3]: Leaving directory '/tmp/tmp.6eXNtxF8lL/cctools-port/cctools/ld64/src/ld'
302.5 make[3]: *** [Makefile:682: all-recursive] Error 1
302.5 make[2]: *** [Makefile:384: all-recursive] Error 1
302.5 make[2]: Leaving directory '/tmp/tmp.6eXNtxF8lL/cctools-port/cctools/ld64/src'
302.5 make[1]: *** [Makefile:385: all-recursive] Error 1
302.5 make[1]: Leaving directory '/tmp/tmp.6eXNtxF8lL/cctools-port/cctools/ld64'
302.5 make: *** [Makefile:417: all-recursive] Error 1
------
Dockerfile.aarch64-apple-ios-cross:26
--------------------
  24 |     COPY cross-toolchains/docker/ios.sh /
  25 |     COPY cross-toolchains/docker/ios-wrapper.c /
  26 | >>> RUN /ios.sh $CROSS_TARGET $TARGET_CPU
  27 |
  28 |     COPY cross-toolchains/docker/ios-symlink.sh /
--------------------
ERROR: failed to solve: process "/bin/sh -c /ios.sh $CROSS_TARGET $TARGET_CPU" did not complete successfully: exit code: 2

Unable to build `aarch64-apple-darwin` target

I am following these precise steps on PopOS 22.04 LTS:

# Setup cross toolchains
git clone https://github.com/cross-rs/cross
cd cross
git submodule update --init --remote
cargo xtask configure-crosstool

# Build docker images
cargo build-docker-image aarch64-apple-darwin-cross --build-arg 'MACOS_SDK_URL=https://github.com/joseluisq/macosx-sdks/releases/download/13.0/MacOSX13.0.sdk.tar.xz' --tag local

I get the following error:

... **snipped** ...
#0 163.3 create_symlink ./x86_64-apple-darwin22-install_name_tool ./arm64e-apple-darwin22-install_name_tool
#0 163.3 create_symlink ./x86_64-apple-darwin22-segedit ./arm64e-apple-darwin22-segedit
#0 163.3 create_symlink ./x86_64-apple-darwin22-ctf_insert ./arm64e-apple-darwin22-ctf_insert
#0 163.3 
#0 163.3 extracting MacOSX13.0.sdk.tar.xz ...
#0 168.2 mv: cannot stat '*OSX*13.0*sdk*': No such file or directory
#0 168.2 
#0 168.2 exiting with abnormal exit code (1)
#0 168.2 run 'OCDEBUG=1 ./build.sh' to enable debug messages
#0 168.2 
------
error: failed to solve: executor failed running [/bin/sh -c /darwin.sh]: exit code: 1
Error: 
   0: some error(s) encountered

Location:
   xtask/src/build_docker_image.rs:346

Error:

      0: `docker buildx build --platform linux/amd64 --build-arg 'CROSS_TARGET_TRIPLE=AARCH64_APPLE_DARWIN_CROSS' --load --pull --cache-from 'type=registry,ref=ghcr.io/cross-rs/aarch64-apple-darwin-cross:main' --tag ghcr.io/cross-rs/aarch64-apple-darwin-cross:local --label 'org.cross-rs.for-cross-target=aarch64-apple-darwin-cross' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' --file /home/scott/src/rust/cross/docker/cross-toolchains/docker/Dockerfile.aarch64-apple-darwin-cross --progress auto --build-arg 'MACOS_SDK_URL=https://github.com/joseluisq/macosx-sdks/releases/download/13.0/MacOSX13.0.sdk.tar.xz' .` failed with exit status: 1

   Location:
      xtask/src/build_docker_image.rs:309

   Warning: call to docker failed
   Suggestion: is `buildx` available for the container engine?
   Note: disable the `buildkit` dependency optionally with `CROSS_CONTAINER_ENGINE_NO_BUILDKIT=1`

I have tried with a local file in the docker folder with the MACOS_SDK_FILE option and get the same exact error. I get the same issue with the x86_64-apple-darwin target. Please advise if you would be so kind... I'm not sure if this is a bug or something I'm doing wrong, thx.

Instructions unclear for msvc build

Hi all, I'm trying to cross compile for Windows amd64 and arm64 while on a Windows host.

I'm attempting to follow the instructions for the msvc build but am failing - probably on something simple.

I'm using a Github Actions host using windows-latest. My build script looks like:

curl https://sh.rustup.rs -sSf | sh -s -- -y
cargo install cross

git clone https://github.com/cross-rs/cross /cross
cd /cross
git submodule update --init --remote

# I have tried with and without the following line
cargo xtask configure-crosstool x86_64-pc-windows-msvc

cargo build-docker-image x86_64-pc-windows-msvc --tag local

# Never gets this far
echo '\n' >> Cargo.toml
echo '[target.x86_64-pc-windows-msvc]\n' >> Cargo.toml
echo 'image = "ghcr.io/cross-rs/x86_64-pc-windows-msvc:local"\n' >> Cargo.toml

cross run --release --target x86_64-pc-windows-msvc

You can see the logs here: https://github.com/alshdavid-labs/cross-platform-binary-template/actions/runs/5892634303/job/15982367248

This results in the following error:

Run git clone https://github.com/cross-rs/cross /cross
Cloning into '/cross'...
Submodule 'docker/cross-toolchains' (https://github.com/cross-rs/cross-toolchains.git) registered for path 'docker/cross-toolchains'
Cloning into 'D:/cross/docker/cross-toolchains'...
Submodule path 'docker/cross-toolchains': checked out '4299096a1468f91aa9a[7](https://github.com/alshdavid-labs/cross-platform-binary-template/actions/runs/5892357823/job/15981437973#step:4:8)430e4763de6[8](https://github.com/alshdavid-labs/cross-platform-binary-template/actions/runs/5892357823/job/15981437973#step:4:9)5cb386a1'
    Updating crates.io index
 Downloading crates ...
  Downloaded same-file v1.0.6
  Downloaded thiserror-impl v1.0.40
   ....
   ....
   ....
   Compiling wildmatch v2.1.1
   Compiling xtask v0.0.0-dev.0 (D:\cross\xtask)
    Finished dev [unoptimized + debuginfo] target(s) in 1m 56s
     Running `target\debug\xtask.exe configure-crosstool x86_64-pc-windows-msvc`
Error: 
   0: unable to find config for target "x86_64-pc-windows-msvc"

Location:
   xtask\src\crosstool.rs:73

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: process didn't exit successfully: `target\debug\xtask.exe configure-crosstool x86_64-pc-windows-msvc` (exit code: 1)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target\debug\xtask.exe build-docker-image x86_64-pc-windows-msvc --tag local`
Error: 
   0: unable to find dockerfile for target "x86_64-pc-windows-msvc"

Location:
   xtask\src\build_docker_image.rs:105

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: process didn't exit successfully: `target\debug\xtask.exe build-docker-image x86_64-pc-windows-msvc --tag local` (exit code: 1)
Error: Process completed with exit code 1.

Can't configure crosstool for x86_64-unknown-linux-gnu

Hey, I'm trying to build an image to support a x86_64-unknown-linux-gnu target with version 2.25 for glibc, instead of the current version 2.23 used on ghcr.io/cross-rs/x86_64-unknown-linux-gnu. But it seems I am unable to configure it:

$ GLIBC_VERSION=2.25 cargo xtask configure-crosstool x86_64-unknown-linux-gnu
...
     Running `target/debug/xtask configure-crosstool x86_64-unknown-linux-gnu`
Error: 
   0: unable to find config for target "x86_64-unknown-linux-gnu"

Location:
   xtask/src/crosstool.rs:73

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

It doesn't work with x86_64-unknown-linux-gnu-sde-cross either. Am I misunderstanding something?

Thanks!

Replace ranlib to x86_64-apple-darwin-ranlib when build target x86_64-apple-darwin

When I build rust openssl, I get a ranlib error:

  ranlib: /alrd/target/x86_64-apple-darwin/release/build/openssl-sys-539748b120404349/out/openssl-build/install/lib/libcrypto.a.new: malformed archive
  make: *** [Makefile:326: install_dev] Error 1
  thread 'main' panicked at '


  Error installing OpenSSL:
      Command: "make" "install_dev"
      Exit status: exit status: 2


      ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.25.1+1.1.1t/src/lib.rs:509:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I check the ranlib:

$ which ranlib
/usr/bin/ranlib

$ ranlib
Usage: ranlib [options] archive
 Generate an index to speed access to archives
 The options are:
  @<file>                      Read options from <file>
  --plugin <name>              Load the specified plugin
  -D                           Use zero for symbol map timestamp (default)
  -U                           Use an actual symbol map timestamp
  -t                           Update the archive's symbol map timestamp
  -h --help                    Print this help message
  -v --version                 Print version information
ranlib: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-bigobj-x86-64 pe-i386 srec symbolsrec verilog tekhex binary ihex plugin

Should add the below code replace it in darwin-entry.sh:

declare -x RANLIB_${envvar_suffix}="${tools_prefix}"-ranlib

After replace, it works well for me.

Complex Build Scripts Fail with MSVC Targets

Summary

When trying to compile a crate with a complex, external build system, MSVC's cl frequently fails, due to unexpected arguments. Another example is #14.

Example

Cargo.toml

[package]
name = "openssl"
version = "0.1.0"
edition = "2021"

[dependencies]
openssl = "0.10"

[features]
default = []
vendored = ["openssl/vendored"]

Building then with cross build --target x86_64-pc-windows-msvc fails.

Error Output

The error output is as follows:

  0114:fixme:file:server_get_file_info Unsupported info class e                                                                                                                                     
  014c:fixme:nls:RtlSetThreadPreferredUILanguages 256, 0000000000000000, 0000000000000000                                                                                                           
  014c:fixme:nls:RtlGetThreadPreferredUILanguages 00000034, 000000000101D75C, 0000000000000000 000000000101D758                                                                                     
  014c:fixme:nls:get_dummy_preferred_ui_language (0x34 000000000101D75C 0000000000000000 000000000101D758) returning a dummy value (current locale)                                                 
  014c:fixme:nls:RtlGetThreadPreferredUILanguages 00000034, 000000000101D75C, 0000000001055790 000000000101D758                                                                                     
  014c:fixme:nls:get_dummy_preferred_ui_language (0x34 000000000101D75C 0000000001055790 000000000101D758) returning a dummy value (current locale)                                                 
  Microsoft (R) C/C++ Optimizing Compiler Version 19.32.31332 for x64                                                                                                                               
  Copyright (C) Microsoft Corporation.  All rights reserved.                                                                                                                                        
                                                                                                                                                                                                    
  014c:fixme:msvcp:_Locinfo__Locinfo_ctor_cat_cstr (000000000101F8A0 1 C) semi-stub                                                                                                                 
  014c:fixme:msvcp:_Locinfo__Locinfo_ctor_cat_cstr (000000000101F510 1 C) semi-stub                                                                                                                 
  014c:fixme:msvcp:_Locinfo__Locinfo_ctor_cat_cstr (000000000101F500 1 C) semi-stub                                                                                                                 
  cl : Command line warning D9002 : ignoring unknown option '-dM'                                                                                                                                   
  cl : Command line warning D9002 : ignoring unknown option '-x'                                                                                                                                    
  cl : Command line warning D9002 : ignoring unknown option '/dev/null'                                                                                                                             
  c                                                                                                                                                                                                 
  c1: fatal error C1083: Cannot open source file: 'c': No such file or directory                                                                                                                    
  thread 'main' panicked at 'failed to find nmake', /cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.20.0+1.1.1o/src/lib.rs:435:65                                                   
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 

The Makefile used by nmake that causes the above failure is (the suffix has been changed so it can be uploaded to Github):

makefile

Export Build Tools to Registry

Some complex builds such as OpenSSL require cc to find tools such as nmake.exe, which although are in the path, are not in the registry, nor is vswhere.exe installed.

Problems with building an Apple Silicon version

When I cross-build using GitHub Actions, it passes the build with no problem, but when I run it on an M-series Mac, it shows Intel (X86_64) and doesn't seem native.

The Target I use is aarch64-apple-darwin.

jobs:
  lints:
    name: Lints
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: clippy
      - uses: Swatinem/rust-cache@v1
      - name: Clippy
        run: cargo clippy -- -D warnings
      - name: Setup cargo-hack
        run: cargo install cargo-hack
      - name: Check all features
        run: cargo hack check --feature-powerset --no-dev-deps

  build:
    name: Build for ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            exe: rathole
            target: x86_64-unknown-linux-gnu
          - os: windows-latest
            exe: rathole.exe
            target: x86_64-pc-windows-msvc
          - os: macos-latest
            exe: rathole
            target: x86_64-apple-darwin
          - os: macos-latest
            exe: rathole
            target: aarch64-apple-darwin

    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
      - uses: Swatinem/rust-cache@v1
      - name: Build
        run: cargo build
      - name: Run tests
        run: cargo test --verbose
      - uses: actions/upload-artifact@v2
        with:
          name: rathole-${{ matrix.target }}
          path: target/debug/${{ matrix.exe }}

https://missuo.ru/file/66c6fd4a6f090132fd96b.png
https://missuo.ru/file/8674db3a25b8bbdd82f5d.png

'bash\r': No such file or directory

Error
'bash\r': No such file or directory
happens when, f.e. trying to cross build from windows to mac os due to CRLF end lines in some files (f.e. darwin.sh, but I noticed a lot of others with the same).

To check the file you can do (on windows f.e. in git bash):

git clone https://github.com/cross-rs/cross-toolchains
cat -e cross-toolchains/docker/darwin.sh

if you see ^M$ at end lines, f.e. like this:

#!/usr/bin/env bash^M$
^M$
set -x^M$

That file would be broken when running it from docker (which is what cross is doing).

I did not have the same issue on linux machine (probably some tooling - likely git - replaces CRLF to LF automatically; while it does not happen on windows machines).

Publish more images

When I try to consume cross-toolchains images, then Docker often complains of missing images from the GHCR.

$ cat Cross.toml
[target.aarch64-pc-windows-msvc]
image = "ghcr.io/cross-rs/aarch64-pc-windows-msvc:local"

$ cross build --target aarch64-pc-windows-msvc
Unable to find image 'ghcr.io/cross-rs/aarch64-pc-windows-msvc:local' locally
docker: Error response from daemon: Head "https://ghcr.io/v2/cross-rs/aarch64-pc-windows-msvc/manifests/local": denied.
See 'docker run --help'.

Unable to build Docker image missing common.sh

# Attempting to build the Docker image using the command provided in the README.md
jshbrntt@prophet:~/cross-toolchains$ cargo build-docker-image x86_64-pc-windows-msvc-cross --tag local
error: no such subcommand: `build-docker-image`

jshbrntt@prophet:~/cross-toolchains$ cd docker

# Attempting to build the Docker image manually using the Docker CLI
jshbrntt@prophet:~/cross-toolchains/docker$ docker build -f Dockerfile.x86_64-pc-windows-msvc-cross -t ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local .
Sending build context to Docker daemon  81.92kB
Step 1/21 : FROM ubuntu:20.04
20.04: Pulling from library/ubuntu
fb0b3276a519: Pull complete
Digest: sha256:9c2004872a3a9fcec8cc757ad65c042de1dad4da27de4c70739a6e36402213e3
Status: Downloaded newer image for ubuntu:20.04
 ---> 817578334b4d
Step 2/21 : ARG DEBIAN_FRONTEND=noninteractive
 ---> Running in df2d9997bec1
Removing intermediate container df2d9997bec1
 ---> 7e883893d023
Step 3/21 : COPY common.sh lib.sh /
COPY failed: file not found in build context or excluded by .dockerignore: stat common.sh: file does not exist

Add `CROSS_SYSROOT` to Images

A recent PR cross-rs/cross#1080 simplifies installing third-party libraries to the system root by adding CROSS_SYSROOT to the images. This can be used to ensure the compiler and linker find external dependencies built from source or to install pre-built libraries.

Avoid critical config in the entrypoint (ignored by `CROSS_REMOTE=1`)

During this week, I configured my repo to use GitLab CI to cross-compile to Mac (target x86_64-apple-darwin). I figured it out in the end, but it was a bit tricky.

First of all, I followed the help in this issue which was very helpful. This let me cross compile to ARM. In particular, I've set CROSS_REMOTE=1.

The issue I've hit was that I had ring as a dependency, and it failed to compile in GitLab CI. This was because it used the Linux compiler instead of the the one from osxcross (cc: error: unrecognized command line option '-arch').

Full ring error
error: failed to run custom build command for `ring v0.16.20`
Caused by:
  process didn't exit successfully: `/cross/project/target/release/build/ring-719859dcd2b78047/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("z")
  TARGET = Some("x86_64-apple-darwin")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-apple-darwin
  CC_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_x86_64_apple_darwin
  CC_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64-apple-darwin
  CFLAGS_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_apple_darwin
  CFLAGS_x86_64_apple_darwin = Some("-stdlib=libc++")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
  --- stderr
  running "cc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-stdlib=libc++" "-I" "include" "-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/cross/project/target/x86_64-apple-darwin/release/build/ring-dc3763bb75c01cb2/out/aesni-x86_64-macosx.o" "/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'
  cc: error: unrecognized command line option '-stdlib=libc++'
  thread 'main' panicked at 'execution failed', /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
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "non-success exit status"', xtask/src/main.rs:60:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After adding some debug statements and comparing it to the logs when building locally using cross, I found that when using CROSS_REMOTE=1, the 4 environment variables defined in the entrypoint darwin-entry.sh were missing. In my case, those were:

  • AR_x86_64_apple_darwin
  • CC_x86_64_apple_darwin
  • CXX_x86_64_apple_darwin
  • CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER

I did not dig too much into it, but I assume it's because the entrypoint is ignored when using CROSS_REMOTE=1. As a workaround, I created a derived image where I've set the variables directly in the Dockerfile with ENV statements: this fixed the issue.

A solution to avoid this issue would be to avoid putting critical configuration value in the entrypoints. Another solution would be for CROSS_REMOTE to use the entrypoint.

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.