cross icon indicating copy to clipboard operation
cross copied to clipboard

Can't build on Apple Silicone, cross doesn't use custom image or hangs

Open ChzenChzen opened this issue 3 years ago • 36 comments

I built custom docker image for solving openssl issues. Dockerfile

FROM rustembedded/cross:aarch64-unknown-linux-musl
#FROM rustembedded/cross:aarch64-unknown-linux-musl-0.2.1 - the same issue
COPY openssl.sh /
RUN bash /openssl.sh linux-aarch64 aarch64-linux-musl-

ENV OPENSSL_DIR=/openssl \
    OPENSSL_INCLUDE_DIR=/openssl/include \
    OPENSSL_LIB_DIR=/openssl/lib

openssl.sh

set -ex

main() {
  local version=1.0.2t
  local os=$1 \
    triple=$2

  local dependencies=(
    ca-certificates
    curl
    m4
    make
    perl
  )

  # NOTE cross toolchain must be already installed
  apt-get update
  local purge_list=()
  for dep in ${dependencies[@]}; do
    if ! dpkg -L $dep; then
      apt-get install --no-install-recommends -y $dep
      purge_list+=($dep)
    fi
  done

  td=$(mktemp -d)

  pushd $td
  curl https://www.openssl.org/source/openssl-$version.tar.gz |
    tar --strip-components=1 -xz
  AR=${triple}ar CC=${triple}gcc ./Configure \
    --prefix=/openssl \
    no-dso \
    $os \
    -fPIC \
    ${@:3}
  nice make -j$(nproc)
  make install

  # clean up
  apt-get purge --auto-remove -y ${purge_list[@]}

  popd

  rm -rf $td
  rm $0
}

main "${@}"

My docker build command: docker build -t fomotoshi/openssl:latest cross/

Cross.toml

[target.aarch64-unknown-linux-musl]
image = "fomotoshi/openssl:latest"

my issue:

cross build --target aarch64-unknown-linux-musl
cross build --target aarch64-unknown-linux-musl
   Compiling openssl-sys v0.9.63
   Compiling socket2 v0.4.0
   Compiling aho-corasick v0.7.18
   Compiling atty v0.2.14
   Compiling futures-util v0.3.15
   Compiling indexmap v1.6.2
   Compiling futures-channel v0.3.15
   Compiling syn v1.0.72
   Compiling parking_lot v0.11.1
error: failed to run custom build command for `openssl-sys v0.9.63`

Caused by:
  process didn't exit successfully: `/Users/fomotoshi/Documents/projects/bitcoin_mixer/target/debug/build/openssl-sys-c7100d1a7e5f4dbd/build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR
  AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR
  AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR
  AARCH64_UNKNOWN_LINUX_MUSL_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_aarch64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_musl
  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_aarch64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: "pkg-config has not been configured to support cross-compilation.\n\n                Install a sysroot for the target platform and configure it via\n                PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\n                cross-compiling wrapper for pkg-config and set it via\n                PKG_CONFIG environment variable."

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = aarch64-apple-darwin
  $TARGET = aarch64-unknown-linux-musl
  openssl-sys = 0.9.63

  ', /Users/fomotoshi/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.63/build/find_normal.rs:174:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

It looks like cross doesn't use my custom image for building.

I also tried to downgrade rustup to 1.49. and use minimal profile, but had the same issue.

rustup show 
Default host: aarch64-apple-darwin
rustup home:  /Users/fomotoshi/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin
nightly-aarch64-apple-darwin
1.49-aarch64-apple-darwin (default)

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
aarch64-unknown-linux-musl

active toolchain
----------------

1.49-aarch64-apple-darwin (default)
rustc 1.49.0 (e1884a8e3 2020-12-29)
cross --version
cross 0.2.1
cargo 1.49.0 (d00d64df9 2020-12-05)

ChzenChzen avatar May 21 '21 22:05 ChzenChzen

I also have the same project on intel laptop and there is work fine on the laptop.

ChzenChzen avatar May 21 '21 22:05 ChzenChzen

If you are not sure that your image is used you can run cross with cross build -vv --target aarch64-unknown-linux-musl. The -vv gives you the docker run command.

olitha avatar May 27 '21 09:05 olitha

I might have the same issue, cross did not pull any docker images on Apple silicon Mac host.

novuscy avatar May 29 '21 10:05 novuscy

Having the same issue...

