The environment variable target encountered an error while executing the build program

When cross-compiling with the specified target aarch64-unknown-linux-gnu, I found that the environment variable target changed during the execution of the build program for openssl-sys. What caused this?How should I set it to ensure it has the correct value(aarch64-unknown-linux-gnu)?
Additionally, there is another warning:

warning: build failed, waiting for other jobs to finish...
warning: openssl-sys@0.9.101: Compiler version doesn't include clang or GCC: "aarch64-linux-gnu-gcc" "--version"

You need a C compiler for aarch64-unknown-linux-gnu

This warning can be a false positive, and is most likely completely unrelated, so don't worry too much about it.

The real reason the build failed is not caused by this warning. Because of poor quality build script error integration in Cargo the real build error is somewhere below, under many irrelevant lines of variables. Read carefully to find the error somewhere towards the end of the stderr dump.

do you mean "aarch64-linux-gnu-gcc"?

root@33204eab7dab:~/src# env | grep aarch64-linux-gnu-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
CROSS_TOOLCHAIN_PREFIX=aarch64-linux-gnu-
AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
root@33204eab7dab:~/src#
root@33204eab7dab:~/src#
root@33204eab7dab:~/src# aarch64-linux-gnu-gcc
aarch64-linux-gnu-gcc: fatal error: no input files
compilation terminated.

I have already prepared the openssl dependency for aarch64-unknown-linux-gnu and configured the environment variables.

root@33204eab7dab:~/src# env | grep OPENSSL
AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/opt/openssl-1.1.0l/include
AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/opt/openssl-1.1.0l/lib

However, because the target changed to x86_64-unknown-linux-gnu, it started looking for the wrong environment variable. I verified this in a relatively simple project where the target was correct.

I found the issue: openssl-sys was compiled twice, with targets x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu respectively. However, I don't know why it was compiled twice.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.