Selyatin avatar Jun 02 '21 12:06 Selyatin

Guys after installing Docker Desktop and installing from master using the command cargo install --git https://github.com/rust-embedded/cross.git it's downloading the images properly, but I'm getting this error

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
error: could not compile `typenum`

Caused by:
  process didn't exit successfully: `rustc --crate-name build_script_main --edition=2018 /cargo/registry/src/github.com-1ecc6299db9ec823/typenum-1.13.0/build/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=392454c66f8e2573 -C extra-filename=-392454c66f8e2573 --out-dir /target/release/build/typenum-392454c66f8e2573 -L dependency=/target/release/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)

Selyatin avatar Jun 02 '21 13:06 Selyatin

@Selyatin Maybe increasing Docker's available RAM setting will help you

DevNulPavel avatar Aug 31 '21 12:08 DevNulPavel

I experienced the same issue with Apple Silicon (not using Docker) and it was solved by using master. Building however completely freezes after a short while.

ivnsch avatar Nov 06 '21 15:11 ivnsch

Did anyone find a solution? Why was this closed?

BouweCeunen avatar Apr 15 '22 14:04 BouweCeunen

@BouweCeunen what error are you getting and are you running with the newest (unreleased) code?

Emilgardis avatar Apr 15 '22 15:04 Emilgardis

@BouweCeunen what error are you getting and are you running with the newest (unreleased) code?

I did cargo install cross and then cross build --target x86_64-unknown-linux-musl but got

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
(signal: 11, SIGSEGV: invalid memory reference)

Maybe not related to cross, but just wondering if anyone here found a solution.

BouweCeunen avatar Apr 16 '22 09:04 BouweCeunen

@BouweCeunen right!

Do you have a better experience if you do

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

Emilgardis avatar Apr 16 '22 12:04 Emilgardis

@BouweCeunen right!

Do you have a better experience if you do

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

Now it hangs for some reason Building [=======> ] 78/244: pkg-config, ipnet, typenum(build.rs), cc, unicode-bidi, regex-syntax, tracing-core, au... 🤔 will do some more digging, already thank you for the replies.

BouweCeunen avatar Apr 16 '22 22:04 BouweCeunen

@BouweCeunen did you ever figure this out? I'm getting the same freezing on an M1

JayKickliter avatar Jun 23 '22 22:06 JayKickliter

I have a M1 myself now, I've been doing most of my work via ssh on my regular box but I've experienced this when building locally via cross. It seems the major culprit is pkg-config, I suspect the issue is something to do with file-access and/or binary execution through docker via the x86_64 compat. Need to debug it further, or implement native aarch64 images, see #751

Emilgardis avatar Jun 23 '22 23:06 Emilgardis

@BouweCeunen did you ever figure this out? I'm getting the same freezing on an M1

No not really, ended up not using this.

BouweCeunen avatar Jun 24 '22 11:06 BouweCeunen

Hey! I got same issue on last master

cross 0.2.2 (eb2b8ad 2022-06-27)
[cross] note: Falling back to `cargo` on the host.
cargo 1.61.0 (a028ae42f 2022-04-29)

Mnwa avatar Jun 27 '22 21:06 Mnwa

Does anyone know a cloud service I can test on an M1 system and not pay a fortune? Like, SSH access? I'd love to be able to fix this but latest macOS system is a 2013 MacBook Pro, and Qemu isn't cutting it.

Alexhuszagh avatar Jun 27 '22 21:06 Alexhuszagh

So, if you need I could help you with debug.

Mnwa avatar Jun 27 '22 21:06 Mnwa

So, if you need I could help you with debug.

Sure, can you first try compiling a simple crate rust-cpp-hello-world with the --verbose flag for cross installed from main?

git clone https://github.com/cross-rs/cross
cd cross
# you can also install, but this is so your environment stays clean
cargo build
cd ..

git clone https://github.com/cross-rs/rust-cpp-hello-word
cd rust-cpp-hello-word
../cross/target/debug/cross build --target $TARGET --verbose

If you could give me that info, that'd be a great starting point. I'd also love to be able to debug it on a machine I have SSH access to, but I currently don't have a way to use a machine.

Also showing me the output of a few commands:

$ rustup target list
$ rustup toolchain list
$ rustc --print sysroot

Alexhuszagh avatar Jun 27 '22 21:06 Alexhuszagh

Targets info:

rustup target list 

aarch64-apple-darwin
aarch64-apple-ios
aarch64-apple-ios-sim
aarch64-fuchsia
aarch64-linux-android
aarch64-pc-windows-msvc
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
aarch64-unknown-none
aarch64-unknown-none-softfloat
arm-linux-androideabi
arm-unknown-linux-gnueabi
arm-unknown-linux-gnueabihf
arm-unknown-linux-musleabi
arm-unknown-linux-musleabihf
armebv7r-none-eabi
armebv7r-none-eabihf
armv5te-unknown-linux-gnueabi
armv5te-unknown-linux-musleabi
armv7-linux-androideabi
armv7-unknown-linux-gnueabi
armv7-unknown-linux-gnueabihf
armv7-unknown-linux-musleabi
armv7-unknown-linux-musleabihf
armv7a-none-eabi
armv7r-none-eabi
armv7r-none-eabihf
asmjs-unknown-emscripten
i586-pc-windows-msvc
i586-unknown-linux-gnu
i586-unknown-linux-musl
i686-linux-android
i686-pc-windows-gnu
i686-pc-windows-msvc
i686-unknown-freebsd
i686-unknown-linux-gnu
i686-unknown-linux-musl
mips-unknown-linux-gnu
mips-unknown-linux-musl
mips64-unknown-linux-gnuabi64
mips64-unknown-linux-muslabi64
mips64el-unknown-linux-gnuabi64
mips64el-unknown-linux-muslabi64
mipsel-unknown-linux-gnu
mipsel-unknown-linux-musl
nvptx64-nvidia-cuda
powerpc-unknown-linux-gnu
powerpc64-unknown-linux-gnu
powerpc64le-unknown-linux-gnu
riscv32i-unknown-none-elf
riscv32imac-unknown-none-elf
riscv32imc-unknown-none-elf
riscv64gc-unknown-linux-gnu
riscv64gc-unknown-none-elf
riscv64imac-unknown-none-elf
s390x-unknown-linux-gnu
sparc64-unknown-linux-gnu
sparcv9-sun-solaris
thumbv6m-none-eabi
thumbv7em-none-eabi
thumbv7em-none-eabihf
thumbv7m-none-eabi
thumbv7neon-linux-androideabi
thumbv7neon-unknown-linux-gnueabihf
thumbv8m.base-none-eabi
thumbv8m.main-none-eabi
thumbv8m.main-none-eabihf
wasm32-unknown-emscripten
wasm32-unknown-unknown
wasm32-wasi
x86_64-apple-darwin (installed)
x86_64-apple-ios
x86_64-fortanix-unknown-sgx
x86_64-fuchsia
x86_64-linux-android
x86_64-pc-solaris
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
x86_64-sun-solaris
x86_64-unknown-freebsd
x86_64-unknown-illumos
x86_64-unknown-linux-gnu (installed)
x86_64-unknown-linux-gnux32
x86_64-unknown-linux-musl (installed)
x86_64-unknown-netbsd
x86_64-unknown-redox
rustup toolchain list

stable-x86_64-apple-darwin (default)
stable-x86_64-unknown-linux-gnu
nightly-x86_64-apple-darwin
rustc --print sysroot 

/Users/mnwa/.rustup/toolchains/stable-x86_64-apple-darwin

Mnwa avatar Jun 27 '22 21:06 Mnwa

So, compiling is freezing for x86_64-unknown-linux-musl with stdout:

../cross/target/debug/cross build --target x86_64-unknown-linux-musl --verbose
+ cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-musl
+ rustc --print sysroot
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ /usr/local/bin/docker
+ /usr/local/bin/docker run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=mnwa' --rm --user 501:20 -v /Users/mnwa/.xargo:/xargo:Z -v /Users/mnwa/.cargo:/cargo:Z -v /cargo/bin -v /Users/mnwa/crossdebug/rust-cpp-hello-word:/project:Z -v /Users/mnwa/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:Z,ro -v /Users/mnwa/crossdebug/rust-cpp-hello-word/target:/target:Z -w /project -i -t ghcr.io/cross-rs/x86_64-unknown-linux-musl:main sh -c 'PATH=$PATH:/rust/bin cargo build --target x86_64-unknown-linux-musl'
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
   Compiling cc v1.0.73
    Building [                             ] 0/4: cc

Mnwa avatar Jun 27 '22 21:06 Mnwa

x86_64-unknown-linux-gnu is same

../cross/target/debug/cross build --target x86_64-unknown-linux-gnu --verbose
+ cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ /usr/local/bin/docker
+ /usr/local/bin/docker run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=mnwa' --rm --user 501:20 -v /Users/mnwa/.xargo:/xargo:Z -v /Users/mnwa/.cargo:/cargo:Z -v /cargo/bin -v /Users/mnwa/crossdebug/rust-cpp-hello-word:/project:Z -v /Users/mnwa/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:Z,ro -v /Users/mnwa/crossdebug/rust-cpp-hello-word/target:/target:Z -w /project -i -t ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main sh -c 'PATH=$PATH:/rust/bin cargo build --target x86_64-unknown-linux-gnu'
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
   Compiling cc v1.0.73
    Building [                             ] 0/4: cc

Mnwa avatar Jun 27 '22 21:06 Mnwa

That all seems normal. Can you try running basically the same command except an interactive shell?

/usr/local/bin/docker run \
    --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' \
    -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' \
    -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' \
    -e TERM -e 'USER=mnwa' --rm --user 501:20 \
    -v /Users/mnwa/.xargo:/xargo:Z \
    -v /Users/mnwa/.cargo:/cargo:Z \
    -v /cargo/bin \
    -v /Users/mnwa/crossdebug/rust-cpp-hello-word:/project:Z \
    -v /Users/mnwa/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:Z,ro \
    -v /Users/mnwa/crossdebug/rust-cpp-hello-word/target:/target:Z \
    -w /project -it ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main bash

Then do the following in the shell:

export PATH="$PATH":/rust/bin

And try doing stuff like cargo --version, rustc --version, rustc --print sysroot, rustc --print target-features --target x86_64-unknown-linux-musl. Except for maybe the sysroot, I don't need the output of this: just to confirm it works.

If that all works, try build commands and see what's going on with a system profiler (like top), when running it in the background.

Alexhuszagh avatar Jun 27 '22 21:06 Alexhuszagh

cargo --version
cargo 1.61.0 (a028ae4 2022-04-29)
rustc --version
rustc 1.61.0 (fe5b13d68 2022-05-18)
rustc --print sysroot
/rust
rustc --print target-features --target x86_64-unknown-linux-musl

Features supported by rustc for this target:
    adx                             - Support ADX instructions.
    aes                             - Enable AES instructions.
    avx                             - Enable AVX instructions.
    avx2                            - Enable AVX2 instructions.
    avx512bf16                      - Support bfloat16 floating point.
    avx512bitalg                    - Enable AVX-512 Bit Algorithms.
    avx512bw                        - Enable AVX-512 Byte and Word Instructions.
    avx512cd                        - Enable AVX-512 Conflict Detection Instructions.
    avx512dq                        - Enable AVX-512 Doubleword and Quadword Instructions.
    avx512er                        - Enable AVX-512 Exponential and Reciprocal Instructions.
    avx512f                         - Enable AVX-512 instructions.
    avx512gfni                      - Enable Galois Field Arithmetic Instructions.
    avx512ifma                      - Enable AVX-512 Integer Fused Multiple-Add.
    avx512pf                        - Enable AVX-512 PreFetch Instructions.
    avx512vaes                      - Promote selected AES instructions to AVX512/AVX registers.
    avx512vbmi                      - Enable AVX-512 Vector Byte Manipulation Instructions.
    avx512vbmi2                     - Enable AVX-512 further Vector Byte Manipulation Instructions.
    avx512vl                        - Enable AVX-512 Vector Length eXtensions.
    avx512vnni                      - Enable AVX-512 Vector Neural Network Instructions.
    avx512vp2intersect              - Enable AVX-512 vp2intersect.
    avx512vpclmulqdq                - Enable vpclmulqdq instructions.
    avx512vpopcntdq                 - Enable AVX-512 Population Count Instructions.
    bmi1                            - Support BMI instructions.
    bmi2                            - Support BMI2 instructions.
    cmpxchg16b                      - 64-bit with cmpxchg16b.
    ermsb                           - REP MOVS/STOS are fast.
    f16c                            - Support 16-bit floating point conversion instructions.
    fma                             - Enable three-operand fused multiple-add.
    fxsr                            - Support fxsave/fxrestore instructions.
    lzcnt                           - Support LZCNT instruction.
    movbe                           - Support MOVBE instruction.
    pclmulqdq                       - Enable packed carry-less multiplication instructions.
    popcnt                          - Support POPCNT instruction.
    rdrand                          - Support RDRAND instruction.
    rdseed                          - Support RDSEED instruction.
    rtm                             - Support RTM instructions.
    sha                             - Enable SHA instructions.
    sse                             - Enable SSE instructions.
    sse2                            - Enable SSE2 instructions.
    sse3                            - Enable SSE3 instructions.
    sse4.1                          - Enable SSE 4.1 instructions.
    sse4.2                          - Enable SSE 4.2 instructions.
    sse4a                           - Support SSE 4a instructions.
    ssse3                           - Enable SSSE3 instructions.
    tbm                             - Enable TBM instructions.
    xsave                           - Support xsave instructions.
    xsavec                          - Support xsavec instructions.
    xsaveopt                        - Support xsaveopt instructions.
    xsaves                          - Support xsaves instructions.
    crt-static                      - Enables C Run-time Libraries to be statically linked.

Code-generation features supported by LLVM for this target:
    16bit-mode                      - 16-bit mode (i8086).
    32bit-mode                      - 32-bit mode (80386).
    3dnow                           - Enable 3DNow! instructions.
    3dnowa                          - Enable 3DNow! Athlon instructions.
    64bit                           - Support 64-bit instructions.
    64bit-mode                      - 64-bit mode (x86_64).
    amx-bf16                        - Support AMX-BF16 instructions.
    amx-int8                        - Support AMX-INT8 instructions.
    amx-tile                        - Support AMX-TILE instructions.
    avx512fp16                      - Support 16-bit floating point.
    avxvnni                         - Support AVX_VNNI encoding.
    branchfusion                    - CMP/TEST can be fused with conditional branches.
    cldemote                        - Enable Cache Demote.
    clflushopt                      - Flush A Cache Line Optimized.
    clwb                            - Cache Line Write Back.
    clzero                          - Enable Cache Line Zero.
    cmov                            - Enable conditional move instructions.
    crc32                           - Enable SSE 4.2 CRC32 instruction.
    cx8                             - Support CMPXCHG8B instructions.
    enqcmd                          - Has ENQCMD instructions.
    false-deps-lzcnt-tzcnt          - LZCNT/TZCNT have a false dependency on dest register.
    false-deps-popcnt               - POPCNT has a false dependency on dest register.
    fast-11bytenop                  - Target can quickly decode up to 11 byte NOPs.
    fast-15bytenop                  - Target can quickly decode up to 15 byte NOPs.
    fast-7bytenop                   - Target can quickly decode up to 7 byte NOPs.
    fast-bextr                      - Indicates that the BEXTR instruction is implemented as a single uop with good throughput.
    fast-gather                     - Indicates if gather is reasonably fast.
    fast-hops                       - Prefer horizontal vector math instructions (haddp, phsub, etc.) over normal vector instructions with shuffles.
    fast-lzcnt                      - LZCNT instructions are as fast as most simple integer ops.
    fast-movbe                      - Prefer a movbe over a single-use load + bswap / single-use bswap + store.
    fast-scalar-fsqrt               - Scalar SQRT is fast (disable Newton-Raphson).
    fast-scalar-shift-masks         - Prefer a left/right scalar logical shift pair over a shift+and pair.
    fast-shld-rotate                - SHLD can be used as a faster rotate.
    fast-variable-crosslane-shuffle - Cross-lane shuffles with variable masks are fast.
    fast-variable-perlane-shuffle   - Per-lane shuffles with variable masks are fast.
    fast-vector-fsqrt               - Vector SQRT is fast (disable Newton-Raphson).
    fast-vector-shift-masks         - Prefer a left/right vector logical shift pair over a shift+and pair.
    fma4                            - Enable four-operand fused multiple-add.
    fsgsbase                        - Support FS/GS Base instructions.
    fsrm                            - REP MOVSB of short lengths is faster.
    hreset                          - Has hreset instruction.
    idivl-to-divb                   - Use 8-bit divide for positive values less than 256.
    idivq-to-divl                   - Use 32-bit divide for positive values less than 2^32.
    invpcid                         - Invalidate Process-Context Identifier.
    kl                              - Support Key Locker kl Instructions.
    lea-sp                          - Use LEA for adjusting the stack pointer.
    lea-uses-ag                     - LEA instruction needs inputs at AG stage.
    lvi-cfi                         - Prevent indirect calls/branches from using a memory operand, and precede all indirect calls/branches from a register with an LFENCE instruction to serialize control flow. Also decompose RET instructions into a POP+LFENCE+JMP sequence..
    lvi-load-hardening              - Insert LFENCE instructions to prevent data speculatively injected into loads from being used maliciously..
    lwp                             - Enable LWP instructions.
    macrofusion                     - Various instructions can be fused with conditional branches.
    mmx                             - Enable MMX instructions.
    movdir64b                       - Support movdir64b instruction.
    movdiri                         - Support movdiri instruction.
    mwaitx                          - Enable MONITORX/MWAITX timer functionality.
    nopl                            - Enable NOPL instruction.
    pad-short-functions             - Pad short functions.
    pconfig                         - platform configuration instruction.
    pku                             - Enable protection keys.
    prefer-128-bit                  - Prefer 128-bit AVX instructions.
    prefer-256-bit                  - Prefer 256-bit AVX instructions.
    prefer-mask-registers           - Prefer AVX512 mask registers over PTEST/MOVMSK.
    prefetchwt1                     - Prefetch with Intent to Write and T1 Hint.
    prfchw                          - Support PRFCHW instructions.
    ptwrite                         - Support ptwrite instruction.
    rdpid                           - Support RDPID instructions.
    retpoline                       - Remove speculation of indirect branches from the generated code, either by avoiding them entirely or lowering them with a speculation blocking construct.
    retpoline-external-thunk        - When lowering an indirect call or branch using a `retpoline`, rely on the specified user provided thunk rather than emitting one ourselves. Only has effect when combined with some other retpoline feature.
    retpoline-indirect-branches     - Remove speculation of indirect branches from the generated code.
    retpoline-indirect-calls        - Remove speculation of indirect calls from the generated code.
    sahf                            - Support LAHF and SAHF instructions in 64-bit mode.
    serialize                       - Has serialize instruction.
    seses                           - Prevent speculative execution side channel timing attacks by inserting a speculation barrier before memory reads, memory writes, and conditional branches. Implies LVI Control Flow integrity..
    sgx                             - Enable Software Guard Extensions.
    shstk                           - Support CET Shadow-Stack instructions.
    slow-3ops-lea                   - LEA instruction with 3 ops or certain registers is slow.
    slow-incdec                     - INC and DEC instructions are slower than ADD and SUB.
    slow-lea                        - LEA instruction with certain arguments is slow.
    slow-pmaddwd                    - PMADDWD is slower than PMULLD.
    slow-pmulld                     - PMULLD instruction is slow.
    slow-shld                       - SHLD instruction is slow.
    slow-two-mem-ops                - Two memory operand instructions are slow.
    slow-unaligned-mem-16           - Slow unaligned 16-byte memory access.
    slow-unaligned-mem-32           - Slow unaligned 32-byte memory access.
    soft-float                      - Use software floating point features.
    sse-unaligned-mem               - Allow unaligned memory operands with SSE instructions.
    tagged-globals                  - Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits..
    tsxldtrk                        - Support TSXLDTRK instructions.
    uintr                           - Has UINTR Instructions.
    use-aa                          - Use alias analysis during codegen.
    use-glm-div-sqrt-costs          - Use Goldmont specific floating point div/sqrt costs.
    use-slm-arith-costs             - Use Silvermont specific arithmetic costs.
    vzeroupper                      - Should insert vzeroupper instructions.
    waitpkg                         - Wait and pause enhancements.
    wbnoinvd                        - Write Back No Invalidate.
    widekl                          - Support Key Locker wide Instructions.
    x87                             - Enable X87 float instructions.
    xop                             - Enable XOP instructions.

Use +feature to enable a feature, or -feature to disable it.
For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2

Code-generation features cannot be used in cfg or #[target_feature],
and may be renamed or removed in a future version of LLVM or rustc.

Mnwa avatar Jun 27 '22 21:06 Mnwa

So, I ran cargo build & top and rust is calculating Screenshot 2022-06-28 at 00 42 18

Mnwa avatar Jun 27 '22 21:06 Mnwa

So, I ran cargo build & top and rust is calculating Screenshot 2022-06-28 at 00 42 18

So basically it's spinning in place indefinitely. That's... not a great sign. What's the output of lsb_release -a? Maybe I can try seeing if using aarch64-unknown-linux-gnu images for cross on the M1s will work :/.

Alexhuszagh avatar Jun 27 '22 21:06 Alexhuszagh

It does, but that could maybe be a coincidence or "good" luck when I've tested

Emilgardis avatar Jun 28 '22 06:06 Emilgardis

So, I ran cargo build & top and rust is calculating Screenshot 2022-06-28 at 00 42 18

So basically it's spinning in place indefinitely. That's... not a great sign. What's the output of lsb_release -a? Maybe I can try seeing if using aarch64-unknown-linux-gnu images for cross on the M1s will work :/.

aarch64-unknown-linux-gnu is same :(

../cross/target/debug/cross build --target aarch64-unknown-linux-gnu --verbose
+ cargo metadata --format-version 1 --filter-platform aarch64-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup --verbose target add aarch64-unknown-linux-gnu --toolchain stable-x86_64-unknown-linux-gnu
verbose: read metadata version: '12'
info: downloading component 'rust-std' for 'aarch64-unknown-linux-gnu'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2022-05-19/rust-std-1.61.0-aarch64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: installing component 'rust-std' for 'aarch64-unknown-linux-gnu'
verbose: creating temp directory: /Users/mnwa/.rustup/tmp/vrnmm3iyk9son9h7_dir
 35.6 MiB /  35.6 MiB (100 %)  14.4 MiB/s in  2s ETA:  0s
verbose: creating temp file: /Users/mnwa/.rustup/tmp/14qnj698z2b8gjog_file
verbose: creating temp file: /Users/mnwa/.rustup/tmp/zw85st0wmli2uwu__file
verbose: deleted temp directory: /Users/mnwa/.rustup/tmp/vrnmm3iyk9son9h7_dir
verbose: creating temp file: /Users/mnwa/.rustup/tmp/ec3lnn83tuh9sqca_file
verbose: creating temp file: /Users/mnwa/.rustup/tmp/v8wv95747jz3fje7_file
verbose: deleted temp file: /Users/mnwa/.rustup/tmp/14qnj698z2b8gjog_file
verbose: deleted temp file: /Users/mnwa/.rustup/tmp/zw85st0wmli2uwu__file
verbose: deleted temp file: /Users/mnwa/.rustup/tmp/ec3lnn83tuh9sqca_file
verbose: deleted temp file: /Users/mnwa/.rustup/tmp/v8wv95747jz3fje7_file
+ /usr/local/bin/docker
+ /usr/local/bin/docker run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=mnwa' --rm --user 501:20 -v /Users/mnwa/.xargo:/xargo:Z -v /Users/mnwa/.cargo:/cargo:Z -v /cargo/bin -v /Users/mnwa/crossdebug/rust-cpp-hello-word:/project:Z -v /Users/mnwa/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:Z,ro -v /Users/mnwa/crossdebug/rust-cpp-hello-word/target:/target:Z -w /project -i -t ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main sh -c 'PATH=$PATH:/rust/bin cargo build --target aarch64-unknown-linux-gnu'
Unable to find image 'ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main' locally
main: Pulling from cross-rs/aarch64-unknown-linux-gnu
58690f9b18fc: Already exists
b51569e7c507: Already exists
da8ef40b9eca: Already exists
fb15d46c38dc: Already exists
06e261ba4825: Pull complete
508ed4ede219: Pull complete
9777cffa81e7: Pull complete
eb05404c4b9f: Pull complete
50b11996bcd1: Pull complete
cf8b78ee1cd6: Pull complete
c937ea3571be: Pull complete
7dcfd506d82b: Pull complete
acc9280b3453: Pull complete
3a70200bafac: Pull complete
1af273002106: Pull complete
e5e4a2bf5281: Pull complete
9383ce3d8be6: Pull complete
10bf397477d0: Pull complete
Digest: sha256:570f9393184ce3f6eee7eb9aad1d025ad4732b2f5a22f13251d07b976fe3dd5c
Status: Downloaded newer image for ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
   Compiling cc v1.0.73
    Building [                             ] 0/4: c

Mnwa avatar Jun 28 '22 09:06 Mnwa

Youre not running on aarch64 here, youre using emulation. Need #751

Emilgardis avatar Jun 28 '22 10:06 Emilgardis

I might end up just getting a Mac M1 Mini and seeing if I can test locally. I think we might need the native aarch64 hosts.

Alexhuszagh avatar Jun 28 '22 13:06 Alexhuszagh